Master Detail
ProNewA list beside the thing chosen from it. Side by side when its container is wide; one pane at a time with a back button when it is narrow.
Installation
pnpm dlx shadcn@latest add @viewport/master-detail
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| list* | React.ReactNodeThe list of things to choose from. | — |
| detail* | React.ReactNodeThe chosen thing, or a placeholder when nothing is chosen. | — |
| open* | booleanWhether something is chosen. On narrow containers this decides which of the two panes is shown. | — |
| onBack* | () => voidReturns to the list on narrow containers. Clear the selection here. | — |
| backLabel | stringThe back button's text, e.g. the list's name. | "Back" |
| listLabel | stringNames the two regions for assistive technology. | "List" |
| detailLabel | string | "Details" |
Accessibility
- Two labelled regions.
- The split follows the component's own width, so it works inside panels.
- The back button appears only when one pane is shown.
- Respects prefers-reduced-motion.