Column Header
ProNewA column heading that opens a menu to sort either way, clear the sort, pin the column or hide it.
Installation
pnpm dlx shadcn@latest add @viewport/column-header
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 |
|---|---|---|
| title* | stringThe column's name. | — |
| sort | "asc" | "desc" | nullThe column's current sort. | null |
| onSort | (sort: "asc" | "desc" | null) => voidReceives the chosen sort, or `null` to clear it. Leave it out for columns that cannot be sorted. | — |
| onHide | () => voidAdds "Hide column". | — |
| pinned | booleanWhether the column is pinned. Pass it with `onPin` to add "Pin column". | — |
| onPin | (pinned: boolean) => void | — |
| numeric | booleanAlign the trigger to the end, for numeric columns. | — |
| className | string | — |
Accessibility
- The trigger names the column and states its current sort.
- A Radix Dropdown Menu: arrow keys, typeahead and Escape.
- The arrow turns between ascending and descending only when motion is allowed.