Content sheets
Five right-edge panels that differ by their inner content layout: menu, form, list, detail and split. Each is self-contained (no radix), sized, token-driven, and closes on backdrop click or Escape.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/sheet-contentDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motion lucide-reactCopy the source
components/ui/sheet-content.tsx"use client"
import * as React from "react"
import { AnimatePresence, motion, useReducedMotion } from "motion/react"
import {
BarChart3,
Calendar,
Check,
ChevronRight,
CreditCard,
Hash,
House,
LayoutGrid,
LifeBuoy,
MapPin,
Settings,
Tag,
User,
Users,
Zap,
X,
} from "lucide-react"
import { cn } from "@/lib/utils"
/* Content-themed sheet family: 5 right-edge panels. They all carry the same
self-contained shell (NO radix/portal), the same slide-in from the right and the
same token colors; the DIFFERENCE IS THE INNER CONTENT LAYOUT of the panel - each
export brings a real usage scenario to life with tokenized placeholder content
(bars/avatars/icons). The shell: a fixed inset-0 backdrop + a fixed panel pinned
to the right (z-50), sliding in from the right. Internal state (defaultOpen) or
controlled (open + onOpenChange). A backdrop click / Escape / the close button
closes it. The panel takes focus on open. The slide runs through
AnimatePresence; only a fade under reduced-motion. Color comes ONLY from tokens,
with transparency via color-mix. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
type Edge = "right" | "left" | "top" | "bottom"
const widthSize: Record<StyledSize, string> = {
sm: "w-72",
md: "w-80",
lg: "w-96",
xl: "w-[32rem]",
}
const heightSize: Record<StyledSize, string> = {
sm: "h-40",
md: "h-64",
lg: "h-80",
xl: "h-[32rem]",
}
const edgeAnchor: Record<Edge, string> = {
right: "inset-y-0 right-0",
left: "inset-y-0 left-0",
top: "inset-x-0 top-0",
bottom: "inset-x-0 bottom-0",
}
/* Essentials slideOffset: the panel slides outwards past its own edge. This family uses the right edge; the mechanism is kept so other edges derive from the same function. */
function slideOffset(edge: Edge) {
switch (edge) {
case "right":
return { x: "100%" }
case "left":
return { x: "-100%" }
case "top":
return { y: "-100%" }
case "bottom":
return { y: "100%" }
}
}
interface SheetProps {
size?: StyledSize
trigger?: React.ReactNode
title?: React.ReactNode
className?: string
open?: boolean
defaultOpen?: boolean
onOpenChange?: (o: boolean) => void
}
function useControllableOpen(
open: boolean | undefined,
defaultOpen: boolean | undefined,
onOpenChange: ((o: boolean) => void) | undefined
) {
const [uncontrolled, setUncontrolled] = React.useState(defaultOpen ?? false)
const isControlled = open !== undefined
const value = isControlled ? open : uncontrolled
const setValue = React.useCallback(
(next: boolean) => {
if (!isControlled) setUncontrolled(next)
onOpenChange?.(next)
},
[isControlled, onOpenChange]
)
return [value, setValue] as const
}
const iconBox =
"[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none"
/* Shared shell: trigger plus an AnimatePresence backdrop plus a right-edge panel. body draws the panel's inner content per variant; defaultTitle is the variant's title. */
function SheetContentShell({
props,
defaultTitle,
body,
}: {
props: SheetProps
defaultTitle: React.ReactNode
body: React.ReactNode
}) {
const { size = "md", trigger, title, className, open, defaultOpen, onOpenChange } = props
const edge: Edge = "right"
const reduce = useReducedMotion()
const [isOpen, setOpen] = useControllableOpen(open, defaultOpen, onOpenChange)
const panelRef = React.useRef<HTMLDivElement>(null)
React.useEffect(() => {
if (!isOpen) return
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") setOpen(false)
}
window.addEventListener("keydown", onKey)
return () => window.removeEventListener("keydown", onKey)
}, [isOpen, setOpen])
// Right and left edges are horizontal: full height, width from size. This family
// uses the right edge; heightSize keeps the mechanism intact for vertical edges.
const horizontal = edge === "right"
const sizeClass = horizontal ? cn("h-full", widthSize[size]) : cn("w-full", heightSize[size])
const enter = slideOffset(edge)
const heading = title ?? defaultTitle
return (
<div data-slot="styled-sheet" className="inline-flex">
{/* The ARIA state lives on the REAL trigger. There used to be a
span role="button" tabIndex={-1} wrapper, which produced TWO buttons
in the AX tree: one carrying the state (not focusable) and one that
took focus (stateless). A screen-reader user never heard "has dialog"
or "expanded" - measured with the CDP AX tree. */}
{React.isValidElement<React.ButtonHTMLAttributes<HTMLButtonElement>>(trigger) ? (
React.cloneElement(trigger, {
"aria-haspopup": "dialog",
"aria-expanded": isOpen,
onClick: (event: React.MouseEvent<HTMLButtonElement>) => {
trigger.props.onClick?.(event)
setOpen(true)
},
})
) : (
<button
type="button"
aria-haspopup="dialog"
aria-expanded={isOpen}
onClick={() => setOpen(true)}
className={cn(
"inline-flex h-9 shrink-0 select-none items-center justify-center gap-2 rounded-lg border border-border bg-secondary px-4 text-sm font-medium text-secondary-foreground outline-none whitespace-nowrap transition-[color,background-color] duration-(--motion-fast) ease-(--motion-ease) hover:bg-surface-3 focus-visible:ring-[3px] focus-visible:ring-ring/50",
iconBox
)}
>
{trigger ?? "Open"}
</button>
)}
<AnimatePresence>
{isOpen ? (
<div className="fixed inset-0 z-50">
<motion.div
data-slot="styled-sheet-backdrop"
onClick={() => setOpen(false)}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: reduce ? 0 : 0.2, ease: [0.4, 0, 0.2, 1] }}
className="absolute inset-0 bg-[color-mix(in_oklab,var(--color-foreground)_50%,transparent)]"
/>
<motion.div
ref={panelRef}
data-slot="styled-sheet-panel"
role="dialog"
aria-modal="true"
tabIndex={-1}
onAnimationComplete={() => panelRef.current?.focus()}
initial={reduce ? { opacity: 0 } : enter}
animate={reduce ? { opacity: 1 } : { x: 0, y: 0 }}
exit={reduce ? { opacity: 0 } : enter}
transition={
reduce ? { duration: 0 } : { type: "spring", stiffness: 320, damping: 34 }
}
className={cn(
"fixed flex flex-col border-l border-border bg-card text-card-foreground shadow-lg outline-none",
edgeAnchor[edge],
sizeClass,
className
)}
>
<div className="flex items-start justify-between gap-4 border-b border-border px-5 py-4">
<h2
data-slot="styled-sheet-title"
className="text-base font-semibold text-foreground"
>
{heading}
</h2>
<button
type="button"
onClick={() => setOpen(false)}
aria-label="Close"
className={cn(
"relative -m-1 inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color] duration-(--motion-fast) ease-(--motion-ease) hover:bg-surface-3 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 after:absolute after:-inset-2",
iconBox
)}
>
<X />
</button>
</div>
<div className="min-h-0 flex-1 overflow-auto p-5 text-sm text-muted-foreground">
{body}
</div>
</motion.div>
</div>
) : null}
</AnimatePresence>
</div>
)
}
/* A token placeholder bar: a token-colored bar instead of real text. */
function Bar({ className }: { className?: string }) {
return <span className={cn("block h-2 rounded-full bg-muted", className)} aria-hidden />
}
/* MenuSheet: dikey token nav menusu - her oge ikon + etiket cubugu; ilk oge
aktif (primary soft). */
export function MenuSheet(props: SheetProps) {
const items = [
{ Icon: House, w: "w-16", active: true },
{ Icon: LayoutGrid, w: "w-24", active: false },
{ Icon: Users, w: "w-20", active: false },
{ Icon: Calendar, w: "w-28", active: false },
{ Icon: BarChart3, w: "w-16", active: false },
{ Icon: Settings, w: "w-24", active: false },
{ Icon: LifeBuoy, w: "w-20", active: false },
]
return (
<SheetContentShell
props={props}
defaultTitle="Menu"
body={
<nav className="flex flex-col gap-1">
{items.map(({ Icon, w, active }, i) => (
<span
key={i}
className={cn(
"flex items-center gap-3 rounded-lg px-3 py-2.5",
iconBox,
active
? "bg-[color-mix(in_oklab,var(--color-primary)_12%,transparent)] text-primary"
: "text-foreground hover:bg-muted"
)}
>
<Icon />
<Bar className={cn(w, active && "bg-[color-mix(in_oklab,var(--color-primary)_45%,transparent)]")} />
</span>
))}
</nav>
}
/>
)
}
/* FormSheet: token label + input placeholder satirlari + submit. Girisler bos
bordered kutu (gorunum yeterli). */
export function FormSheet(props: SheetProps) {
const fields = [
{ label: "w-16", input: "h-9" },
{ label: "w-20", input: "h-9" },
{ label: "w-14", input: "h-9" },
{ label: "w-24", input: "h-20" },
]
return (
<SheetContentShell
props={props}
defaultTitle="Details"
body={
<form className="flex flex-col gap-5" onSubmit={(e) => e.preventDefault()}>
{fields.map((f, i) => (
<div key={i} className="flex flex-col gap-2">
<Bar className={cn("h-2", f.label)} />
<div className={cn("rounded-lg border border-border bg-background", f.input)} />
</div>
))}
<button
type="submit"
className={cn(
"mt-1 inline-flex h-9 w-full select-none items-center justify-center gap-2 rounded-lg bg-primary px-4 text-sm font-medium text-primary-foreground outline-none transition-[color,background-color] duration-(--motion-fast) ease-(--motion-ease) hover:bg-[color-mix(in_oklab,var(--color-primary)_88%,transparent)] focus-visible:ring-[3px] focus-visible:ring-ring/50",
iconBox
)}
>
<Check />
Submit
</button>
</form>
}
/>
)
}
/* ListSheet: token liste satirlari - avatar daire + iki metin cubugu + chevron. */
export function ListSheet(props: SheetProps) {
const rows = [
{ name: "w-24", sub: "w-32" },
{ name: "w-20", sub: "w-28" },
{ name: "w-28", sub: "w-24" },
{ name: "w-16", sub: "w-36" },
{ name: "w-24", sub: "w-20" },
{ name: "w-20", sub: "w-32" },
]
return (
<SheetContentShell
props={props}
defaultTitle="Members"
body={
<ul className="flex flex-col">
{rows.map((r, i) => (
<li
key={i}
className={cn(
"flex items-center gap-3 border-b border-border py-3 last:border-0",
iconBox
)}
>
<span className="flex size-9 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">
<User />
</span>
<div className="flex flex-1 flex-col gap-1.5">
<Bar className={cn("h-2", r.name)} />
<Bar className={cn("h-1.5 bg-[color-mix(in_oklab,var(--color-muted-foreground)_25%,transparent)]", r.sub)} />
</div>
<ChevronRight className="text-muted-foreground" />
</li>
))}
</ul>
}
/>
)
}
/* DetailSheet: a header block at the top (avatar plus name) with key/value detail fields below - each row an icon label plus a value bar. */
export function DetailSheet(props: SheetProps) {
const rows = [
{ Icon: Tag, value: "w-24" },
{ Icon: Calendar, value: "w-20" },
{ Icon: User, value: "w-28" },
{ Icon: MapPin, value: "w-16" },
{ Icon: Hash, value: "w-24" },
]
return (
<SheetContentShell
props={props}
defaultTitle="Overview"
body={
<div className="flex flex-col gap-5">
<div className="flex items-center gap-3">
<span className="flex size-12 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground [&_svg]:size-5">
<User />
</span>
<div className="flex flex-col gap-2">
<Bar className="h-2.5 w-32" />
<Bar className="h-2 w-20 bg-[color-mix(in_oklab,var(--color-muted-foreground)_25%,transparent)]" />
</div>
</div>
<div className="flex flex-col divide-y divide-border rounded-lg border border-border">
{rows.map(({ Icon, value }, i) => (
<div
key={i}
className={cn("flex items-center justify-between gap-4 px-3 py-2.5", iconBox)}
>
<span className="flex items-center gap-2 text-muted-foreground">
<Icon />
<Bar className="h-2 w-14" />
</span>
<Bar className={cn("h-2", value)} />
</div>
))}
</div>
</div>
}
/>
)
}
/* SplitSheet: a summary card in the top half (icon plus title plus mini statistics) and an action list in the bottom half - each row an icon plus label plus chevron. */
export function SplitSheet(props: SheetProps) {
const stats = ["w-10", "w-8", "w-12"]
const actions = [
{ Icon: Zap, w: "w-24" },
{ Icon: CreditCard, w: "w-28" },
{ Icon: Settings, w: "w-20" },
{ Icon: LifeBuoy, w: "w-24" },
]
return (
<SheetContentShell
props={props}
defaultTitle="Summary"
body={
<div className="flex h-full flex-col gap-4">
<div className="flex flex-col gap-3 rounded-xl border border-border bg-[color-mix(in_oklab,var(--color-muted)_50%,transparent)] p-4">
<div className={cn("flex items-center gap-3", iconBox)}>
<span className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-[color-mix(in_oklab,var(--color-primary)_14%,transparent)] text-primary">
<BarChart3 />
</span>
<Bar className="h-2.5 w-28" />
</div>
<Bar className="h-2 w-full" />
<Bar className="h-2 w-2/3 bg-[color-mix(in_oklab,var(--color-muted-foreground)_25%,transparent)]" />
<div className="mt-1 grid grid-cols-3 gap-3">
{stats.map((w, i) => (
<div key={i} className="flex flex-col gap-1.5 rounded-lg bg-background p-2.5">
<Bar className={cn("h-2.5", w)} />
<Bar className="h-1.5 w-full bg-[color-mix(in_oklab,var(--color-muted-foreground)_25%,transparent)]" />
</div>
))}
</div>
</div>
<Bar className="mt-1 h-2 w-16" />
<div className="flex flex-col gap-1">
{actions.map(({ Icon, w }, i) => (
<span
key={i}
className={cn(
"flex items-center gap-3 rounded-lg px-3 py-2.5 text-foreground hover:bg-muted",
iconBox
)}
>
<Icon />
<Bar className={cn("h-2 flex-1", w)} />
<ChevronRight className="text-muted-foreground" />
</span>
))}
</div>
</div>
}
/>
)
}Manual installs skip the @ai2/tokens theme, so add the token CSS from the theming guide or the tone colors will be missing.
Variations
5 takes on the same idea. Each is its own export, and every one accepts a size prop (sm, md, lg, xl) aligned to the base Button scale.
Menu
A vertical navigation menu with icons and item rows.
import { MenuSheet } from "@/components/ui/sheet-content"
<MenuSheet />Form
Stacked label and input rows with a submit button.
import { FormSheet } from "@/components/ui/sheet-content"
<FormSheet />List
Avatar and text rows for a members or results list.
import { ListSheet } from "@/components/ui/sheet-content"
<ListSheet />Detail
A header block above a key and value detail grid.
import { DetailSheet } from "@/components/ui/sheet-content"
<DetailSheet />Split
A summary card on top and an action list below.
import { SplitSheet } from "@/components/ui/sheet-content"
<SplitSheet />ai2 Content sheets: 5 styled variations on the token system
The ai2 Content sheets are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around right-edge side panels that differ by their inner content layout. They are free and MIT licensed, and every color comes from a semantic token, so they theme with the rest of ai2 in light and dark.
Motion runs on framer-motion: framer-motion slides the panel in from the right edge; the backdrop fades. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, the slide is skipped and the panel fades or shows instantly.
What is in the ai2 Content sheets?
5 exports in one file: Menu, Form, List, Detail and Split. Each renders a native button and takes a size prop (sm, md, lg, xl) aligned to the base Button. They are separate from the base Button on purpose: the base keeps its clean variant, tone and size axes, while the styled layer carries the effects.
You own the file. Copy the one category file and you have all 5 variations, with no runtime dependency on ai2 itself.
Why use it
- On-system by construction: Every color resolves to an ai2 semantic token, so the buttons follow your theme in light and dark with no extra work.
- Effect without the sprawl: The decorations live in a dedicated styled file, so the base Button keeps its clean, predictable API.
- Accessible and honest: Each renders a real button element, keeps a visible focus ring, and respects prefers-reduced-motion.
Features
- Token-driven color: No hardcoded hex or oklch; the look recolors with your theme tokens.
- framer-motion: framer-motion slides the panel in from the right edge; the backdrop fades.
- Reduced-motion aware: Under prefers-reduced-motion, the slide is skipped and the panel fades or shows instantly.
- Size aligned to the base: Every variation takes sm, md, lg and xl matching the base Button height scale, so styled and base buttons line up in a row.
Production tips
- Use it for emphasis, not everywhere: Styled buttons draw the eye. Reserve them for the one action you want people to take on a screen, and use the base Button for the rest.
- Keep labels as verbs: The decoration adds weight, so a clear action label keeps the button scannable.
- Pick one variation per surface: The variations share a family; using two different ones in the same view competes for attention.
Works with the rest of ai2
The Content sheets sit alongside the base Button and the rest of the @ai2 registry. They share the same token file, so a styled action next to a base button or a badge stays visually consistent in both modes.