SwAdNative

Ad Placement Four Essentials

  • Use case: native ad cards inside content feeds (mixed into list / grid feeds; slotKey e.g. home_feed)
  • Industry form: Native / In-feed ads (AdSDK format native)
  • Visual form: a card of cover image + title + description + advertiser + CTA, blending into the page style
  • Tracking events: same as banner — adImpression (once on entering the viewport via IntersectionObserver) / adClick; built-in zero-config, silent no-op when the tracker gate is off

Picking the wrong scenario = wrong ad_type / timing in tracking. See Ad Component Selection.

SwAdNative is the native feed ad slot component — a "text-card-type" self-rendering component of the ad foundation. It renders a native "image + title + description + advertiser + CTA" card that blends into a feed. It supports banner-list (single-column large-image cards) and grid (multi-column grid) layouts. Impression / click tracking is built in.

Native feed card (banner-list)

加载中...

Props

NameTypeRequiredDefaultDescription
itemsSwAdItem[]✓—Ad creative array (uses image/title/description/advertiser/cta)
slotKeystring✓—Ad slot key → ad_slot_key
slotNamestringundefinedAd slot name → ad_slot_name
pageKeystringundefinedPage key → page_key
pageNamestringundefinedPage name → page_name
ratiostring'16/9'Card main-image aspect ratio
radiusnumber | string8Corner radius (number = px, string passed to SwImage as-is, e.g. '1.125rem')
showAdLabelbooleanundefined"Ad" compliance badge; when not set it follows the global swiftConfig.ad.showLabel (default true), an explicit value always wins
layout'banner-list' | 'grid''banner-list'Layout: single-column cards / multi-column grid
gridColumnsnumber | { mobile?, tablet?, desktop? }2grid columns. Object form sets per-breakpoint tiers (<768 / 768-1023 / ≥1024), missing tiers fall back to the nearest one (same pattern as SwGallery columns)
gridGapnumber | string12Gap (number = px, string used as-is — can reference a token)

Events

NamePayloadDescription
load—Rendered
empty—items empty
impressionitems: SwAdItem[]Impression (auto tracking)
clickitem: SwAdItemA card clicked (auto tracking)
error—Render / load error

Feed grid (grid, 2 columns)

加载中...

Compliance badge (essential in-feed)

加载中...

Events

加载中...

Empty @empty

加载中...
<SwAdNative :items="feedAds" slot-key="feed_native" page-key="discover" ratio="16/9" :radius="8" show-ad-label />

<!-- Responsive columns: 1 on mobile / 2 on tablet / 3 on desktop -->
<SwAdNative :items="feedAds" slot-key="feed_native" layout="grid" :grid-columns="{ mobile: 1, tablet: 2, desktop: 3 }" />

<!-- gridGap / radius accept strings: tokens / rem -->
<SwAdNative :items="feedAds" slot-key="feed_native" layout="grid" grid-gap="1rem" radius="0.75rem" />

CSS variables

Layout is no longer inline style — everything lands as CSS variables, so business CSS can override the layout with plain rules, no !important needed:

VariableDefaultDescription
--sw-ad-native-gap12pxCard gap (maps to gridGap, applies to both banner-list and grid)
--sw-ad-native-cols-mobile / --sw-ad-native-cols-tablet / --sw-ad-native-cols-desktop2Grid column count per breakpoint (maps to gridColumns)

Caveats

  • Card fields: image (main image) / title / description / advertiser / cta (button text), driven by item data.
  • Tracking is built in and gated; see Ad & Tracking for full fields.