SwAdLabel

Ad Placement Four Essentials

  • Use case: compliance label (not an ad slot) — each SwAd* renders it internally per showAdLabel; use it directly when a custom non-standard slot needs a compliance label (the overlay variant needs position: relative on the container)
  • Industry form: Ad badge / label (a compliance requirement, not a delivery format)
  • Visual form: a small corner overlay badge (overlay, for image ads) / an inline tag (inline, for text ads)
  • Tracking events: none (pure label component, no reporting)

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

SwAdLabel is the "Ad" compliance badge component — it renders a small badge marking an item as advertising (an advertising-law compliance requirement). Every SwAd* component renders it by default (when showAdLabel is not set it follows the global swiftConfig.ad.showLabel, default true; sites whose creatives already carry a baked-in label turn it off globally); you can also use it standalone for custom ad slots.

Overlay badge (image ad slots)

加载中...

Inline tag (text ad slots)

加载中...

Custom text (Sponsored / AD)

加载中...

Props

NameTypeRequiredDefaultDescription
textstring'广告'Badge text (e.g. 'Sponsored' / 'Promoted')
variant'overlay' | 'inline''overlay'Form: overlay dark translucent badge (image ads; container needs position: relative) / inline in-flow tag (text ads; token colors adapt to light/dark)

Usage

<!-- Default "广告" (overlay, for image ad slots) -->
<SwAdLabel />

<!-- Inline variant (text ad slots: flows with text, doesn't cover it) -->
<SwAdLabel variant="inline" />

<!-- Custom text -->
<SwAdLabel text="Sponsored" />

CSS variables

VariableDefaultDescription
--sw-ad-label-z10Overlay-variant badge z-index (compliance chrome, above the creative by default)

Caveats

  • Prefer the showAdLabel prop on SwAd* components — each ad component bundles this badge, so you don't stack it manually. Use SwAdLabel standalone only for custom ad slots.
  • Pick the variant by slot type: image slots (Banner / Mrec / Icon / Native / Popup…) use the default overlay; text slots (custom text links / tickers) use inline — the overlay form covers single-line text (SwAdText / SwAdMarquee already use inline internally).
  • This is the simplest display-only component of the ad foundation — no events, no tracking.