Folio · Full page

A full page stacked from the Folio blocks: docs (sidebar + scrollspy), classic (top bar, split hero) or manifesto.

Blocks
foliolandingpagetemplate
shinUI
New in the libraryRead the note

shinUI is a free, growing kit of design tools for people who ship their own interfaces.

Backgrounds, components and blocks as plain React files. Copy them, install them, or pull them from the registry.

npx shadcn add shinui/folio-hero

Works with

React 19Tailwind v4ViteNext.js

What it is

A small library that keeps growing.

Three rules sit behind every piece, so blocks you mix still look like they came from the same hand.

  • Original, not remixed.

    Every block starts from a blank file and a single idea, then gets tuned in the studio until it holds up on a phone and in the dark.

  • Plain files you own.

    No runtime, no wrapper package. Each piece is one React file and a few tokens, so you can read it in a minute and change anything.

  • The boring parts, handled.

    Responsive layouts, light and dark palettes, reduced motion and keyboard focus are done before anything ships to the registry.

How it composes

One brief becomes a handful of blocks.

One brief in

“A calm landing page for a note-taking tool. Docs-like, lots of white, one accent color, nothing that glows.”

Four blocks out

  • 1Hero, editorial layout
  • 2Navbar with a scrollspy indexextends
  • 3Dithered art panelderived
  • →Footer with a writing listpairs with

In use

The point is pages people enjoy using, not pages that just pass a checklist.

First paint

Per block, on a mid-range phone

Cold

Warm

Hero142ms61ms
Footer38ms17ms

Installs

Per month, all items

12k+

Kept after a month

Blocks still in use, sampled projects

#1

Folio blocks were the set people changed least after installing.

How we measured

“Swapped our whole marketing page in an afternoon and it finally looks like us.”

Indie maker, on a weekend build

Where it runs

Use it wherever your project lives.

Each block is a plain file, so it works the same in a fresh Vite app, an old Next.js codebase or a weekend prototype.

See install options
  1. In your repo

    001
  2. In the registry

    002
  3. On your laptop

    003

Notes

Writing from the studio.

Read the journal
  1. 01How a block goes from blank file to registry
  2. 02Dithering without images: pixels from a little math
  3. 03Why every Folio label is set in mono

Usage

Drop the file into your project, along with the shared files listed below, and import it.

usage.tsx
import { FolioLanding } from "@/registry/blocks/folio-landing";

export function Example() {
  return <FolioLanding />;
}

Install prerequisites

Every component here relies only on Tailwind and the cn helper from shadcn/ui.

terminal
npm i clsx tailwind-merge

Also copy these files

Folio · Full page imports these files. Keep the same paths, or update the imports to match.

src/registry/blocks/folio-cards.tsx
'use client'

import { ArrowUpRight, DitherField, FolioBrackets, FolioRoot, FolioSectionHead } from '@/registry/blocks/folio-kit'
import { cn } from '@/lib/utils'

export interface FolioCardsProps {
  /** numbered: three framed cards with dithered art and 001 indexes. index: a numbered reading list. */
  variant?: 'numbered' | 'index'
  eyebrow?: string
  title?: string
  lede?: string
  linkLabel?: string
  animate?: boolean
  width?: 'narrow' | 'wide'
  className?: string
}

const CARDS = [
  { title: 'In your repo', shape: 'field' as const },
  { title: 'In the registry', shape: 'orb' as const },
  { title: 'On your laptop', shape: 'wave' as const },
]

const POSTS = [
  'How a block goes from blank file to registry',
  'Dithering without images: pixels from a little math',
  'Why every Folio label is set in mono',
]

/** Folio card section: numbered showcase cards or a numbered index list. */
export function FolioCards({
  variant = 'numbered',
  eyebrow = 'Where it runs',
  title = 'Use it wherever your project lives.',
  lede = 'Each block is a plain file, so it works the same in a fresh Vite app, an old Next.js codebase or a weekend prototype.',
  linkLabel = 'See install options',
  animate = true,
  width = 'narrow',
  className,
}: FolioCardsProps) {
  const wrap = cn('mx-auto px-6 py-12 md:py-14', width === 'narrow' ? 'max-w-[44rem]' : 'max-w-6xl md:px-10')

  return (
    <FolioRoot className={cn('w-full', className)}>
      <section className={wrap}>
        <FolioSectionHead eyebrow={eyebrow} title={title} lede={lede} />
        {linkLabel && (
          <a href="#" className="mt-5 inline-flex items-center gap-1 text-[13.5px] font-medium transition-colors hover:text-(--fo-blue)">
            {linkLabel} <ArrowUpRight />
          </a>
        )}

        {variant === 'numbered' ? (
          <ol className="mt-8 grid gap-3 sm:grid-cols-3">
            {CARDS.map((c, i) => (
              <li key={c.title} className="group border border-(--fo-line) p-3 transition-colors duration-200 hover:border-(--fo-blue)">
                <div className="flex items-start justify-between gap-2 px-1 pt-1">
                  <h3 className="text-[14.5px] leading-snug font-medium">{c.title}</h3>
                  <span className="font-mono text-[10px] text-(--fo-faint) group-hover:text-(--fo-blue)">{String(i + 1).padStart(3, '0')}</span>
                </div>
                <div className="relative mt-4 aspect-[4/3.4] p-2.5">
                  <FolioBrackets />
                  <div className="size-full opacity-80 transition-opacity duration-300 group-hover:opacity-100">
                    <DitherField shape={c.shape} cell={3} animate={animate} />
                  </div>
                </div>
              </li>
            ))}
          </ol>
        ) : (
          <ol className="mt-8 border-t border-(--fo-line)">
            {POSTS.map((p, i) => (
              <li key={p}>
                <a href="#" className="group flex items-baseline gap-5 border-b border-(--fo-line) py-4 transition-colors duration-200 hover:bg-(--fo-tint)">
                  <span className="w-6 pl-1 font-mono text-[11px] text-(--fo-faint) group-hover:text-(--fo-blue)">{String(i + 1).padStart(2, '0')}</span>
                  <span className="flex-1 text-[15px]">{p}</span>
                  <ArrowUpRight className="mr-2 text-(--fo-faint) transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5 group-hover:text-(--fo-blue)" />
                </a>
              </li>
            ))}
          </ol>
        )}
      </section>
    </FolioRoot>
  )
}
src/registry/blocks/folio-kit.tsx
'use client'

import { useEffect, useRef, useState, type ComponentProps, type ReactNode } from 'react'
import { cn } from '@/lib/utils'

/**
 * Folio Kit: the shared pieces behind the shinUI "Folio" blocks.
 *
 * Folio is an editorial, docs-like look: white paper, near-black ink stepped
 * down with opacity instead of grays, one cobalt accent, square corners,
 * hairline rules, tiny uppercase mono labels and dithered pixel art instead
 * of gradients or glows. Wrap a page (or a single block) in <FolioRoot> to
 * get the palette, then use the helpers below.
 *
 *   <FolioRoot>
 *     <FolioLabel>Section</FolioLabel>
 *     <FolioButton icon>Get started</FolioButton>
 *   </FolioRoot>
 */

/** Palette as CSS variables, light and dark. Everything Folio reads `--fo-*`. */
const FOLIO_VARS = cn(
  '[--fo-paper:#ffffff] [--fo-ink:#0b1015] [--fo-blue:#0562ef] [--fo-blue-press:#0446c9] [--fo-on-blue:#ffffff]',
  '[--fo-soft:rgb(11_16_21/0.66)] [--fo-faint:rgb(11_16_21/0.45)] [--fo-line:rgb(11_16_21/0.12)] [--fo-line-strong:rgb(11_16_21/0.22)]',
  '[--fo-tint:rgb(5_98_239/0.07)] [--fo-tint-strong:rgb(5_98_239/0.14)] [--fo-well:#f4f5f7] [--fo-ok:#10a86a]',
  'dark:[--fo-paper:#0a0d12] dark:[--fo-ink:#e9edf3] dark:[--fo-blue:#4a8bff] dark:[--fo-blue-press:#2f74f5] dark:[--fo-on-blue:#ffffff]',
  'dark:[--fo-soft:rgb(233_237_243/0.68)] dark:[--fo-faint:rgb(233_237_243/0.44)] dark:[--fo-line:rgb(233_237_243/0.12)] dark:[--fo-line-strong:rgb(233_237_243/0.24)]',
  'dark:[--fo-tint:rgb(74_139_255/0.1)] dark:[--fo-tint-strong:rgb(74_139_255/0.2)] dark:[--fo-well:#12161d] dark:[--fo-ok:#2fd18e]',
)

const KEYFRAMES = `
@keyframes fo-pulse{0%,100%{opacity:1}50%{opacity:.35}}
@keyframes fo-rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@keyframes fo-dash{to{stroke-dashoffset:-16}}
@media (prefers-reduced-motion:reduce){.fo-anim{animation:none!important}}
`

/** Sets the Folio palette, paper and ink. Renders the keyframes once per root. */
export function FolioRoot({ className, children, ...props }: ComponentProps<'div'>) {
  return (
    <div className={cn(FOLIO_VARS, 'bg-(--fo-paper) font-sans text-(--fo-ink) antialiased', className)} {...props}>
      <style>{KEYFRAMES}</style>
      {children}
    </div>
  )
}

/** Tiny uppercase mono label: eyebrows, table heads, captions. */
export function FolioLabel({ className, children, ...props }: ComponentProps<'p'>) {
  return (
    <p className={cn('font-mono text-[10.5px] tracking-[0.12em] text-(--fo-faint) uppercase', className)} {...props}>
      {children}
    </p>
  )
}

/** A full-width hairline. */
export function FolioRule({ dashed, className }: { dashed?: boolean; className?: string }) {
  return <hr className={cn('border-0 border-t border-(--fo-line)', dashed && 'border-dashed', className)} />
}

/** Four small L-shaped corners, like crop marks. Parent must be `relative`. */
export function FolioBrackets({ className, inset = 0 }: { className?: string; inset?: number }) {
  const base = 'pointer-events-none absolute size-2.5 border-(--fo-line-strong)'
  const s = { margin: inset }
  return (
    <span aria-hidden className={cn('pointer-events-none absolute inset-0', className)}>
      <span style={s} className={cn(base, 'top-0 left-0 border-t border-l')} />
      <span style={s} className={cn(base, 'top-0 right-0 border-t border-r')} />
      <span style={s} className={cn(base, 'bottom-0 left-0 border-b border-l')} />
      <span style={s} className={cn(base, 'right-0 bottom-0 border-r border-b')} />
    </span>
  )
}

/** The Folio mark: an original folded-corner page glyph. */
export function FolioMark({ className }: { className?: string }) {
  return (
    <svg viewBox="0 0 20 20" className={cn('size-5', className)} aria-hidden>
      <path d="M3 2h9l5 5v11H3z" fill="currentColor" />
      <path d="M12 2v5h5" fill="var(--fo-paper)" opacity={0.85} />
      <path d="M6 11h8M6 14h5" stroke="var(--fo-paper)" strokeWidth={1.4} />
    </svg>
  )
}

export function ArrowUpRight({ className }: { className?: string }) {
  return (
    <svg viewBox="0 0 12 12" className={cn('size-3', className)} fill="none" stroke="currentColor" strokeWidth={1.3} aria-hidden>
      <path d="M3.5 8.5l5-5M4.5 3.5h4v4" />
    </svg>
  )
}

export function SparkGlyph({ className }: { className?: string }) {
  return (
    <svg viewBox="0 0 16 16" className={cn('size-4', className)} fill="none" stroke="currentColor" strokeWidth={1.4} aria-hidden>
      <path d="M8 1.5v13M1.5 8h13M3.4 3.4l9.2 9.2M12.6 3.4l-9.2 9.2" />
    </svg>
  )
}

interface FolioButtonProps extends ComponentProps<'a'> {
  variant?: 'primary' | 'secondary' | 'ghost'
  /** Primary: shows a glyph in its own cell on the left. Others: a ↗ arrow. */
  icon?: boolean
  size?: 'md' | 'lg'
}

/** Square, mono, uppercase. Primary is solid cobalt; secondary is a tinted well with crop marks. */
export function FolioButton({ variant = 'primary', icon = true, size = 'md', className, children, ...props }: FolioButtonProps) {
  const h = size === 'lg' ? 'h-11' : 'h-9'
  const text = 'font-mono text-[11px] tracking-[0.1em] uppercase'
  const motion = 'transition-[background-color,color,translate] duration-200 ease-[cubic-bezier(.25,.1,.25,1)]'
  if (variant === 'primary') {
    return (
      <a
        href="#"
        className={cn('group inline-flex items-stretch bg-(--fo-blue) text-(--fo-on-blue) hover:bg-(--fo-blue-press) active:translate-y-px', h, text, motion, className)}
        {...props}
      >
        {icon && (
          <span className={cn('grid place-items-center border-r border-(--fo-paper)/25 bg-(--fo-blue)', size === 'lg' ? 'w-11' : 'w-9')}>
            <SparkGlyph className="transition-transform duration-500 group-hover:rotate-45" />
          </span>
        )}
        <span className="flex items-center px-4">{children}</span>
      </a>
    )
  }
  return (
    <a
      href="#"
      className={cn(
        'relative inline-flex items-center gap-2 px-4 active:translate-y-px',
        variant === 'secondary' ? 'bg-(--fo-tint) text-(--fo-ink) hover:bg-(--fo-tint-strong)' : 'text-(--fo-ink) hover:text-(--fo-blue)',
        h,
        text,
        motion,
        className,
      )}
      {...props}
    >
      {variant === 'secondary' && <FolioBrackets />}
      {children}
      {icon && <ArrowUpRight />}
    </a>
  )
}

/** Inline text link in cobalt with a tiny boxed plus, like a footnote. */
export function FolioLink({ children, className, ...props }: ComponentProps<'a'>) {
  return (
    <a href="#" className={cn('text-(--fo-blue) decoration-1 underline-offset-4 hover:underline', className)} {...props}>
      {children}
      <span aria-hidden className="ml-0.5 inline-grid size-2.5 translate-y-[-0.35em] place-items-center border border-current text-[7px] leading-none">
        +
      </span>
    </a>
  )
}

/** A hatched well with a mono command and a copy button. */
export function FolioCommand({ command, className }: { command: string; className?: string }) {
  const [copied, setCopied] = useState(false)
  return (
    <div
      className={cn('flex h-9 items-stretch bg-(--fo-well) font-mono text-[11px] tracking-[0.08em] uppercase', className)}
      style={{ backgroundImage: 'repeating-linear-gradient(-45deg, var(--fo-line) 0 1px, transparent 1px 7px)' }}
    >
      <span className="flex min-w-0 flex-1 items-center truncate px-3">{command}</span>
      <button
        type="button"
        onClick={() => {
          void navigator.clipboard?.writeText(command).catch(() => {})
          setCopied(true)
          setTimeout(() => setCopied(false), 1200)
        }}
        className="grid w-9 cursor-pointer place-items-center border-l border-(--fo-line) text-(--fo-soft) transition-colors hover:text-(--fo-ink)"
        aria-label="Copy"
      >
        {copied ? (
          <svg viewBox="0 0 16 16" className="size-3.5" fill="none" stroke="currentColor" strokeWidth={1.6} aria-hidden>
            <path d="M3 8.5l3 3 7-7" />
          </svg>
        ) : (
          <svg viewBox="0 0 16 16" className="size-3.5" fill="none" stroke="currentColor" strokeWidth={1.3} aria-hidden>
            <rect x="5" y="5" width="8.5" height="8.5" />
            <path d="M3 10.5V2.5h8" />
          </svg>
        )}
      </button>
    </div>
  )
}

/** Small announcement chip: pulsing dot, label, bordered link. */
export function FolioAnnouncement({ label, link, className }: { label: string; link: string; className?: string }) {
  return (
    <div className={cn('inline-flex items-stretch bg-(--fo-well) text-[11.5px]', className)}>
      <span className="flex items-center gap-2 px-3 py-1.5 text-(--fo-soft)">
        <span className="fo-anim size-1.5 rounded-full bg-(--fo-ok) [animation:fo-pulse_2.4s_ease-in-out_infinite]" />
        {label}
      </span>
      <a href="#" className="flex items-center gap-1.5 border border-(--fo-line-strong) bg-(--fo-paper) px-3 font-medium transition-colors hover:text-(--fo-blue)">
        {link}
        <ArrowUpRight />
      </a>
    </div>
  )
}

/** Deterministic 0..1 hash, so pixel art looks the same on every render. */
function hash(x: number, y: number, seed = 1) {
  const s = Math.sin(x * 127.1 + y * 311.7 + seed * 74.7) * 43758.5453
  return s - Math.floor(s)
}

/** A column chart drawn as stacked squares. One column can be highlighted. */
export function PixelBars({
  values,
  rows = 6,
  highlight = -1,
  className,
}: {
  values: number[]
  rows?: number
  highlight?: number
  className?: string
}) {
  return (
    <div className={cn('flex items-end gap-[3px]', className)} aria-hidden>
      {values.map((v, col) => {
        const filled = Math.max(1, Math.round(v * rows))
        return (
          <div key={col} className="flex flex-1 flex-col-reverse gap-[3px]">
            {Array.from({ length: rows }, (_, row) => (
              <span
                key={row}
                className={cn(
                  'aspect-square w-full',
                  row < filled ? (col === highlight ? 'bg-(--fo-blue)' : 'bg-(--fo-blue)/45') : 'bg-(--fo-line)',
                )}
              />
            ))}
          </div>
        )
      })}
    </div>
  )
}

const BAYER = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5].map((v) => (v + 0.5) / 16)

/**
 * A slowly drifting field of cobalt pixels, ordered-dithered (Bayer 4x4) from
 * layered sine noise. Canvas, ~12fps, pauses offscreen and for reduced motion.
 */
export function DitherField({
  cell = 4,
  animate = true,
  shape = 'field',
  inverse = false,
  className,
}: {
  /** Light pixels on a cobalt ground instead of cobalt on paper. */
  inverse?: boolean
  /** Pixel size in CSS px. */
  cell?: number
  animate?: boolean
  /** field: full-bleed texture. orb: a dithered sphere. wave: horizon bands. */
  shape?: 'field' | 'orb' | 'wave'
  className?: string
}) {
  const ref = useRef<HTMLCanvasElement>(null)

  useEffect(() => {
    const canvas = ref.current
    const ctx = canvas?.getContext('2d')
    if (!canvas || !ctx) return
    const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches
    let raf = 0
    let last = 0
    let visible = true
    let t = 0

    const draw = () => {
      const { clientWidth: w, clientHeight: h } = canvas
      const cols = Math.max(1, Math.ceil(w / cell))
      const rows = Math.max(1, Math.ceil(h / cell))
      if (canvas.width !== cols || canvas.height !== rows) {
        canvas.width = cols
        canvas.height = rows
      }
      const style = getComputedStyle(canvas)
      const blue = style.getPropertyValue('--fo-blue').trim() || '#0562ef'
      const paper = style.getPropertyValue('--fo-paper').trim() || '#ffffff'
      ctx.fillStyle = inverse ? blue : paper
      ctx.fillRect(0, 0, cols, rows)
      ctx.fillStyle = inverse ? 'rgba(255,255,255,0.82)' : blue
      for (let y = 0; y < rows; y++) {
        for (let x = 0; x < cols; x++) {
          const u = x / cols
          const v = y / rows
          let d: number
          if (shape === 'orb') {
            const dx = (u - 0.5) * (cols / rows)
            const dy = v - 0.5
            const r = Math.sqrt(dx * dx + dy * dy) / 0.42
            const light = 1 - Math.hypot(dx + 0.14, dy + 0.16) / 0.55
            d = r > 1 ? 0 : 0.25 + 0.75 * Math.max(0, light) + 0.08 * Math.sin(u * 22 + v * 9 - t * 1.4)
          } else if (shape === 'wave') {
            const crest = 0.55 + 0.12 * Math.sin(u * 6.5 + t * 0.8) + 0.05 * Math.sin(u * 17 - t * 1.3)
            d = v < crest ? 0 : 0.35 + 0.65 * Math.min(1, (v - crest) * 2.4) + 0.06 * Math.sin(u * 40 + v * 30 + t)
          } else {
            d =
              0.5 +
              0.28 * Math.sin(u * 5.1 + t * 0.6 + Math.sin(v * 4.2 - t * 0.4) * 1.6) +
              0.22 * Math.sin(v * 7.3 - u * 2.2 + t * 0.9) +
              0.05 * (hash(x, y) - 0.5)
          }
          if (d > BAYER[(y % 4) * 4 + (x % 4)]) ctx.fillRect(x, y, 1, 1)
        }
      }
    }

    const loop = (now: number) => {
      raf = requestAnimationFrame(loop)
      if (!visible || now - last < 80) return
      last = now
      t += 0.08
      draw()
    }

    draw()
    const io = new IntersectionObserver(([entry]) => (visible = entry.isIntersecting))
    io.observe(canvas)
    const ro = new ResizeObserver(() => draw())
    ro.observe(canvas)
    // Re-read colors when the theme class flips.
    const mo = new MutationObserver(() => draw())
    mo.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] })
    if (animate && !reduce) raf = requestAnimationFrame(loop)
    return () => {
      cancelAnimationFrame(raf)
      io.disconnect()
      ro.disconnect()
      mo.disconnect()
    }
  }, [cell, animate, shape, inverse])

  return <canvas ref={ref} aria-hidden className={cn('block size-full [image-rendering:pixelated]', className)} />
}

/** A dotted-grid panel for diagrams and figures, with an optional caption. */
export function FolioFigure({
  children,
  caption,
  className,
  dots = true,
}: {
  children: ReactNode
  caption?: ReactNode
  className?: string
  dots?: boolean
}) {
  return (
    <figure className={className}>
      <div
        className="relative border border-(--fo-line)"
        style={dots ? { backgroundImage: 'radial-gradient(var(--fo-line-strong) 1px, transparent 1px)', backgroundSize: '14px 14px' } : undefined}
      >
        {children}
      </div>
      {caption && <figcaption className="mt-3 max-w-md text-[12px] leading-relaxed text-(--fo-faint)">{caption}</figcaption>}
    </figure>
  )
}


/** Section opener: hairline, mono eyebrow, regular-weight title, muted lede. */
export function FolioSectionHead({
  eyebrow,
  title,
  lede,
  className,
}: {
  eyebrow?: string
  title: string
  lede?: string
  className?: string
}) {
  return (
    <div className={cn('border-t border-(--fo-line) pt-10', className)}>
      {eyebrow && <FolioLabel className="mb-4">{eyebrow}</FolioLabel>}
      <h2 className="max-w-xl text-[clamp(1.4rem,2.6vw,1.75rem)] leading-tight font-normal tracking-[-0.02em] text-balance">{title}</h2>
      {lede && <p className="mt-3 max-w-xl text-[15.5px] leading-relaxed text-(--fo-soft)">{lede}</p>}
    </div>
  )
}
src/registry/blocks/folio-features.tsx
'use client'

import { DitherField, FolioLabel, FolioLink, FolioRoot, FolioSectionHead } from '@/registry/blocks/folio-kit'
import { cn } from '@/lib/utils'

export interface FolioFeaturesProps {
  /** list: dithered tiles beside short paragraphs. table: a ruled comparison. pipeline: one input, many outputs, in mono. */
  variant?: 'list' | 'table' | 'pipeline'
  eyebrow?: string
  title?: string
  lede?: string
  /** Cobalt relation tags in the pipeline variant. */
  showTags?: boolean
  animate?: boolean
  /** Column width: narrow (docs column) or wide. */
  width?: 'narrow' | 'wide'
  className?: string
}

const FEATURES = [
  {
    title: 'Original, not remixed.',
    body: 'Every block starts from a blank file and a single idea, then gets tuned in the studio until it holds up on a phone and in the dark.',
    shape: 'orb' as const,
  },
  {
    title: 'Plain files you own.',
    body: 'No runtime, no wrapper package. Each piece is one React file and a few tokens, so you can read it in a minute and change anything.',
    shape: 'field' as const,
  },
  {
    title: 'The boring parts, handled.',
    body: 'Responsive layouts, light and dark palettes, reduced motion and keyboard focus are done before anything ships to the registry.',
    shape: 'wave' as const,
  },
]

const ROWS: [string, string, string][] = [
  ['Starting point', 'A screenshot and a guess', 'A tuned, original block'],
  ['Ownership', 'Copied snippets', 'One file in your repo'],
  ['Theming', 'Hard-coded colors', 'Tokens, light and dark'],
  ['Updates', 'Hunt through old tabs', 'Re-run one install command'],
]

const OUTPUTS: [string, string?][] = [
  ['Hero, editorial layout'],
  ['Navbar with a scrollspy index', 'extends'],
  ['Dithered art panel', 'derived'],
  ['Footer with a writing list', 'pairs with'],
]

/** Folio content section in three variants. */
export function FolioFeatures({
  variant = 'list',
  eyebrow = 'What it is',
  title = 'A small library that keeps growing.',
  lede = 'Three rules sit behind every piece, so blocks you mix still look like they came from the same hand.',
  showTags = true,
  animate = true,
  width = 'narrow',
  className,
}: FolioFeaturesProps) {
  const wrap = cn('mx-auto px-6 py-12 md:py-14', width === 'narrow' ? 'max-w-[44rem]' : 'max-w-6xl md:px-10')

  return (
    <FolioRoot className={cn('w-full', className)}>
      <section className={wrap}>
        <FolioSectionHead eyebrow={eyebrow} title={title} lede={lede} />

        {variant === 'list' && (
          <ul className={cn('mt-10 grid gap-8', width === 'wide' && 'md:grid-cols-3')}>
            {FEATURES.map((f) => (
              <li key={f.title} className={cn('group flex gap-5', width === 'wide' && 'md:flex-col')}>
                <div className="size-14 shrink-0 overflow-hidden transition-transform duration-300 group-hover:-translate-y-0.5">
                  <DitherField shape={f.shape} cell={2} animate={animate} inverse />
                </div>
                <div>
                  <h3 className="text-[15.5px] font-medium tracking-[-0.01em]">{f.title}</h3>
                  <p className="mt-1.5 text-[15px] leading-relaxed text-(--fo-soft)">{f.body}</p>
                </div>
              </li>
            ))}
          </ul>
        )}

        {variant === 'table' && (
          <div className="mt-10 overflow-x-auto">
            <table className="w-full min-w-[34rem] border-collapse text-left text-[13.5px]">
              <thead>
                <tr className="border-b border-dashed border-(--fo-line-strong)">
                  <th className="w-[24%] py-3 font-normal" />
                  {['Without', 'With shinUI'].map((h, i) => (
                    <th key={h} className="py-3 pr-4 font-normal">
                      <FolioLabel className={cn(i === 1 && 'text-(--fo-blue)')}>{h}</FolioLabel>
                    </th>
                  ))}
                </tr>
              </thead>
              <tbody>
                {ROWS.map(([label, a, b]) => (
                  <tr key={label} className="border-b border-(--fo-line) transition-colors hover:bg-(--fo-tint)">
                    <th className="py-3.5 pr-4 font-medium">{label}</th>
                    <td className="py-3.5 pr-4 text-(--fo-faint) line-through decoration-(--fo-line-strong)">{a}</td>
                    <td className="py-3.5 pr-4 text-(--fo-soft)">{b}</td>
                  </tr>
                ))}
              </tbody>
            </table>
            <p className="mt-6 text-[14.5px] leading-relaxed text-(--fo-soft)">
              Each block ships with its tokens, so it <FolioLink>inherits your theme</FolioLink> instead of fighting it.
            </p>
          </div>
        )}

        {variant === 'pipeline' && (
          <div className="mt-10 border border-(--fo-line) bg-(--fo-paper) p-5 font-mono text-[12px] leading-relaxed">
            <FolioLabel>One brief in</FolioLabel>
            <p className="mt-2 text-(--fo-soft)">
              “A calm landing page for a note-taking tool. Docs-like, lots of white, one accent color, nothing that glows.”
            </p>
            <FolioLabel className="mt-6">Four blocks out</FolioLabel>
            <ul className="mt-2">
              {OUTPUTS.map(([text, tag], i) => (
                <li
                  key={text}
                  className="flex items-center gap-3 border-b border-(--fo-line) py-2 last:border-b-0 [animation:fo-rise_.5s_ease-out_both] fo-anim"
                  style={{ animationDelay: `${i * 120}ms` }}
                >
                  <span className="w-4 text-(--fo-faint)">{i === OUTPUTS.length - 1 ? '→' : i + 1}</span>
                  <span>{text}</span>
                  {showTags && tag && <span className="text-(--fo-blue)">{tag}</span>}
                </li>
              ))}
            </ul>
          </div>
        )}
      </section>
    </FolioRoot>
  )
}
src/registry/blocks/folio-footer.tsx
'use client'

import { ArrowUpRight, DitherField, FolioButton, FolioCommand, FolioLabel, FolioMark, FolioRoot } from '@/registry/blocks/folio-kit'
import { cn } from '@/lib/utils'

/** Split a comma list prop into trimmed items. */
const list = (value: string | undefined) =>
  (value ?? '')
    .split(',')
    .map((s) => s.trim())
    .filter(Boolean)

export interface FolioFooterProps {
  /** cta: closing call to action, link columns and a dithered horizon. columns: links and status only. minimal: one quiet line. */
  variant?: 'cta' | 'columns' | 'minimal'
  brand?: string
  tagline?: string
  ctaTitle?: string
  ctaBody?: string
  ctaLabel?: string
  command?: string
  /** Shows a green "all systems normal" style status. Empty hides it. */
  status?: string
  /** Comma separated bottom links. */
  legal?: string
  animate?: boolean
  className?: string
}

const YEAR = new Date().getFullYear()

const COLUMNS: [string, string[]][] = [
  ['Library', ['Backgrounds', 'Components', 'Blocks', 'Folio set']],
  ['Studio', ['Favicon Studio', 'Registry', 'Changelog', 'Roadmap']],
  ['About', ['Journal', 'Notes', 'Contact', 'Docs ↗']],
]

function Columns() {
  return (
    <div className="grid grid-cols-2 gap-8 sm:grid-cols-3">
      {COLUMNS.map(([head, links]) => (
        <div key={head}>
          <FolioLabel>{head}</FolioLabel>
          <ul className="mt-4 flex flex-col gap-2.5 text-[13.5px]">
            {links.map((l) => (
              <li key={l}>
                <a href="#" className="inline-flex items-center gap-1 text-(--fo-soft) transition-colors duration-200 hover:text-(--fo-ink)">
                  {l.replace('↗', '').trim()}
                  {l.endsWith('↗') && <ArrowUpRight className="text-(--fo-faint)" />}
                </a>
              </li>
            ))}
          </ul>
        </div>
      ))}
    </div>
  )
}

function Status({ label }: { label: string }) {
  if (!label) return null
  return (
    <span className="inline-flex items-center gap-2 font-mono text-[10.5px] tracking-[0.1em] text-(--fo-soft) uppercase">
      <span className="fo-anim size-1.5 rounded-full bg-(--fo-ok) [animation:fo-pulse_2.4s_ease-in-out_infinite]" />
      {label}
    </span>
  )
}

/** Folio footer in three variants. */
export function FolioFooter({
  variant = 'cta',
  brand = 'shinUI',
  tagline = 'Free, original design tools for people who ship.',
  ctaTitle = 'Shipping a page this week?',
  ctaBody = 'Start from a block that already works on phones, in the dark and with a keyboard, then make it yours.',
  ctaLabel = 'Start building',
  command = 'npx shadcn add shinui/folio-landing',
  status = 'All systems normal',
  legal = 'Privacy, Terms, License',
  animate = true,
  className,
}: FolioFooterProps) {
  const bottom = (
    <div className="flex flex-col gap-3 border-t border-(--fo-line) py-6 text-[12px] text-(--fo-faint) sm:flex-row sm:items-center sm:justify-between">
      <span>
        © {YEAR} {brand}
      </span>
      <div className="flex flex-wrap items-center gap-5">
        <Status label={status} />
        {list(legal).map((l) => (
          <a key={l} href="#" className="transition-colors hover:text-(--fo-ink)">
            {l}
          </a>
        ))}
      </div>
    </div>
  )

  if (variant === 'minimal') {
    return (
      <FolioRoot className={cn('w-full', className)}>
        <footer className="mx-auto flex max-w-6xl flex-col gap-4 border-t border-(--fo-line) px-6 py-7 text-[12.5px] text-(--fo-faint) sm:flex-row sm:items-center sm:justify-between md:px-10">
          <a href="#" className="flex items-center gap-2 text-[14px] font-semibold text-(--fo-ink)">
            <FolioMark className="size-4" />
            {brand}
          </a>
          <span className="sm:mr-auto sm:ml-6">{tagline}</span>
          <div className="flex flex-wrap items-center gap-5">
            <Status label={status} />
            {list(legal).map((l) => (
              <a key={l} href="#" className="transition-colors hover:text-(--fo-ink)">
                {l}
              </a>
            ))}
          </div>
        </footer>
      </FolioRoot>
    )
  }

  return (
    <FolioRoot className={cn('w-full', className)}>
      <footer className="mx-auto max-w-6xl px-6 md:px-10">
        {variant === 'cta' && (
          <div className="grid gap-10 border-t border-(--fo-line) py-16 md:grid-cols-[1.2fr_1fr] md:items-end">
            <div>
              <h2 className="max-w-lg text-[clamp(1.6rem,3.4vw,2.4rem)] leading-tight font-normal tracking-[-0.03em] text-balance">{ctaTitle}</h2>
              <p className="mt-4 max-w-md text-[15px] leading-relaxed text-(--fo-soft)">{ctaBody}</p>
            </div>
            <div className="flex flex-col gap-2 md:items-end">
              <FolioButton size="lg">{ctaLabel}</FolioButton>
              {command && <FolioCommand command={command} className="w-full md:max-w-[23rem]" />}
            </div>
          </div>
        )}
        <div className="grid gap-10 border-t border-(--fo-line) py-12 md:grid-cols-[1fr_1.6fr]">
          <div className="flex flex-col items-start gap-3">
            <a href="#" className="flex items-center gap-2 text-[17px] font-semibold tracking-[-0.02em]">
              <FolioMark />
              {brand}
            </a>
            <p className="max-w-xs text-[13.5px] leading-relaxed text-(--fo-soft)">{tagline}</p>
          </div>
          <Columns />
        </div>
        {bottom}
      </footer>
      {variant === 'cta' && (
        <div className="h-24 w-full overflow-hidden sm:h-32">
          <DitherField shape="wave" cell={4} animate={animate} />
        </div>
      )}
    </FolioRoot>
  )
}
src/registry/blocks/folio-hero.tsx
'use client'

import type { ReactNode } from 'react'
import { DitherField, FolioAnnouncement, FolioButton, FolioCommand, FolioFigure, FolioLabel, FolioRoot } from '@/registry/blocks/folio-kit'
import { cn } from '@/lib/utils'

/** Split a comma list prop into trimmed items. */
const list = (value: string | undefined) =>
  (value ?? '')
    .split(',')
    .map((s) => s.trim())
    .filter(Boolean)

export interface FolioHeroProps {
  /** editorial: narrow column over a dithered panel. split: copy left, live diagram right. statement: a big muted sentence with inked emphasis, plus stats. */
  variant?: 'editorial' | 'split' | 'statement'
  announcement?: string
  announcementLink?: string
  /** Wrap words in *asterisks* to ink them in the statement variant. */
  title?: string
  description?: string
  primaryCta?: string
  secondaryCta?: string
  /** Hatched copy-to-clipboard command under the buttons. Empty hides it. */
  command?: string
  /** Comma separated "works with" items. Empty hides the row. */
  worksWith?: string
  /** Dithered art: drifting field, a sphere or horizon waves. */
  art?: 'field' | 'orb' | 'wave'
  animate?: boolean
  className?: string
}

/** "a *b* c" → muted text with inked emphasis. */
function Emphasis({ text }: { text: string }) {
  return (
    <>
      {text.split(/(\*[^*]+\*)/g).map((part, i) =>
        part.startsWith('*') ? (
          <span key={i} className="text-(--fo-ink)">
            {part.slice(1, -1)}
          </span>
        ) : (
          <span key={i}>{part}</span>
        ),
      )}
    </>
  )
}

const plain = (s: string) => s.replace(/\*/g, '')

function Actions({ primaryCta, secondaryCta, command }: Pick<FolioHeroProps, 'primaryCta' | 'secondaryCta' | 'command'>) {
  return (
    <div className="flex w-full max-w-sm flex-col gap-2 sm:max-w-none">
      <div className="flex flex-col gap-2 sm:flex-row">
        {primaryCta && <FolioButton size="lg">{primaryCta}</FolioButton>}
        {secondaryCta && (
          <FolioButton variant="secondary" size="lg" className="justify-center">
            {secondaryCta}
          </FolioButton>
        )}
      </div>
      {command && <FolioCommand command={command} className="sm:max-w-[23rem]" />}
    </div>
  )
}

function WorksWith({ items }: { items: string[] }) {
  if (items.length === 0) return null
  return (
    <div className="flex flex-wrap items-center gap-x-4 gap-y-2">
      <FolioLabel>Works with</FolioLabel>
      {items.map((item) => (
        <span key={item} className="border border-(--fo-line) px-2 py-0.5 font-mono text-[11px] text-(--fo-soft)">
          {item}
        </span>
      ))}
    </div>
  )
}

/** A boxed icon centered on (x, y) in the 400x275 diagram space, label underneath. */
function Node({ x, y, label, active, children }: { x: number; y: number; label: string; active?: boolean; children?: ReactNode }) {
  return (
    <div className="absolute -translate-x-1/2 -translate-y-1/2" style={{ left: `${(x / 400) * 100}%`, top: `${(y / 275) * 100}%` }}>
      <div
        className={cn(
          'grid size-9 place-items-center border sm:size-11',
          active ? 'border-(--fo-blue) bg-(--fo-blue) text-(--fo-on-blue)' : 'border-(--fo-line-strong) bg-(--fo-well) text-(--fo-soft)',
        )}
      >
        {children}
      </div>
      <span
        className={cn(
          'absolute top-full left-1/2 mt-1.5 -translate-x-1/2 font-mono text-[8.5px] tracking-[0.12em] whitespace-nowrap uppercase sm:text-[9.5px]',
          active ? 'text-(--fo-blue)' : 'text-(--fo-faint)',
        )}
      >
        {label}
      </span>
    </div>
  )
}

const ICONS = {
  doc: <path d="M5 3h6l3 3v9H5zM8 9h4M8 12h3" />,
  grid: <path d="M3.5 3.5h5v5h-5zM11.5 3.5h5v5h-5zM3.5 11.5h5v5h-5zM11.5 11.5h5v5h-5z" />,
  link: <path d="M8.5 11.5l3-3M7 9.5L5.5 11a2.5 2.5 0 003.5 3.5l1.5-1.5M13 10.5l1.5-1.5A2.5 2.5 0 0011 5.5L9.5 7" />,
  stack: <path d="M4 6l6-3 6 3-6 3zM4 10l6 3 6-3M4 14l6 3 6-3" />,
  out: <path d="M4 4h12v12H4zM7 8h6M7 11h4" />,
}

function Icon({ name }: { name: keyof typeof ICONS }) {
  return (
    <svg viewBox="0 0 20 20" className="size-[18px]" fill="none" stroke="currentColor" strokeWidth={1.3} aria-hidden>
      {ICONS[name]}
    </svg>
  )
}

/** Inputs feed a highlighted core, which writes to a registry and your app. Dashed links crawl. */
function Diagram({ animate }: { animate: boolean }) {
  const dash = cn('stroke-(--fo-line-strong) [stroke-dasharray:3_5]', animate && 'fo-anim [animation:fo-dash_1.2s_linear_infinite]')
  const pct = (x: number, y: number) => ({ left: `${(x / 400) * 100}%`, top: `${(y / 275) * 100}%` })
  return (
    <FolioFigure caption="Figure 1. Tokens, blocks and links flow into the kit, get composed, and land in the registry and your app as plain files.">
      <div className="relative aspect-[400/275] w-full">
        <svg viewBox="0 0 400 275" className="absolute inset-0 size-full" fill="none" aria-hidden>
          <path className={dash} vectorEffect="non-scaling-stroke" d="M92 70H125V205H92M92 137H155" />
          <path className={dash} vectorEffect="non-scaling-stroke" d="M245 137H290M290 95V190M290 95H308M290 190H308" />
        </svg>
        <span className="absolute -translate-x-1/2 font-mono text-[9px] tracking-[0.14em] text-(--fo-faint) uppercase" style={pct(70, 22)}>
          Sources
        </span>
        <div
          className="absolute -translate-x-1/2 -translate-y-1/2 border border-dashed border-(--fo-line-strong) bg-(--fo-paper)"
          style={{ ...pct(200, 137), width: '23%', height: '36%' }}
        >
          <span className="absolute -top-2 left-2 bg-(--fo-paper) px-1 font-mono text-[9px] tracking-[0.14em] uppercase">Kit</span>
        </div>
        <Node x={70} y={70} label="Tokens">
          <Icon name="doc" />
        </Node>
        <Node x={70} y={137} label="Blocks">
          <Icon name="grid" />
        </Node>
        <Node x={70} y={205} label="Links">
          <Icon name="link" />
        </Node>
        <Node x={200} y={130} label="Compose" active>
          <Icon name="stack" />
        </Node>
        <Node x={330} y={95} label="Registry">
          <Icon name="stack" />
        </Node>
        <Node x={330} y={190} label="Your app">
          <Icon name="out" />
        </Node>
      </div>
    </FolioFigure>
  )
}

/** Folio hero in three layouts. */
export function FolioHero({
  variant = 'editorial',
  announcement = 'New in the library',
  announcementLink = 'Read the note',
  title = 'shinUI is a free, growing kit of design tools for people who *ship* their own *interfaces*.',
  description = 'Backgrounds, components and blocks as plain React files. Copy them, install them, or pull them from the registry.',
  primaryCta = 'Start building',
  secondaryCta = 'Browse the library',
  command = 'npx shadcn add shinui/folio-hero',
  worksWith = 'React 19, Tailwind v4, Vite, Next.js',
  art = 'field',
  animate = true,
  className,
}: FolioHeroProps) {
  const head = 'text-[clamp(2rem,5vw,3.1rem)] leading-[1.08] font-normal tracking-[-0.03em] text-balance'

  if (variant === 'split') {
    return (
      <FolioRoot className={cn('w-full', className)}>
        <div className="mx-auto grid max-w-6xl items-center gap-12 px-6 py-16 md:grid-cols-[1fr_1.05fr] md:px-10 md:py-24">
          <div className="flex flex-col items-start gap-7">
            {announcement && <FolioAnnouncement label={announcement} link={announcementLink} />}
            <h1 className={head}>{plain(title)}</h1>
            <p className="max-w-lg text-[16px] leading-relaxed text-(--fo-soft)">{description}</p>
            <Actions primaryCta={primaryCta} secondaryCta={secondaryCta} command={command} />
            <WorksWith items={list(worksWith)} />
          </div>
          <Diagram animate={animate} />
        </div>
      </FolioRoot>
    )
  }

  if (variant === 'statement') {
    return (
      <FolioRoot className={cn('w-full', className)}>
        <div className="mx-auto max-w-6xl px-6 py-16 md:px-10 md:py-24">
          <FolioLabel>{announcement}</FolioLabel>
          <div className="mt-5 grid items-end gap-10 md:grid-cols-[1.4fr_1fr]">
            <h1 className="text-[clamp(2rem,4.6vw,3.4rem)] leading-[1.1] font-normal tracking-[-0.03em] text-balance text-(--fo-faint)">
              <Emphasis text={title} />
            </h1>
            <div className="relative aspect-square w-full max-w-72 justify-self-center md:justify-self-end">
              <DitherField shape="orb" cell={4} animate={animate} />
            </div>
          </div>
          <div className="mt-10 flex flex-col gap-6 border-t border-(--fo-line) pt-8 md:flex-row md:items-start md:justify-between">
            <p className="max-w-md text-[15px] leading-relaxed text-(--fo-soft)">{description}</p>
            <Actions primaryCta={primaryCta} secondaryCta={secondaryCta} />
          </div>
          <dl className="mt-10 grid grid-cols-1 border border-(--fo-line) sm:grid-cols-3">
            {[
              ['Blocks', '40', '+'],
              ['Install', '1', 'cmd'],
              ['Price', '$0', ''],
            ].map(([label, value, unit], i) => (
              <div key={label} className={cn('p-5', i > 0 && 'border-t border-(--fo-line) sm:border-t-0 sm:border-l')}>
                <FolioLabel>
                  <dt>{label}</dt>
                </FolioLabel>
                <dd className="mt-3 text-[34px] leading-none tracking-[-0.03em]">
                  {value}
                  <span className="ml-0.5 text-[15px] text-(--fo-soft)">{unit}</span>
                </dd>
              </div>
            ))}
          </dl>
        </div>
      </FolioRoot>
    )
  }

  return (
    <FolioRoot className={cn('w-full', className)}>
      <div className="mx-auto flex max-w-[44rem] flex-col items-start gap-7 px-6 py-16 md:py-20">
        {announcement && <FolioAnnouncement label={announcement} link={announcementLink} />}
        <h1 className={head}>{plain(title)}</h1>
        <p className="max-w-xl text-[16px] leading-relaxed text-(--fo-soft)">{description}</p>
        <Actions primaryCta={primaryCta} secondaryCta={secondaryCta} command={command} />
        <WorksWith items={list(worksWith)} />
        <div className="mt-6 aspect-[2.4/1] w-full overflow-hidden">
          <DitherField shape={art} cell={4} animate={animate} />
        </div>
      </div>
    </FolioRoot>
  )
}
src/registry/blocks/folio-metrics.tsx
'use client'

import type { ReactNode } from 'react'
import { ArrowUpRight, FolioLabel, FolioRoot, PixelBars, SparkGlyph } from '@/registry/blocks/folio-kit'
import { cn } from '@/lib/utils'

export interface FolioMetricsProps {
  /** bento: mixed stat cards with pixel charts. row: three big numbers and a pull quote. */
  variant?: 'bento' | 'row'
  eyebrow?: string
  /** Wrap words in *asterisks* to ink them; the rest stays muted. */
  title?: string
  quote?: string
  quoteSource?: string
  width?: 'narrow' | 'wide'
  className?: string
}

function Inked({ text }: { text: string }) {
  return (
    <>
      {text.split(/(\*[^*]+\*)/g).map((p, i) =>
        p.startsWith('*') ? (
          <span key={i} className="text-(--fo-ink)">
            {p.slice(1, -1)}
          </span>
        ) : (
          <span key={i}>{p}</span>
        ),
      )}
    </>
  )
}

function Card({ title, sub, children, className }: { title: string; sub: string; children: ReactNode; className?: string }) {
  return (
    <div className={cn('border border-(--fo-line) bg-(--fo-paper) p-5 transition-colors duration-200 hover:border-(--fo-line-strong)', className)}>
      <h3 className="text-[14px] font-medium">{title}</h3>
      <FolioLabel className="mt-1 text-[9.5px]">{sub}</FolioLabel>
      {children}
    </div>
  )
}

function Big({ value, unit }: { value: string; unit?: string }) {
  return (
    <p className="mt-5 text-[40px] leading-none tracking-[-0.04em]">
      {value}
      {unit && <span className="ml-0.5 align-baseline text-[16px] text-(--fo-soft)">{unit}</span>}
    </p>
  )
}

/** Deterministic 0..1 noise so the chart is stable between renders. */
const hash = (x: number, y: number) => {
  const s = Math.sin(x * 127.1 + y * 311.7) * 43758.5453
  return s - Math.floor(s)
}
const usage = Array.from({ length: 22 }, (_, i) => 0.25 + 0.75 * hash(i, 3))
const ranks = [0.22, 0.36, 0.46, 0.58, 0.63, 1, 0.5, 0.3]

function Quote({ quote, source }: { quote: string; source: string }) {
  return (
    <blockquote className="border-l-2 border-(--fo-blue) py-1 pl-5">
      <p className="text-[16px] leading-relaxed">
        <Inked text={quote} />
      </p>
      <footer className="mt-2 flex items-center gap-1 text-[12px] text-(--fo-faint)">
        {source}
        <ArrowUpRight />
      </footer>
    </blockquote>
  )
}

/** Folio stats section: bento cards or a row of numbers. */
export function FolioMetrics({
  variant = 'bento',
  eyebrow = 'In use',
  title = 'The point is pages people *enjoy* using, not pages that just *pass* a checklist.',
  quote = '“Swapped our whole marketing page in an afternoon and it finally *looks like us*.”',
  quoteSource = 'Indie maker, on a weekend build',
  width = 'narrow',
  className,
}: FolioMetricsProps) {
  const wrap = cn('mx-auto px-6 py-12 md:py-14', width === 'narrow' ? 'max-w-[44rem]' : 'max-w-6xl md:px-10')
  const head = (
    <div className="border-t border-(--fo-line) pt-10">
      <FolioLabel className="mb-4">{eyebrow}</FolioLabel>
      <h2 className="max-w-xl text-[clamp(1.4rem,2.8vw,1.9rem)] leading-snug font-normal tracking-[-0.02em] text-balance text-(--fo-faint)">
        <Inked text={title} />
      </h2>
    </div>
  )

  if (variant === 'row') {
    return (
      <FolioRoot className={cn('w-full', className)}>
        <section className={wrap}>
          {head}
          <dl className="mt-10 grid grid-cols-1 gap-px border border-(--fo-line) bg-(--fo-line) sm:grid-cols-3">
            {[
              ['Install time', 'per block, median', '38', 's'],
              ['Bundle added', 'typical block, gzip', '4.1', 'kb'],
              ['License', 'every item', 'MIT', ''],
            ].map(([t, s, v, u]) => (
              <div key={t} className="bg-(--fo-paper) p-5">
                <dt className="text-[14px] font-medium">{t}</dt>
                <FolioLabel className="mt-1 text-[9.5px]">{s}</FolioLabel>
                <dd>
                  <Big value={v} unit={u} />
                </dd>
              </div>
            ))}
          </dl>
          <div className="mt-10">
            <Quote quote={quote} source={quoteSource} />
          </div>
        </section>
      </FolioRoot>
    )
  }

  return (
    <FolioRoot className={cn('w-full', className)}>
      <section className={wrap}>
        {head}
        <div className={cn('mt-10 grid gap-3', 'sm:grid-cols-[1fr_1.3fr]')}>
          <div className="flex flex-col gap-3">
            <Card title="First paint" sub="Per block, on a mid-range phone">
              <table className="mt-4 w-full text-left text-[12px]">
                <thead>
                  <tr>
                    <th />
                    <th className="pb-1 font-normal">
                      <FolioLabel className="text-[9px]">Cold</FolioLabel>
                    </th>
                    <th className="pb-1 font-normal">
                      <FolioLabel className="text-[9px]">Warm</FolioLabel>
                    </th>
                  </tr>
                </thead>
                <tbody className="font-mono">
                  {[
                    ['Hero', '142', '61'],
                    ['Footer', '38', '17'],
                  ].map(([k, a, b]) => (
                    <tr key={k}>
                      <th className="py-1.5 text-[10px] font-normal tracking-[0.1em] uppercase">{k}</th>
                      {[a, b].map((n) => (
                        <td key={n} className="py-1.5 font-sans text-[22px] tracking-[-0.03em]">
                          {n}
                          <span className="ml-0.5 text-[11px] text-(--fo-faint) italic">ms</span>
                        </td>
                      ))}
                    </tr>
                  ))}
                </tbody>
              </table>
            </Card>
            <Card title="Installs" sub="Per month, all items">
              <Big value="12k" unit="+" />
              <PixelBars values={usage} rows={5} highlight={-1} className="mt-5" />
            </Card>
          </div>
          <Card title="Kept after a month" sub="Blocks still in use, sampled projects" className="flex flex-col">
            <Big value="#1" />
            <p className="mt-2 max-w-xs text-[13px] leading-relaxed text-(--fo-soft)">
              Folio blocks were the set people <span className="bg-(--fo-tint-strong) text-(--fo-ink)">changed least</span> after installing.
            </p>
            <div className="relative mt-auto flex h-40 items-end gap-2 pt-8">
              <div aria-hidden className="absolute inset-x-0 top-8 bottom-0 bg-[linear-gradient(var(--fo-line)_1px,transparent_1px)] bg-[size:100%_33.3%]" />
              {ranks.map((v, i) => (
                <div
                  key={i}
                  className={cn('relative flex-1 transition-[height] duration-500', i === 5 ? 'bg-(--fo-blue) text-(--fo-on-blue)' : 'bg-(--fo-well) ring-1 ring-(--fo-line)')}
                  style={{ height: `${v * 100}%` }}
                >
                  {i === 5 && <SparkGlyph className="absolute top-2 left-1/2 -translate-x-1/2" />}
                </div>
              ))}
            </div>
            <a href="#" className="mt-5 flex items-center gap-1 text-[12.5px] font-medium hover:text-(--fo-blue)">
              How we measured <ArrowUpRight />
            </a>
          </Card>
        </div>
        <div className="mt-10">
          <Quote quote={quote} source={quoteSource} />
        </div>
      </section>
    </FolioRoot>
  )
}
src/registry/blocks/folio-navbar.tsx
'use client'

import { useEffect, useState } from 'react'
import { ArrowUpRight, FolioButton, FolioLabel, FolioMark, FolioRoot } from '@/registry/blocks/folio-kit'
import { cn } from '@/lib/utils'

/** Split a comma list prop into trimmed items. */
const list = (value: string | undefined) =>
  (value ?? '')
    .split(',')
    .map((s) => s.trim())
    .filter(Boolean)

export interface FolioNavbarProps {
  /** sidebar: a sticky docs-style rail with an "on this page" index. topbar: a hairline bar. index: a centered mono bar with numbered links. */
  variant?: 'sidebar' | 'topbar' | 'index'
  brand?: string
  /** Comma separated page links. Add " ↗" to mark external ones. */
  links?: string
  /** The link shown as current. */
  active?: string
  /** Comma separated section ids/labels for the "on this page" index (sidebar). */
  sections?: string
  /** Two-option segmented switch under the brand (sidebar), e.g. "Design, Code". Empty hides it. */
  toggle?: string
  ctaLabel?: string
  /** Element to watch for scrollspy. Defaults to the window. */
  scrollRoot?: HTMLElement | null
  className?: string
}

const slug = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '')

function Brand({ brand }: { brand: string }) {
  return (
    <a href="#" className="flex items-center gap-2 text-[17px] font-semibold tracking-[-0.02em]">
      <FolioMark />
      {brand}
    </a>
  )
}

function NavText({ label }: { label: string }) {
  const external = label.endsWith('↗')
  return (
    <>
      {label.replace('↗', '').trim()}
      {external && <ArrowUpRight className="text-(--fo-faint)" />}
    </>
  )
}

function Segmented({ options }: { options: string[] }) {
  const [value, setValue] = useState(options[0])
  return (
    <div className="inline-flex border border-(--fo-line) bg-(--fo-well) p-0.5 text-[11px]">
      {options.map((o) => (
        <button
          key={o}
          type="button"
          onClick={() => setValue(o)}
          className={cn(
            'cursor-pointer px-3 py-1 transition-colors',
            value === o ? 'bg-(--fo-paper) font-medium text-(--fo-ink) shadow-[0_0_0_1px_var(--fo-line)]' : 'text-(--fo-faint) hover:text-(--fo-ink)',
          )}
        >
          {o}
        </button>
      ))}
    </div>
  )
}

/** Highlights the section closest to the top of the viewport. */
function useScrollSpy(ids: string[], root?: HTMLElement | null) {
  const [current, setCurrent] = useState(ids[0])
  const key = ids.join('|')
  useEffect(() => {
    const els = key
      .split('|')
      .map((id) => document.getElementById(id)).filter((el): el is HTMLElement => Boolean(el))
    if (els.length === 0) return
    const io = new IntersectionObserver(
      (entries) => {
        const hit = entries.filter((e) => e.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top)[0]
        if (hit) setCurrent(hit.target.id)
      },
      { root: root ?? null, rootMargin: '0px 0px -65% 0px' },
    )
    els.forEach((el) => io.observe(el))
    return () => io.disconnect()
  }, [key, root])
  return current
}

function MenuButton({ open, onClick }: { open: boolean; onClick: () => void }) {
  return (
    <button
      type="button"
      onClick={onClick}
      aria-expanded={open}
      className="flex cursor-pointer items-center gap-2 font-mono text-[11px] tracking-[0.12em] text-(--fo-soft) uppercase"
    >
      {open ? 'Close' : 'Menu'}
      <svg viewBox="0 0 16 16" className="size-3.5" fill="none" stroke="currentColor" strokeWidth={1.4} aria-hidden>
        {open ? <path d="M4 4l8 8M12 4l-8 8" /> : <path d="M2.5 6h11M2.5 10h11" />}
      </svg>
    </button>
  )
}

function MobileSheet({ items, active, cta }: { items: string[]; active: string; cta?: string }) {
  return (
    <div className="border-t border-(--fo-line) px-5 pt-2 pb-5 [animation:fo-rise_.2s_ease-out]">
      {items.map((label) => (
        <a key={label} href="#" className={cn('flex items-center gap-1.5 border-b border-(--fo-line) py-3 text-[15px]', label === active ? 'text-(--fo-ink)' : 'text-(--fo-soft)')}>
          <NavText label={label} />
        </a>
      ))}
      {cta && (
        <FolioButton className="mt-5 w-full justify-start" size="lg">
          {cta}
        </FolioButton>
      )}
    </div>
  )
}

/** The rail, without the page. Use inside a two-column layout (see Folio Landing). */
export function FolioSidebar({
  brand = 'shinUI',
  links = 'Home, Library, Journal, Changelog, Pricing, Docs ↗, Studio ↗',
  active = 'Home',
  sections = 'Overview, Principles, In use, Install, Notes',
  toggle = 'Design, Code',
  scrollRoot,
  className,
}: Omit<FolioNavbarProps, 'variant' | 'ctaLabel'>) {
  const items = list(links)
  const toc = list(sections)
  const ids = toc.map(slug)
  const current = useScrollSpy(ids, scrollRoot)
  const options = list(toggle).slice(0, 2)

  return (
    <nav className={cn('flex flex-col gap-8 px-8 py-10 text-[14px]', className)}>
      <div className="flex flex-col items-start gap-5">
        <Brand brand={brand} />
        {options.length === 2 && <Segmented options={options} />}
      </div>
      <ul className="flex flex-col gap-0.5">
        {items.map((label) => {
          const on = label === active
          return (
            <li key={label}>
              <a href="#" className={cn('relative flex items-center gap-1.5 py-1.5 transition-colors duration-200', on ? 'font-medium text-(--fo-ink)' : 'text-(--fo-soft) hover:text-(--fo-ink)')}>
                {on && <span className="absolute top-1/2 -left-3 size-1.5 -translate-y-1/2 bg-(--fo-blue)" />}
                <NavText label={label} />
              </a>
            </li>
          )
        })}
      </ul>
      {toc.length > 0 && (
        <div className="border-t border-dashed border-(--fo-line-strong) pt-6">
          <FolioLabel>On this page</FolioLabel>
          <ul className="mt-4 flex flex-col gap-0.5">
            {toc.map((label, i) => {
              const on = ids[i] === current
              return (
                <li key={label}>
                  <a
                    href={`#${ids[i]}`}
                    className={cn('flex items-center gap-4 py-1.5 transition-colors duration-200', on ? 'text-(--fo-ink)' : 'text-(--fo-faint) hover:text-(--fo-ink)')}
                  >
                    <span className={cn('h-px transition-all duration-300', on ? 'w-4 bg-(--fo-blue)' : 'w-2 bg-(--fo-line-strong)')} />
                    {label}
                  </a>
                </li>
              )
            })}
          </ul>
        </div>
      )}
    </nav>
  )
}

/**
 * Folio navigation in three variants. All collapse to a "Menu" bar with a
 * stacked sheet on small screens.
 */
export function FolioNavbar({
  variant = 'topbar',
  brand = 'shinUI',
  links = 'Home, Library, Journal, Changelog, Pricing, Docs ↗',
  active = 'Home',
  sections = 'Overview, Principles, In use, Install, Notes',
  toggle = 'Design, Code',
  ctaLabel = 'Open the studio',
  scrollRoot,
  className,
}: FolioNavbarProps) {
  const [open, setOpen] = useState(false)
  const items = list(links)

  const mobile = (
    <div className="md:hidden">
      <div className="flex h-14 items-center justify-between px-5">
        <Brand brand={brand} />
        <MenuButton open={open} onClick={() => setOpen((o) => !o)} />
      </div>
      {open && <MobileSheet items={items} active={active} cta={ctaLabel} />}
    </div>
  )

  if (variant === 'sidebar') {
    return (
      <FolioRoot className={cn('border-(--fo-line) md:h-full md:border-r', className)}>
        {mobile}
        <FolioSidebar className="hidden md:flex" brand={brand} links={links} active={active} sections={sections} toggle={toggle} scrollRoot={scrollRoot} />
      </FolioRoot>
    )
  }

  if (variant === 'index') {
    return (
      <FolioRoot className={cn('border-b border-(--fo-line)', className)}>
        {mobile}
        <div className="mx-auto hidden h-16 max-w-6xl items-center gap-8 px-8 md:flex">
          <Brand brand={brand} />
          <ul className="flex flex-1 items-center justify-center gap-1">
            {items.map((label, i) => {
              const on = label === active
              return (
                <li key={label}>
                  <a
                    href="#"
                    className={cn(
                      'flex items-baseline gap-1.5 px-3 py-2 text-[13px] transition-colors duration-200',
                      on ? 'bg-(--fo-tint) text-(--fo-ink)' : 'text-(--fo-soft) hover:text-(--fo-ink)',
                    )}
                  >
                    <span className={cn('font-mono text-[9.5px]', on ? 'text-(--fo-blue)' : 'text-(--fo-faint)')}>{String(i + 1).padStart(2, '0')}</span>
                    <NavText label={label} />
                  </a>
                </li>
              )
            })}
          </ul>
          {ctaLabel && <FolioButton variant="secondary">{ctaLabel}</FolioButton>}
        </div>
      </FolioRoot>
    )
  }

  return (
    <FolioRoot className={cn('sticky top-0 z-20 border-b border-(--fo-line) bg-(--fo-paper)/90 backdrop-blur', className)}>
      {mobile}
      <div className="mx-auto hidden h-16 max-w-6xl items-center gap-10 px-8 md:flex">
        <Brand brand={brand} />
        <ul className="flex flex-1 items-center gap-6 text-[13.5px]">
          {items.map((label) => {
            const on = label === active
            return (
              <li key={label}>
                <a href="#" className={cn('relative flex items-center gap-1 py-5 transition-colors duration-200', on ? 'text-(--fo-ink)' : 'text-(--fo-soft) hover:text-(--fo-ink)')}>
                  <NavText label={label} />
                  {on && <span className="absolute inset-x-0 -bottom-px h-px bg-(--fo-blue)" />}
                </a>
              </li>
            )
          })}
        </ul>
        {ctaLabel && <FolioButton>{ctaLabel}</FolioButton>}
      </div>
    </FolioRoot>
  )
}

More in Blocks