Forms

Cascader.

Navigate a hierarchy and choose a final path, one level at a time.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/cascader.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Choose a path from local records

An asynchronous local loader demonstrates the boundary; selecting a leaf commits its stable ID path.

Loads this example when you need it.

Keyboard

  • Right opens a parent; Left returns to its parent.
  • Enter selects a final leaf.

States covered

  • Root choices
  • Child choices
  • Committed path

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-cascader.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {useState} from 'react';
import {Cascader,UIProvider,type CascaderNode,type CascaderOptionsLoader,type CascaderPathResolver} from '@bld8/ui';
import '@bld8/ui/styles.css';
const nodes:CascaderNode[]=[{value:'design',label:'Design',parentValue:null,hasChildren:true},{value:'engineering',label:'Engineering',parentValue:null,hasChildren:true},{value:'ui',label:'Interfaces',parentValue:'design',hasChildren:false},{value:'web',label:'Web applications',parentValue:'engineering',hasChildren:false}];
const loadAreas:CascaderOptionsLoader=async({parentValue,query,signal})=>{if(signal.aborted)throw new DOMException('Cancelled','AbortError');return {items:nodes.filter(node=>node.parentValue===parentValue&&node.label.toLowerCase().includes(query.toLowerCase())),nextCursor:null};};
const resolvePath:CascaderPathResolver=async({values,signal})=>{if(signal.aborted)throw new DOMException('Cancelled','AbortError');return values.flatMap(value=>nodes.filter(node=>node.value===value));};
export default function CascaderExample(){const [path,setPath]=useState<string[]>([]);return <UIProvider><Cascader label="Example project area" name="area" value={path} onValueChange={setPath} loadOptions={loadAreas} resolvePath={resolvePath} hint="These records are local to this module."/><p>Committed IDs: {path.join(' / ')||'none'}</p></UIProvider>;}

Quick reference

React / TypeScript
<Cascader label="Project area" name="area"
  value={path} onValueChange={setPath}
  loadOptions={loadAreas} resolvePath={resolveAreaPath} />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

A committed value is an ordered array of stable IDs. Browsing parents does not change it; only a final leaf commits. The shared async boundary debounces current-level search, cancels stale requests and supports bounded paging and retry. resolvePath returns the exact ordered chain; selectedPath can seed its labels. Native forms submit a JSON ID array. Arrow keys browse results; Right opens a parent and Left goes back. At most eight levels and 500 loaded options per level are included. Search applies only to the current level. No global tree search or virtualization is implied. The host validates membership and access. See /examples/cascader and /agent/guides/cascader.md.

Try hierarchical selection · Path contract

Cascader

Cascader public properties
PropTypeDefault
labelRequiredstring—
loadOptionsRequiredCascaderOptionsLoader<T>—
clearableboolean | undefinedtrue
debounceMsnumber | undefined200
defaultValuereadonly string[] | undefined[]
density"compact" | "comfortable" | undefined'comfortable'
disabledboolean | undefinedfalse
errorstring | undefined—
hintstring | undefined—
inputRefRef<HTMLButtonElement> | undefined—
labelVisibility"hidden" | "visible" | undefined'visible'
maxDepthnumber | undefined8
minQueryLengthnumber | undefined0
namestring | undefined—
onBlurFocusEventHandler<HTMLButtonElement> | undefined—
onValueChange((path: string[]) => void) | undefined—
placeholderstring | undefined'Choose an option…'
renderNode((node: T) => ReactNode) | undefined—
resolvePathCascaderPathResolver<T> | undefined—
selectedPathreadonly T[] | undefined

Complete initial display path. Ignore its records after a different value is chosen.

—
sourceKeystring | undefined''
valuereadonly string[] | undefined—

CascaderNode

CascaderNode public properties
PropTypeDefault
hasChildrenRequiredboolean—
labelRequiredstring—
parentValueRequiredstring | null—
valueRequiredstring—
descriptionstring | undefined—
disabledboolean | undefined—

CascaderOptionsRequest

CascaderOptionsRequest public properties
PropTypeDefault
cursorRequiredstring | null—
parentValueRequiredstring | null—
pathRequiredreadonly string[]—
queryRequiredstring—
signalRequiredAbortSignal—

AsyncOptionsPage

AsyncOptionsPage public properties
PropTypeDefault
itemsRequiredreadonly T[]—
nextCursorRequiredstring | null—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.