Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Cascader

A button that opens columns of a hierarchy in a popup, one column per level, to pick one or more items.

Built on the headless Cascader.See its API in Docs

Rendered by React 19.3.1

cascader.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/cascader.json

It also adds utils, button. The app needs its setup first: Installation.

Usage

Put a CascaderLabel, a CascaderTrigger (with a CascaderValue inside; the chevron comes with it) and an optional CascaderClear in Cascader, then CascaderPortal > CascaderPositioner > CascaderPopup around an optional CascaderInput, the CascaderColumns and CascaderEmpty. CascaderColumns renders a CascaderColumn for each column it hands over, and each column a CascaderItem for each of its items, with CascaderItemText, CascaderItemIndicator and CascaderItemIcon inside. Without the popup, CascaderColumns is the control itself, named by the Label. The open path, the keys, the search, the selection, the lazy loading and the form value come from the headless Cascader.

import {
  Cascader,
  CascaderArrow,
  CascaderBackdrop,
  CascaderClear,
  CascaderColumn,
  CascaderColumns,
  CascaderEmpty,
  CascaderIcon,
  CascaderInput,
  CascaderItem,
  CascaderItemIcon,
  CascaderItemIndicator,
  CascaderItemText,
  CascaderLabel,
  CascaderPopup,
  CascaderPortal,
  CascaderPositioner,
  CascaderStatus,
  CascaderTrigger,
  CascaderValue,
} from '@/components/ui/cascader'

Examples

Default

A location picker whose value shows the path it chose.

Its preview and code are at the top of the page.

The trigger, the Clear, the popup and the Input are Tree Select's; the popup grows with its columns, from the trigger's width up to the room left on screen. Each column scrolls on its own and the rows are the Listbox's, with the items on the open path tinted. A parent ends in a chevron, which turns in right-to-left text, and the chosen leaf shows a check; with several values the indicator is a checkbox at the row's start. A column that is loading its children pulses, and an item whose children failed to load is drawn in the destructive color. This item takes Base UI's component ID as its slug and one name per Base UI part.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Cascader's API reference.