View Tabs
ProNewSaved views of one table with counts, a gliding underline, and Save and Discard that appear when the view has changed.
Installation
pnpm dlx shadcn@latest add @viewport/view-tabs
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 |
|---|---|---|
| views* | View[] | — |
| value* | stringThe id of the view in use. | — |
| onValueChange* | (id: string) => void | — |
| onCreate | () => voidAdds a "New view" button. | — |
| dirty | booleanThe current view has filters or sorting that are not saved. Shows Save and Discard. | false |
| onSave | () => void | — |
| onDiscard | () => void | — |
| label | stringAccessible name for the group. | "Views" |
| className | string | — |
Accessibility
- A radio group, since every view shows the same table: arrow keys switch views.
- Unsaved changes are announced, not only shown as a dot.
- The hidden Save and Discard cannot be reached by Tab.
- Respects prefers-reduced-motion.