Frame
A box with registration marks on its four corners, for anything from a card to a whole page section. An optional header holds a back button, any title content and a three-dot menu, and can fold the content into itself.
- @ui-sdk/react
- lucide-react
Example
A whole page section. Press the title to fold it into the header; Back and the menu work without folding it.
Last action: Nothing yet
"use client"
import { useState } from "react"
import { Archive, Copy, FileSpreadsheet, FileText, Pencil, Share2, Trash2 } from "lucide-react"
import {
Frame,
FrameBack,
FrameContent,
FrameHeader,
FrameMenu,
FrameMenuItem,
FrameMenuSeparator,
FrameSubmenu,
FrameSubmenuContent,
FrameSubmenuTrigger,
FrameTitle,
} from "@/components/ui/frame"
export function FrameBasicDemo() {
const [last, setLast] = useState("Nothing yet")
return (
<div className="flex w-full flex-col gap-4">
<Frame size="lg" collapsible>
<FrameHeader>
<FrameBack onClick={() => setLast("Back")} />
<FrameTitle>Store — 01 / Orders</FrameTitle>
<FrameMenu label="Section actions" onAction={(value) => setLast(value)}>
<FrameMenuItem value="Edit" icon={<Pencil />}>Edit</FrameMenuItem>
<FrameMenuItem value="Duplicate" icon={<Copy />}>Duplicate</FrameMenuItem>
<FrameSubmenu>
<FrameSubmenuTrigger icon={<Share2 />}>Export</FrameSubmenuTrigger>
<FrameSubmenuContent>
<FrameMenuItem value="CSV" icon={<FileSpreadsheet />}>CSV</FrameMenuItem>
<FrameMenuItem value="PDF" icon={<FileText />}>PDF</FrameMenuItem>
</FrameSubmenuContent>
</FrameSubmenu>
<FrameMenuSeparator />
<FrameMenuItem value="Archive" icon={<Archive />}>Archive</FrameMenuItem>
<FrameMenuItem value="Delete" icon={<Trash2 />} destructive>Delete</FrameMenuItem>
</FrameMenu>
</FrameHeader>
<FrameContent>
<p className="text-sm text-muted-foreground">
A whole page section. Press the title to fold it into the header; Back and the menu work without folding it.
</p>
</FrameContent>
</Frame>
<p className="font-mono text-xs text-muted-foreground">Last action: {last}</p>
</div>
)
}Press the title, or focus it and press Enter or Space, to fold the content. Back and the menu sit beside the title, so pressing them never folds it.
Header
FrameHeader is optional and takes any children. Put FrameBack first for a back button, FrameTitle in the middle (it fills the free space and truncates long text), and FrameMenu last for a three-dot menu of FrameMenuItem, FrameMenuSeparator and FrameSubmenu. height sets its minimum height and defaults to the frame's size. The title is Text's overline; size on FrameTitle takes any Text size (default "xs").
Collapsing
Add collapsible to let the user fold the content into the header by pressing the title. It starts open; use defaultOpen={false} to start closed, or open with onOpenChange to control it. Without collapsible, the title is plain text and the content always shows.
- Items
- 3 items
- Total
- $84.00
import { Frame, FrameContent, FrameHeader, FrameMenu, FrameMenuItem, FrameTitle } from "@/components/ui/frame"
const orders = [
{ id: "4189", items: "3 items", total: "$84.00" },
{ id: "4190", items: "1 item", total: "$18.00" },
{ id: "4191", items: "5 items", total: "$212.50" },
]
export function FrameCardsDemo() {
return (
<div className="grid w-full gap-4 sm:grid-cols-3">
{orders.map((order, index) => (
<Frame key={order.id} size="sm" collapsible defaultOpen={index === 0}>
<FrameHeader>
<FrameTitle>Order {order.id}</FrameTitle>
<FrameMenu label={`Order ${order.id} actions`}>
<FrameMenuItem value="open">Open</FrameMenuItem>
<FrameMenuItem value="refund">Refund</FrameMenuItem>
</FrameMenu>
</FrameHeader>
<FrameContent>
<dl className="grid grid-cols-2 gap-1 text-sm">
<dt className="text-muted-foreground">Items</dt>
<dd className="text-end">{order.items}</dd>
<dt className="text-muted-foreground">Total</dt>
<dd className="text-end font-mono">{order.total}</dd>
</dl>
</FrameContent>
</Frame>
))}
</div>
)
}Sizes
size="sm" fits cards and list items, "lg" page sections: it scales the corner marks, the content padding and the header height. A frame without a header is just the box.
No header: just the box and its corners.
Without collapsible, the title is plain text.
import { Frame, FrameContent, FrameHeader, FrameTitle } from "@/components/ui/frame"
export function FramePlainDemo() {
return (
<div className="grid w-full gap-4 sm:grid-cols-2">
<Frame size="sm">
<FrameContent>
<p className="text-sm">No header: just the box and its corners.</p>
</FrameContent>
</Frame>
<Frame size="sm">
<FrameHeader height="lg">
<FrameTitle size="sm">Taller header, larger title</FrameTitle>
</FrameHeader>
<FrameContent>
<p className="text-sm">Without collapsible, the title is plain text.</p>
</FrameContent>
</Frame>
</div>
)
}Colors
color takes any intent color of the theme. "primary", the default, is the plain card with primary corners; every other color ("warning", "error", "info", "success", "secondary", "muted") colors the corners and lays a light wash of itself over the background and borders. Use "warning" for things that need attention and "error" for failures or destructive sections.
The default: card background, primary corners.
3 products have fewer than 5 units left.
Order 4190 was declined by the card issuer.
import { Frame, FrameContent, FrameHeader, FrameMenu, FrameMenuItem, FrameTitle } from "@/components/ui/frame"
export function FrameColorsDemo() {
return (
<div className="grid w-full gap-4 sm:grid-cols-3">
<Frame size="sm">
<FrameHeader>
<FrameTitle>Primary</FrameTitle>
</FrameHeader>
<FrameContent>
<p className="text-sm">The default: card background, primary corners.</p>
</FrameContent>
</Frame>
<Frame size="sm" color="warning" collapsible>
<FrameHeader>
<FrameTitle>Low stock</FrameTitle>
<FrameMenu label="Low stock actions">
<FrameMenuItem value="restock">Restock</FrameMenuItem>
</FrameMenu>
</FrameHeader>
<FrameContent>
<p className="text-sm">3 products have fewer than 5 units left.</p>
</FrameContent>
</Frame>
<Frame size="sm" color="error" collapsible>
<FrameHeader>
<FrameTitle>Payment failed</FrameTitle>
</FrameHeader>
<FrameContent>
<p className="text-sm">Order 4190 was declined by the card issuer.</p>
</FrameContent>
</Frame>
</div>
)
}Installation
npx shadcn@latest add https://lanzate-ui.vercel.app/r/frame.jsonUsage
import {
Frame,
FrameBack,
FrameContent,
FrameHeader,
FrameMenu,
FrameMenuItem,
FrameTitle,
} from "@/components/ui/frame"
<Frame size="lg" collapsible>
<FrameHeader>
<FrameBack onClick={goBack} />
<FrameTitle>Orders</FrameTitle>
<FrameMenu label="Order actions" onAction={run}>
<FrameMenuItem value="edit">Edit</FrameMenuItem>
</FrameMenu>
</FrameHeader>
<FrameContent>…</FrameContent>
</Frame>API
| Prop | Type | Default | Description |
|---|---|---|---|
Frame size | "sm" | "md" | "lg" | "md" | Scales the corner marks, the content padding and the default header height: sm for cards, lg for page sections. |
Frame color | "primary" | "error" | "warning" | "info" | "success" | "secondary" | "muted" | "primary" | Color of the corner marks. Every color but primary also tints the background and borders. |
Frame collapsible | boolean | false | Makes FrameTitle a button that shows and hides FrameContent. |
Frame open | boolean | Whether the content is shown, when controlled. Pair it with onOpenChange. | |
Frame defaultOpen | boolean | true | Whether the content is shown at first, when uncontrolled. |
Frame onOpenChange | (open: boolean, details) => void | Runs when the user shows or hides the content. | |
FrameHeader height | "sm" | "md" | "lg" | the frame's size | Height of the header. Back and menu buttons scale with it and keep the same gap on every side. Its children are free content. |
FrameTitle children | ReactNode | Title content: text, icons, badges. Fills the space between back and menu, and truncates. | |
FrameTitle size | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "display" | "inherit" | "xs" | Text size of the title, from Text's scale. Pair a large size with a taller FrameHeader height. |
FrameBack label | string | "Back" | Accessible name of the back button. It is the registry Button (square, ghost), so it takes onClick, tooltip, color and the rest of its props. |
FrameMenu label | string | Accessible name of the three-dot button. Required: screen readers and agents find the menu by it. | |
FrameMenu onAction | (value: string) => void | Runs for every item in the menu and its submenus, with the item's value. | |
FrameMenuItem icon | ReactNode | Decorative icon before the item text. Also on FrameSubmenuTrigger. | |
FrameContent className | string | Classes for the padded box around the content. |