Blocks

Pricing table block

Plans side by side: an optional centered heading and line over plan cards on the #262626 fill, each the same width, centered as a row; one plan sits alone in the middle.

Install

React apps get the React files; every other stack gets the web component.

npx spyglass-ds add pricing-table-block
<script type="module" src="/spyglass-ds/elements/pricing-table-block.js"></script>
The Creator plan

One plan. Everything in it.

Creator

$10 for your first month, then $20/month

  • AI-powered research across brands, creators, ads, and campaigns
  • Unlimited board swipe files, alerts, and tracked brands
  • Unlimited team seats
Start Creator for 50% off
Acme's three plans

Plans for every team.

Every plan is billed monthly.

Acme Solo

$12/month

  • One seat
  • Ten tracked brands

Acme Team

$40/month

  • Five seats
  • Fifty tracked brands
  • Shared boards

Acme Studio

$90/month

  • Unlimited seats
  • Unlimited tracked brands
  • Shared boards
  • Alerts

Usage

A pricing section with one to three plans, each stated exactly as sold.

Never

  • A price or feature the plan does not state
  • A highlighted plan in a spectrum color or with a glow
  • More than three plans in a row

Adds with it: plan-card

Props

The web component takes the same as attributes or properties (<spyglass-pricing-table-block>); title is heading there.

<PricingTableBlock>

PropTypeDefault
plansPlan[]
titleReactNode

A heading above the plans.

bodyReactNode

A line under the heading.

classNamestring

Examples

The same example in React and as web components; both render identically.

react/examples/pricing-table-block/Creator.tsx
import { PricingTableBlock } from '@/react/components/blocks/PricingTableBlock'
// The Creator plan, exactly as the ad states it.

const plans = [
  { title: 'Creator', price: '$10 for your first month, then $20/month', features: ['AI-powered research across brands, creators, ads, and campaigns', 'Unlimited board swipe files, alerts, and tracked brands', 'Unlimited team seats'], cta: 'Start Creator for 50% off', href: '/sign-up' },
]

export default function Creator() {
  return <PricingTableBlock title="One plan. Everything in it." plans={plans} />
}
elements/examples/pricing-table-block/Creator.html
<!-- The Creator plan, exactly as the ad states it. -->
<spyglass-pricing-table-block heading="One plan. Everything in it." plans='[{"title":"Creator","price":"$10 for your first month, then $20/month","features":["AI-powered research across brands, creators, ads, and campaigns","Unlimited board swipe files, alerts, and tracked brands","Unlimited team seats"],"cta":"Start Creator for 50% off","href":"/sign-up"}]'></spyglass-pricing-table-block>
react/examples/pricing-table-block/Plans.tsx
import { PricingTableBlock } from '@/react/components/blocks/PricingTableBlock'
// Acme's own three plans, side by side (placeholder plans: state yours exactly).

const plans = [
  { title: 'Acme Solo', price: '$12/month', features: ['One seat', 'Ten tracked brands'], cta: 'Start Solo' },
  { title: 'Acme Team', price: '$40/month', features: ['Five seats', 'Fifty tracked brands', 'Shared boards'], cta: 'Start Team' },
  { title: 'Acme Studio', price: '$90/month', features: ['Unlimited seats', 'Unlimited tracked brands', 'Shared boards', 'Alerts'], cta: 'Start Studio' },
]

export default function Plans() {
  return <PricingTableBlock title="Plans for every team." body="Every plan is billed monthly." plans={plans} />
}
elements/examples/pricing-table-block/Plans.html
<!-- Acme's own three plans, side by side (placeholder plans: state yours exactly). -->
<spyglass-pricing-table-block heading="Plans for every team." body="Every plan is billed monthly." plans='[{"title":"Acme Solo","price":"$12/month","features":["One seat","Ten tracked brands"],"cta":"Start Solo"},{"title":"Acme Team","price":"$40/month","features":["Five seats","Fifty tracked brands","Shared boards"],"cta":"Start Team"},{"title":"Acme Studio","price":"$90/month","features":["Unlimited seats","Unlimited tracked brands","Shared boards","Alerts"],"cta":"Start Studio"}]'></spyglass-pricing-table-block>

Source

react/components/blocks/PricingTableBlock.tsx
import type { ReactNode } from 'react'
import { PlanCard } from '@/react/components/site/PlanCard'
import { cn } from '@/react/lib/cn'

// Plans side by side: an optional centered Funnel Display heading and line over plan cards (the Creator plan card from
// the ad), each the same width and height, centered as a row; one plan sits alone in the middle. Up to three across,
// one on phones. Every price and feature is what the plan states.
export interface Plan {
  title: string
  price?: string
  features?: string[]
  cta?: string
  href?: string
}

export interface PricingTableBlockProps {
  plans: Plan[]
  /** A heading above the plans. */
  title?: ReactNode
  /** A line under the heading. */
  body?: ReactNode
  className?: string
}

export function PricingTableBlock({ plans, title, body, className }: PricingTableBlockProps) {
  return (
    <section data-ds="pricing-table-block" className={cn('flex flex-col gap-12 text-fg max-sm:gap-8', className)}>
      {(title || body) && (
        <div className="mx-auto grid max-w-3xl gap-4 text-center">
          {title && <h2 className="type-section">{title}</h2>}
          {body && <p className="type-body-lg text-fg-soft">{body}</p>}
        </div>
      )}
      <div className="flex flex-wrap items-stretch justify-center gap-4">
        {plans.map((p) => <PlanCard key={p.title} title={p.title} price={p.price} features={p.features} cta={p.cta} href={p.href} className="w-100 max-w-full" />)}
      </div>
    </section>
  )
}

export default PricingTableBlock
react/lib/cn.ts
// 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(' ')
}
elements/components/blocks/pricing-table-block.ts
import { html, nothing } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import '@/elements/components/site/plan-card'
import styles from 'virtual:tw'

// PricingTableBlock.tsx as <spyglass-pricing-table-block>: a centered `heading` (React's `title`) and `body` over plan
// cards (`plans`, a list of { title, price, features, cta, href }), the same width and height, centered as a row.
export interface Plan { title: string; price?: string; features?: string[]; cta?: string; href?: string }

/**
 * @summary Plans side by side.
 */
export class PricingTableBlock extends DsElement {
	static styles = [DsElement.styles, styles]
	protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="pricing-table-block"]'))
	static properties = { plans: { type: Array }, heading: {}, body: {} }
	plans: Plan[] = []
	/** A heading above the plans (React's `title`). */
	heading?: string
	/** A line under the heading. */
	body?: string

	render() {
		return html`<section data-ds="pricing-table-block" class="flex flex-col gap-12 text-fg max-sm:gap-8">${this.heading || this.body ? html`<div class="mx-auto grid max-w-3xl gap-4 text-center">${this.heading ? html`<h2 class="type-section">${this.heading}</h2>` : nothing}${this.body ? html`<p class="type-body-lg text-fg-soft">${this.body}</p>` : nothing}</div>` : nothing}<div class="flex flex-wrap items-stretch justify-center gap-4">${(this.plans ?? []).map((p) => html`<spyglass-plan-card heading=${p.title} .price=${p.price} .features=${p.features ?? []} .cta=${p.cta} .href=${p.href} class="w-100 max-w-full"></spyglass-plan-card>`)}</div></section>`
	}
}

define('pricing-table-block', PricingTableBlock)

Reference: Built from the library (plan card); Figma page 8: Ad, Creator plan offer (the Creator plan's copy is the ad's own).