Theme Preview
Theme preview
Default
Preview a component in light and dark mode.
Light mode
lightDark mode
darkexamples.tsx
1import { ThemeCompare, ThemePreviewToggle } from "@/registry/ui/theme-preview";23function PricingCard() {4 return (5 <div className="mx-auto max-w-sm rounded-3xl border border-border bg-card p-6 text-card-foreground shadow-xl">6 <div className="mb-6">7 <p className="text-sm font-medium text-muted-foreground">Pro</p>8 <h3 className="mt-2 text-3xl font-bold tracking-tight">£9/mo</h3>9 <p className="mt-2 text-sm text-muted-foreground">10 For builders who want premium components and showcase utilities.11 </p>12 </div>1314 <button className="w-full rounded-2xl bg-primary px-4 py-3 text-sm font-semibold text-primary-foreground shadow-sm transition hover:opacity-90">15 Upgrade now16 </button>17 </div>18 );19}2021export function ThemePreviewExample() {22 return (23 <main className="space-y-10 p-8">24 <ThemePreviewToggle minHeight={360}>25 <div className="grid min-h-screen place-items-center p-8">26 <PricingCard />27 </div>28 </ThemePreviewToggle>2930 <ThemeCompare minHeight={360}>31 <div className="grid min-h-screen place-items-center p-8">32 <PricingCard />33 </div>34 </ThemeCompare>35 </main>36 );37}
Installation & source
Install via the shadcn CLI or copy the registry files manually.
bash
npx shadcn@latest add @tt-ui/theme-preview
Props
| Name | Type | Default | Description |
|---|---|---|---|
| theme | string | "light" | "dark" | The theme of the preview. Defaults to light. |
| children | ReactNode | Required | The content of the preview. Defaults to undefined. |
| minHeight | number | 280 | The minimum height of the preview. Defaults to 280. |
| className | string | undefined | The classes of the preview. Defaults to undefined. |
| previewClassName | string | undefined | The classes of the preview. Defaults to undefined. |
| layout | "grid" | "stack" | "grid" | The layout of the preview. Defaults to grid. |
| labels | { light?: string; dark?: string } | undefined | The labels of the preview. Defaults to light: 'Light mode', dark: 'Dark mode'. |