SwAdLabel
Ad Placement Four Essentials
- Use case: compliance label (not an ad slot) — each
SwAd*renders it internally pershowAdLabel; use it directly when a custom non-standard slot needs a compliance label (the overlay variant needsposition: relativeon 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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
text | string | '广告' | 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
| Variable | Default | Description |
|---|---|---|
--sw-ad-label-z | 10 | Overlay-variant badge z-index (compliance chrome, above the creative by default) |
Caveats
- Prefer the
showAdLabelprop onSwAd*components — each ad component bundles this badge, so you don't stack it manually. UseSwAdLabelstandalone 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) useinline— the overlay form covers single-line text (SwAdText/SwAdMarqueealready use inline internally). - This is the simplest display-only component of the ad foundation — no events, no tracking.