Column Options
ProNewShow, hide and reorder a table's columns from one panel, with a count of hidden columns on the trigger.
Installation
pnpm dlx shadcn@latest add @viewport/column-options
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 |
|---|---|---|
| columns* | { id: string; label: string; locked?: boolean }[]Every column, with its name. `locked` columns are always shown and cannot be switched off. | — |
| value* | ColumnState[]The columns in display order, each with whether it is shown. | — |
| onValueChange* | (value: ColumnState[]) => void | — |
| onReset | () => voidAdds "Reset" to the panel. | — |
| label | stringThe trigger's label. | "Columns" |
| className | string | — |
Accessibility
- Each column is a labelled switch; locked columns are disabled, not missing.
- Reorder with a drag handle or with Up and Down on the handle; each move is announced.
- The trigger states how many columns are hidden.