Site
Creative row
A row of 4/5 creatives: even, as the banners line them up 16px apart, or peak, rising to the middle and centered on one line, as the deck cover sets them.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add creative-row<script type="module" src="/spyglass-ds/elements/creative-row.js"></script>Usage
A strip of proof beside a headline: a banner, a deck cover, the band under a hero. The row shrinks with its box and never scrolls.
Never
- A row that scrolls sideways: show fewer creatives
- More than seven creatives in a row
Each picture is an image slot (src, alt, fit, position); without src it keeps its placeholder, which carries data-ds-placeholder.
Adds with it: brand-light, creative-card
Props
The web component takes the same as attributes or properties (<spyglass-creative-row>); title is heading there.
<CreativeRow>
| Prop | Type | Default |
|---|---|---|
items | CreativeItem[] | |
variant | 'even' | 'peak' even (one size) or peak (rising to the middle). | 'even' |
className | string |
Examples
The same example in React and as web components; both render identically.
import { CreativeRow } from '@/react/components/site/CreativeRow'
// The banner's row: six creatives of one size.
const items = [
{ brand: 'Acme Skin', tone: 2 as const },
{ brand: 'Acme Drinks', tone: 3 as const },
{ brand: 'Acme Studio', tone: 1 as const },
{ brand: 'Acme Fit', tone: 4 as const },
{ brand: 'Acme Drinks', tone: 2 as const },
{ brand: 'Acme Motors', tone: 3 as const },
]
export default function Even() {
return <CreativeRow items={items} />
}<!-- The banner's row: six creatives of one size. -->
<spyglass-creative-row items='[{"brand":"Acme Skin","tone":2},{"brand":"Acme Drinks","tone":3},{"brand":"Acme Studio","tone":1},{"brand":"Acme Fit","tone":4},{"brand":"Acme Drinks","tone":2},{"brand":"Acme Motors","tone":3}]'></spyglass-creative-row>import { CreativeRow } from '@/react/components/site/CreativeRow'
// The deck cover's row: five creatives rising to the middle.
const items = [
{ brand: 'Acme Drinks', tone: 3 as const },
{ brand: 'Acme Fit', caption: 'Ten minute plan.', tone: 2 as const },
{ brand: 'Acme Studio', caption: 'Made to move.', tone: 4 as const },
{ brand: 'Acme Skin', caption: 'Does it work?', tone: 1 as const },
{ brand: 'Acme Drinks', tone: 3 as const },
]
export default function Peak() {
return <CreativeRow items={items} variant="peak" />
}<!-- The deck cover's row: five creatives rising to the middle. -->
<spyglass-creative-row variant="peak" items='[{"brand":"Acme Drinks","tone":3},{"brand":"Acme Fit","caption":"Ten minute plan.","tone":2},{"brand":"Acme Studio","caption":"Made to move.","tone":4},{"brand":"Acme Skin","caption":"Does it work?","tone":1},{"brand":"Acme Drinks","tone":3}]'></spyglass-creative-row>Source
import { BrandLight } from '@/react/components/visuals/BrandLight'
import { CreativeCard, type CreativeItem } from '@/react/components/site/CreativeCard'
import { peakWeights } from '@/lib/creative-layouts'
import { cn } from '@/react/lib/cn'
// A row of creatives, all 4/5. `even`: the banners' row, every creative the same size, 16px apart (X banner, Creative
// row). `peak`: the deck cover's row, rising to the middle (200, 240, 304, 240, 200 on the canvas) and centered on one
// line (Pitch deck cover, Row of creatives). The row keeps to its box: the creatives shrink with it, never scroll.
export interface CreativeRowProps {
items: CreativeItem[]
/** even (one size) or peak (rising to the middle). */
variant?: 'even' | 'peak'
className?: string
}
export function CreativeRow({ items, variant = 'even', className }: CreativeRowProps) {
const weights = variant === 'peak' ? peakWeights(items.length) : items.map(() => 1)
return (
<div data-ds="creative-row" className={cn('flex items-center gap-4 max-sm:gap-2', className)}>
{items.map(({ light, seed, ...item }, i) => (
<div key={i} className="min-w-0 basis-0" style={{ flexGrow: weights[i], aspectRatio: '4 / 5' }}>
{light ? <BrandLight variant="tile" seed={seed ?? i} cover className="size-full rounded-container" /> : <CreativeCard {...item} ratio="fill" />}
</div>
))}
</div>
)
}
export default CreativeRow// Joins class names, skipping falsy ones: cn('a', on && 'b', ['c', undefined]). It does not merge conflicting
// utilities (no tailwind-merge), as Vue's class binding does not: the library's classes are written not to compete,
// and a className from the caller is appended after them, as Vue appends a fallthrough class.
export type ClassValue = string | false | null | undefined | 0 | ClassValue[]
export function cn(...values: ClassValue[]): string {
const out: string[] = []
for (const v of values) {
if (!v) continue
if (Array.isArray(v)) {
const s = cn(...v)
if (s) out.push(s)
}
else out.push(v)
}
return out.join(' ')
}import type { ImageFit } from '@/lib/image'
import { html } from 'lit'
import { ifDefined } from 'lit/directives/if-defined.js'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { peakWeights } from '@/lib/creative-layouts'
import '@/elements/components/site/creative-card'
import '@/elements/components/visuals/brand-light'
import styles from 'virtual:tw'
// CreativeRow.tsx as <spyglass-creative-row>: a row of 4/5 creatives, `even` (one size) or `peak` (rising to the
// middle, as the deck cover). `items` is a list (JSON attribute or property).
export interface CreativeItem { src?: string; alt?: string; fit?: ImageFit; position?: string; brand?: string; caption?: string; tone?: 1 | 2 | 3 | 4; href?: string; light?: boolean; seed?: number }
/**
* @summary A row of creatives, even or rising to the middle.
*/
export class CreativeRow extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="creative-row"]'))
static properties = { items: { type: Array }, variant: {} }
/** The creatives. */
items: CreativeItem[] = []
/** even or peak. */
variant: 'even' | 'peak' = 'even'
render() {
const items = this.items ?? []
const weights = this.variant === 'peak' ? peakWeights(items.length) : items.map(() => 1)
return html`<div data-ds="creative-row" class="flex items-center gap-4 max-sm:gap-2">${items.map((it, i) => html`<div class="min-w-0 basis-0" style="flex-grow: ${weights[i]}; aspect-ratio: 4 / 5;">${it.light ? html`<spyglass-brand-light variant="tile" seed=${it.seed ?? i} cover class="size-full rounded-container"></spyglass-brand-light>` : html`<spyglass-creative-card ratio="fill" src=${ifDefined(it.src)} fit=${ifDefined(it.fit)} position=${ifDefined(it.position)} alt=${ifDefined(it.alt)} brand=${ifDefined(it.brand)} caption=${ifDefined(it.caption)} tone=${ifDefined(it.tone)} href=${ifDefined(it.href)}></spyglass-creative-card>`}</div>`)}</div>`
}
}
define('creative-row', CreativeRow)Reference: Figma page 8: X banner, Creative row (six 120x150, 16px apart); Pitch deck cover, Row of creatives (200x250, 240x300, 304x380, 240x300, 200x250, 16px apart).