Cards & content / Cards

Add-on Feature Cards with Toggle

One wide horizontal card with a light chart illustration (green toggle chip 'Spend Cap On', bars under a green threshold line) beside eyebrow, title, description and outlined arrow button; below, two half-width cards with pill/stack illustrations, price line, icon title and corner arrow.

Rebuilt from supabase.com/pricing in the Emerald Paper Precision style.

npx shadcn@latest add https://justyoink.it/r/emerald-paper-precision/blocks/feature-upsell-cards.json

Looks exactly like supabase.com: brings its fonts and colours, namespaced so your own theme stays untouched.

Usage

All copy is exposed as props with defaults (heading, featureTitle, domainTitle, recoveryTitle, etc.). The spend-cap chip is a working switch that animates its thumb and dims the threshold line; bars and layered illustrations fade in staggered at 80ms.

components/feature-upsell-cards.tsx
"use client";

import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react";
import { useState } from "react";

type Props = {
  heading?: string;
  subheading?: string;
  featureEyebrow?: string;
  featureTitle?: string;
  featureBody?: string;
  featureCta?: string;
  domainPrice?: string;
  domainTitle?: string;
  domainBody?: string;
  recoveryPrice?: string;
  recoveryTitle?: string;
  recoveryBody?: string;
};

const Arrow = ({ className = "h-3.5 w-3.5" }: { className?: string }) => (
  <svg viewBox="0 0 16 16" className={className} fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <path d="M4 12 12 4M5.5 4H12v6.5" />
  </svg>
);

export default function AddonFeatureCards({
  heading = "Tailor your workspace",
  subheading = "Move past your plan limits and shape the platform around your team",
  featureEyebrow = "Available on Team plan",
  featureTitle = "Budget Guard",
  featureBody = "Team plans ship with a usage ceiling turned on by default so bills stay predictable. When you need room to grow past the included allowance, flip the ceiling off and pay only for what you use.",
  featureCta = "Learn about Budget Guard",
  domainPrice = "Flat fee $8/month",
  domainTitle = "Branded Address",
  domainBody = "Serve your workspace from an address you own and give customers a fully branded experience.",
  recoveryPrice = "Starts from $90/month",
  recoveryTitle = "Instant Rewind",
  recoveryBody = "Restore your data to any chosen moment in history, down to the exact second.",
}: Props) {
  const [on, setOn] = useState(true);
  const bars = [40, 88, 98, 98, 98];
  return (
    <section className="bg-canvas px-4 py-20 text-ink">
      <div className="mx-auto max-w-[1152px]">
        <Reveal className="text-center">
          <h2 className="font-display text-h2 text-ink">{heading}</h2>
          <p className="mt-3 text-lead text-ink-soft">{subheading}</p>
        </Reveal>

        <div className="mt-14 grid gap-4">
          <article className="grid gap-6 rounded-lg border border-hairline bg-surface p-4 md:grid-cols-[448px_1fr]">
            <div className="relative h-[265px] overflow-hidden rounded-lg border border-hairline bg-surface-muted/40">
              <button
                type="button"
                role="switch"
                aria-checked={on}
                onClick={() => setOn(!on)}
                className="absolute left-2 top-2 z-10 flex items-center gap-1.5 rounded-pill border border-hairline bg-surface py-1 pl-1 pr-2.5 text-label shadow-card-hairline focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand"
              >
                <span className={`relative h-5 w-9 rounded-pill transition-colors duration-base-transition ${on ? "bg-brand" : "bg-hairline-strong"}`}>
                  <span className={`absolute top-0.5 h-4 w-4 rounded-full bg-surface transition-transform duration-base-transition ${on ? "translate-x-[18px]" : "translate-x-0.5"}`} />
                </span>
                Spend Cap {on ? "On" : "Off"}
              </button>
              <div className={`absolute inset-x-0 top-[132px] h-px bg-brand-bright transition-opacity duration-base-transition ${on ? "opacity-100" : "opacity-20"}`} />
              <Stagger step={80} from="fade" className="absolute inset-x-0 bottom-0 flex h-[132px] items-end justify-around px-12">
                {bars.map((h, i) => (
                  <span key={i} className="block w-[18px] rounded-md border border-hairline-strong bg-surface-muted" style={{ height: `${h}%`, marginBottom: 32 - (i === 0 ? 0 : 0) }} />
                ))}
              </Stagger>
            </div>
            <div className="flex flex-col justify-center pr-8">
              <p className="text-label text-ink-muted">{featureEyebrow}</p>
              <h3 className="mt-3 font-display text-h3 text-ink">{featureTitle}</h3>
              <p className="mt-3 max-w-xl text-label text-ink-muted">{featureBody}</p>
              <a href="#" className="mt-8 inline-flex w-fit items-center gap-2 rounded-md border border-hairline bg-surface px-2.5 py-1.5 text-caption font-medium text-ink transition-colors duration-hover-color ease-hover-color hover:border-hairline-strong hover:text-brand focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand">
                {featureCta}
                <Arrow className="h-3 w-3" />
              </a>
            </div>
          </article>

          <div className="grid gap-4 md:grid-cols-2">
            <article className="relative flex h-[133px] overflow-hidden rounded-lg border border-hairline bg-surface">
              <Stagger step={80} from="fade" className="flex w-[216px] shrink-0 flex-col justify-center gap-2 overflow-hidden pl-0">
                {["acme-team.example.app", "https://yourdomain.com"].map((t) => (
                  <span key={t} className="ml-[-24px] block w-[204px] truncate rounded-pill border border-hairline-strong bg-surface py-2.5 pl-8 pr-4 font-sans text-body text-ink-muted">{t}</span>
                ))}
              </Stagger>
              <div className="relative flex-1 py-5 pl-0 pr-5">
                <p className="text-label text-ink-muted">{domainPrice}</p>
                <h3 className="mt-2 flex items-center gap-1.5 text-body font-medium text-ink">
                  <svg viewBox="0 0 16 16" className="h-3.5 w-3.5" fill="none" stroke="currentColor" strokeWidth="1.2" aria-hidden="true"><circle cx="8" cy="8" r="6.5" /><path d="M1.5 8h13M8 1.5c2.5 3 2.5 10 0 13M8 1.5c-2.5 3-2.5 10 0 13" /></svg>
                  {domainTitle}
                </h3>
                <p className="mt-2 text-label text-ink-muted">{domainBody}</p>
                <Arrow className="absolute right-5 top-5 h-4 w-4 text-ink" />
              </div>
            </article>

            <article className="relative flex h-[133px] overflow-hidden rounded-lg border border-hairline bg-surface">
              <Stagger step={80} from="fade" className="relative w-[216px] shrink-0">
                <span className="absolute left-[50px] top-[22px] h-3 w-[102px] rounded-t-md border border-hairline-strong bg-surface" />
                <span className="absolute left-[42px] top-[31px] h-5 w-[120px] rounded-t-md border border-hairline-strong bg-surface-muted" />
                <span className="absolute left-[34px] top-[44px] h-6 w-[136px] rounded-t-md border border-hairline-strong bg-surface" />
                <span className="absolute left-[26px] top-[64px] h-20 w-[150px] rounded-t-md border border-hairline-strong bg-surface" />
              </Stagger>
              <div className="relative flex-1 py-5 pr-5">
                <p className="text-label text-ink-muted">{recoveryPrice}</p>
                <h3 className="mt-2 flex items-center gap-1.5 text-body font-medium text-ink">
                  <svg viewBox="0 0 16 16" className="h-3.5 w-3.5" fill="none" stroke="currentColor" strokeWidth="1.2" aria-hidden="true"><circle cx="8" cy="8" r="6.5" /><path d="M8 4.5V8l2.5 1.5" /></svg>
                  {recoveryTitle}
                </h3>
                <p className="mt-2 text-label text-ink-muted">{recoveryBody}</p>
                <Arrow className="absolute right-5 top-5 h-4 w-4 text-ink" />
              </div>
            </article>
          </div>
        </div>
      </div>
    </section>
  );
}

// ---- Yoink motion (inlined, no dependencies): Reveal, Stagger ----

const YK_EASE = "cubic-bezier(0.16, 1, 0.3, 1)";

const useYkLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;

function ykReducedMotion(): boolean {
  return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
}

// "idle": untouched (visible) · "hidden": waiting below the fold · "shown": play the entrance.
// Content is only hidden once we know we can show it again (IntersectionObserver exists, motion allowed,
// and there is a box to watch), and a safety net reveals anything on screen that is still hidden.
type YkRevealState = "idle" | "hidden" | "shown";

function useYkReveal(ref: RefObject<Element | null>, once = true): YkRevealState {
  const [state, setState] = useState<YkRevealState>("idle");
  useYkLayoutEffect(() => {
    const el = ref.current;
    if (!el || ykReducedMotion() || typeof IntersectionObserver === "undefined") return;
    // watch the element's own box, or its children when it has none (display: contents)
    const boxes = () => (getComputedStyle(el).display === "contents" ? Array.from(el.children) : [el]);
    const onScreen = (t: Element) => {
      const r = t.getBoundingClientRect();
      return (r.width > 0 || r.height > 0) && r.bottom > 0 && r.right > 0 && r.top < window.innerHeight && r.left < window.innerWidth;
    };
    if (!boxes().some((t) => t.getBoundingClientRect().width > 0 || t.getBoundingClientRect().height > 0)) return; // e.g. hidden at mount: leave it visible
    let shown = false;
    const show = (v: boolean) => {
      if (v !== shown) (shown = v), setState(v ? "shown" : "hidden");
    };
    setState("hidden");
    const inView = new Set<Element>();
    const io = new IntersectionObserver((entries) => {
      for (const e of entries) {
        if (e.isIntersecting) inView.add(e.target);
        else inView.delete(e.target);
      }
      if (inView.size) {
        show(true);
        if (once) io.disconnect();
      } else if (!once) show(false);
    });
    const watched = new Set<Element>();
    const watch = () => boxes().forEach((t) => !watched.has(t) && (watched.add(t), io.observe(t)));
    watch();
    // safety net: styles that land after mount (display: contents) get watched too, and nothing
    // stays hidden for more than a moment while it is actually on screen
    const start = Date.now();
    const net = setInterval(() => {
      if (shown) return once && clearInterval(net);
      watch();
      if (Date.now() - start > 2400 && boxes().some(onScreen)) show(true);
    }, 600);
    return () => {
      io.disconnect();
      clearInterval(net);
    };
  }, [once]);
  return state;
}

type YkRevealFrom = "up" | "down" | "left" | "right" | "scale" | "blur" | "none";

/** Fades content in as it scrolls into view. */
function Reveal({
  children,
  from = "up",
  delay = 0,
  duration = 700,
  distance = 24,
  once = true,
  as = "div",
  className,
  style,
}: {
  children?: ReactNode;
  from?: YkRevealFrom;
  delay?: number;
  duration?: number;
  distance?: number;
  once?: boolean;
  as?: ElementType;
  className?: string;
  style?: CSSProperties;
}) {
  const Tag = as;
  const ref = useRef<HTMLElement>(null);
  const state = useYkReveal(ref, once);
  const hidden = state === "hidden";
  const offset = {
    up: `translate3d(0, ${distance}px, 0)`,
    down: `translate3d(0, ${-distance}px, 0)`,
    left: `translate3d(${-distance}px, 0, 0)`,
    right: `translate3d(${distance}px, 0, 0)`,
    scale: "scale(0.94)",
    blur: `translate3d(0, ${distance / 2}px, 0)`,
    none: "none",
  }[from];
  const t = `${duration}ms ${YK_EASE} ${delay}ms`;
  return (
    <Tag
      ref={ref}
      className={className}
      style={{
        ...style,
        ...(hidden && { opacity: 0, transform: offset, filter: from === "blur" ? "blur(12px)" : undefined }),
        ...(state === "shown" && { transition: `opacity ${t}, transform ${t}, filter ${t}` }),
      }}
    >
      {children}
    </Tag>
  );
}

/** Reveals each direct child one after another when the group scrolls into view. */
function Stagger({
  children,
  step = 90,
  from = "up",
  distance = 20,
  duration = 650,
  delay = 0,
  once = true,
  as = "div",
  className,
  style,
}: {
  children?: ReactNode;
  step?: number;
  from?: "up" | "down" | "left" | "right" | "scale" | "fade";
  distance?: number;
  duration?: number;
  delay?: number;
  once?: boolean;
  as?: ElementType;
  className?: string;
  style?: CSSProperties;
}) {
  const Tag = as;
  const ref = useRef<HTMLElement>(null);
  const state = useYkReveal(ref, once);
  useYkLayoutEffect(() => {
    const items = Array.from(ref.current?.children ?? []) as HTMLElement[];
    if (state === "idle") return;
    const offset = {
      up: `translate3d(0, ${distance}px, 0)`,
      down: `translate3d(0, ${-distance}px, 0)`,
      left: `translate3d(${-distance}px, 0, 0)`,
      right: `translate3d(${distance}px, 0, 0)`,
      scale: "scale(0.92)",
      fade: "none",
    }[from];
    if (state === "hidden") {
      for (const el of items) Object.assign(el.style, { transition: "none", opacity: "0", transform: offset });
      return;
    }
    items.forEach((el, i) => {
      const t = `${duration}ms ${YK_EASE} ${delay + i * step}ms`;
      Object.assign(el.style, { transition: `opacity ${t}, transform ${t}`, opacity: "", transform: "" });
    });
    // hand the children their own transitions back once everything has landed
    const done = setTimeout(() => items.forEach((el) => (el.style.transition = "")), delay + items.length * step + duration + 50);
    return () => clearTimeout(done);
  }, [state]);
  return (
    <Tag ref={ref} className={className} style={style}>
      {children}
    </Tag>
  );
}

Quality checks

Automated, in a real browser · 4d ago
—

More from Emerald Paper Precision

The whole style →

Hairline Site Header

Headers & nav bars

Framework Icon Tab Code Panel

Code blocks

Gradient Customer Story Strip

Testimonials

Compute Pricing Calculator

Forms

Two-Tone Split Hero

Heroes

Hairline Bento Product Grid

Feature sections