Sort Indicator

Sort Indicator is a copy-paste React component that stops misread the table's sort order before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/sort-indicator
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsMisread the table's sort order

Was this component page useful?

How do I install Sort Indicator?

pnpm dlx shadcn@latest add @bollard/sort-indicator

The files land in your project. They're yours to edit.

How do I use Sort Indicator in React?

sort-indicator-usage.tsx
import { ariaSort, SortButton, SortIndicator, sortRows, useFlip, type SortColumn, type SortState } from "@/components/ui/sort-indicator"

<SortIndicator
  columns={columns}
  value={sort}
  onValueChange={setSort}
  emptyCount={sorted.emptyCount}
  pinnedCount={sorted.pinnedCount}
  onRevealColumn={() => setShowPriority(true)}
  rowWords={["task", "tasks"]}
/>

What input mistakes does Sort Indicator catch?

  • Sort by a column that isn't on screen, with a reveal action
  • Empty values, kept last in both directions and counted
  • Pinned rows that stay first regardless of sort
  • Direction in words that fit the column (A to Z, oldest first)

What props does Sort Indicator accept?

SortIndicator props
PropTypeDefault
columns* (required)

All sortable columns, used for labels and the readback.

SortColumn[]—
value

Controlled sort; `null` means unsorted.

SortState | null—
defaultValue

Starting sort when uncontrolled.

SortState | nullnull
onValueChange

Called with the new sort, or null when cleared.

(sort: SortState | null) => void—
emptyCount

Rows with no value in the sort column (they sit at the end). `sortRows` returns it.

number0
pinnedCount

Rows pinned above the sort. `sortRows` returns it.

number0
onRevealColumn

Shows a "Show column" fix when sorting by a hidden column.

(columnId: string) => void—
sortedText

Templates: `{label}`, `{direction}`, `{count}`, `{rows}` are filled in.

string"Sorted by {label}, {direction}"
unsortedText

Readback when nothing is sorted.

string"Not sorted: rows are in the order they were added"
reverseLabel

Label of the reverse button.

string"Reverse"
clearLabel

Label of the clear-sort button.

string"Clear sort"
hiddenText

Warning when sorting by a hidden column.

string"{label} isn't shown in the table, so the order can look …
revealLabel

Label of the reveal-column button.

string"Show {label}"
emptyText

Note about rows with empty values.

string"{count} {rows} with no {label} placed at the end."
pinnedText

Note about pinned rows.

string"{count} pinned {rows} kept on top whatever the sort."
rowWords

Singular and plural word for a row, e.g. ["task", "tasks"].

[string, string]["row", "rows"]

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Sort Indicator accessible?

  • Header button with a descriptive title; use the ariaSort helper for aria-sort on <th>
  • Sort readback and warnings render in polite live regions
  • Row animation (FLIP) is skipped under reduced motion
  • Reverse and clear are labelled buttons

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Sorting helper uses natural numeric comparison; locale-specific collation may differ
  • You place aria-sort on your <th> (ariaSort helper provided)

What expensive mistakes does Sort Indicator stop?

Misread the table's sort order

Also known as

table sort · sorting · data table · column header · asc desc · tanstack table · ag grid · sort arrow

What dependencies does Sort Indicator require?

Sort Indicator facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameSort Indicator
Registry identifier@bollard/sort-indicator
Install commandnpx shadcn@latest add @bollard/sort-indicator
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Sort Indicator

What form validation mistake does Sort Indicator catch?

Sort Indicator prevents misread the table's sort order. States a table's sort in plain words and warns when hidden columns, empty values or pinned rows make the order look wrong. Catches: Sort by a column that isn't on screen, with a reveal action, Empty values, kept last in both directions and counted, Pinned rows that stay first regardless of sort, Direction in words that fit the column (A to Z, oldest first). Limitation: validate sort-indicator schemas on backend.

How do I install sort-indicator with shadcn?

Run `npx shadcn@latest add @bollard/sort-indicator`. Sources added: registry/default/sort-indicator/sort-indicator.tsx. Package requirements: lucide-react.

What props customize Sort Indicator?

Sort Indicator accepts `columns`, `value`, `defaultValue`, `onValueChange`, `emptyCount`. Configures table sort, sorting, data table behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of sort-indicator?

Sorting helper uses natural numeric comparison; locale-specific collation may differ. You place aria-sort on your <th> (ariaSort helper provided) Server requirement: backend verification for sort-indicator.

How does Sort Indicator meet accessibility guidelines?

Header button with a descriptive title; use the ariaSort helper for aria-sort on <th>. Sort readback and warnings render in polite live regions. Row animation (FLIP) is skipped under reduced motion. Reverse and clear are labelled buttons. Minimizes errors: table sort unclear, which column is sorted.

Which components pair with Sort Indicator?