Inspector
An inspector pane like Xcode's or Pages': sections of right-aligned labels beside small controls.
@cupertinoui/inspectorRegistry JSON "use client"
import { Checkbox } from "@/components/ui/checkbox"
import { Input } from "@/components/ui/input"
import {
Inspector,
InspectorLabel,
InspectorRow,
InspectorSection,
InspectorSectionTitle,
} from "@/components/ui/inspector"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Slider } from "@/components/ui/slider"
import { Stepper, StepperButtons, StepperInput } from "@/components/ui/stepper"
const fits = { fill: "Fill", fit: "Fit", stretch: "Stretch" }
function Measure({ label, defaultValue }: { label: string; defaultValue: number }) {
return (
<div className="flex flex-col items-center gap-0.5">
<Stepper size="sm" defaultValue={defaultValue} min={0}>
<StepperInput aria-label={label} className="w-14" />
<StepperButtons />
</Stepper>
<span className="text-mac-footnote text-mac-label-secondary">{label}</span>
</div>
)
}
export default function InspectorDemo() {
return (
<Inspector className="w-64 rounded-[10px] bg-mac-window shadow-[0_0_0_1px_var(--mac-grid)]">
<InspectorSection>
<InspectorSectionTitle>Image</InspectorSectionTitle>
<InspectorRow>
<InspectorLabel htmlFor="inspector-name">Name</InspectorLabel>
<Input id="inspector-name" defaultValue="Header" className="h-5 rounded-[5px] px-1.5 text-mac-subheadline" />
</InspectorRow>
<InspectorRow>
<InspectorLabel>Scale</InspectorLabel>
<Select defaultValue="fill" items={fits}>
<SelectTrigger size="sm" aria-label="Scale" className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
{Object.entries(fits).map(([value, label]) => (
<SelectItem key={value} value={value}>
{label}
</SelectItem>
))}
</SelectContent>
</Select>
</InspectorRow>
</InspectorSection>
<InspectorSection>
<InspectorSectionTitle>Arrange</InspectorSectionTitle>
<InspectorRow>
<InspectorLabel>Size</InspectorLabel>
<div className="flex justify-between">
<Measure label="Width" defaultValue={320} />
<Measure label="Height" defaultValue={180} />
</div>
</InspectorRow>
<InspectorRow>
<label className="flex items-center gap-1.5">
<Checkbox defaultChecked />
Constrain proportions
</label>
</InspectorRow>
</InspectorSection>
<InspectorSection>
<InspectorSectionTitle>Style</InspectorSectionTitle>
<InspectorRow>
<InspectorLabel>Opacity</InspectorLabel>
<Slider defaultValue={[80]} aria-label="Opacity" />
</InspectorRow>
<InspectorRow>
<label className="flex items-center gap-1.5">
<Checkbox />
Shadow
</label>
</InspectorRow>
</InspectorSection>
</Inspector>
)
}Installation
pnpm dlx shadcn@latest add @cupertinoui/inspectorThe first install also adds the macOS theme. See Installation to set up the registry.
Usage
import {
Inspector,
InspectorLabel,
InspectorRow,
InspectorSection,
InspectorSectionTitle,
} from "@/components/ui/inspector"
<Inspector>
<InspectorSection>
<InspectorSectionTitle>Text Settings</InspectorSectionTitle>
<InspectorRow>
<InspectorLabel>Widths</InspectorLabel>
<Stepper size="sm" defaultValue={4}>
<StepperInput aria-label="Tab width" />
<StepperButtons />
</Stepper>
</InspectorRow>
</InspectorSection>
</Inspector>Inspectors use 11pt text, so use the small sizes of controls: size="sm" on Pop-up Button, Stepper and Button.
A row without an InspectorLabel puts its controls under those of the rows above, as for a checkbox.
API Reference
Every part forwards the props of the underlying element. The props below are the ones CupertinoUI adds or changes.
Inspector
The scrolling pane. Set --inspector-label-width (84px by default) to change the label column.
| Prop | Type | Description |
|---|---|---|
className | string | Extra classes, merged with the component's own. |
InspectorSection / InspectorSectionTitle
A titled group of rows, divided from the next by a hairline.
| Prop | Type | Description |
|---|---|---|
className | string | Extra classes, merged with the component's own. |
InspectorRow
A label beside its controls.
| Prop | Type | Description |
|---|---|---|
className | string | Extra classes, merged with the component's own. |
InspectorLabel
A right-aligned label; pass htmlFor to point it at a field.
| Prop | Type | Description |
|---|---|---|
htmlFor | string | The id of the control the label belongs to. |
className | string | Extra classes, merged with the component's own. |