Jump to a page or a component.
Composed patterns built from more than one primitive — copy the whole shape, not just a component.
A left-hand icon rail switching between sections, each rendering a different picker shape — palette cards, a described row list, a plain field — inside one dialog. Built entirely from existing primitives: Dialog, Tabs variant="nav", OptionPalette, OptionList and Input. The Theme tab is one line — OptionPalette is the whole picker, and it reports a key rather than applying it, so the dialog stays out of the theming decision. There is no dedicated SettingsDialogcomponent in the library — Layout, Background and Network are the kind of app-specific concepts a shared library shouldn't own, so this page documents the shape instead of shipping it as one more component to keep in sync.
The full four-section version (this one plus a Background pattern grid) runs for real in this gallery's own /demo — click the gear icon at the bottom of the sidebar rail.
Three sections instead of four — Background's texture-swatch picker is cut here for length; see it in full at /demo. Paste this, then replace the placeholder options array and the three pieces of state with whatever your app actually persists.
import { Clock, LayoutTemplate, Palette, SlidersHorizontal } from "lucide-react";
import * as React from "react";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { OptionList } from "@/components/ui/option-list";
import { OptionPalette } from "@/components/ui/option-palette";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { type ColorThemeKey } from "@/lib/color-themes";
// One entry per TabsList "nav" row. Add a fourth ("background") the same way
// — see /demo for a texture picker, the same cards from a plain OptionGrid.
const SETTINGS_SECTIONS = [
{ id: "theme", label: "Theme", Icon: Palette },
{ id: "layout", label: "Layout", Icon: LayoutTemplate },
{ id: "network", label: "Network", Icon: SlidersHorizontal },
] as const;
export function SettingsDialog() {
const [open, setOpen] = React.useState(false);
const [section, setSection] = React.useState<
(typeof SETTINGS_SECTIONS)[number]["id"]
>("theme");
// Wire these to whatever your app actually persists — a palette context,
// a layout preset in Redux, a call-timeout field, etc. This recipe only
// owns the dialog shape, not the settings themselves.
const [theme, setTheme] = React.useState<ColorThemeKey>("midnight-dark");
const [layout, setLayout] = React.useState("balanced");
const [callTimeout, setCallTimeout] = React.useState("");
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button variant="outline">Open Settings</Button>
</DialogTrigger>
<DialogContent className="h-[min(460px,80vh)] w-[min(760px,92vw)]">
<DialogHeader>
<DialogTitle>Settings</DialogTitle>
</DialogHeader>
<Tabs
value={section}
onValueChange={(v) => setSection(v as typeof section)}
orientation="vertical"
className="min-h-0 flex-1"
>
<TabsList aria-label="Settings sections" variant="nav">
{SETTINGS_SECTIONS.map(({ id, label, Icon }) => (
<TabsTrigger key={id} value={id}>
<Icon size={14} />
{label}
</TabsTrigger>
))}
</TabsList>
<TabsContent value="theme" className="min-h-0 overflow-y-auto px-4 py-3">
<OptionPalette value={theme} onValueChange={setTheme} />
</TabsContent>
<TabsContent value="layout" className="min-h-0 overflow-y-auto px-4 py-3">
<OptionList
value={layout}
onValueChange={setLayout}
options={[
{
value: "balanced",
label: "Balanced",
description: "Sidebar, editor and response split evenly.",
icon: LayoutTemplate,
},
// ...one option per layout preset
]}
/>
</TabsContent>
<TabsContent value="network" className="min-h-0 overflow-y-auto px-4 py-3">
<div className="flex items-center gap-2">
<Input
icon={Clock}
type="number"
min={0}
step={500}
value={callTimeout}
onChange={(e) => setCallTimeout(e.target.value)}
onClear={() => setCallTimeout("")}
placeholder="Enter timeout in ms…"
aria-label="Call timeout"
className="font-mono"
/>
<span className="font-mono text-[11px] text-app-dim">ms</span>
</div>
</TabsContent>
</Tabs>
<DialogFooter>
<Button onClick={() => setOpen(false)}>Done</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}