Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Sort Builder

ProNew

A sort with several levels: each rule is a sentence whose field and direction are controls, rules move up and down, a field is used once, and the whole sort is read back in words.

Installation

pnpm dlx shadcn@latest add @viewport/sort-builder

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

PropTypeDefault
fields*{ id: string; label: string }[]

The fields that can be sorted by.

—
value*SortRule[]

The sort, most important rule first.

—
onValueChange*(value: SortRule[]) => void—
maxnumber

The most rules allowed.

4
classNamestring—

Accessibility

  • Every control is named with its rule and field.
  • The sort is announced in words as it changes.
  • Move buttons disable at the ends.
  • Fields keep 16px text on phones.
  • Respects prefers-reduced-motion.