Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

Listbox

listbox

Presents a keyboard-navigable single or multiple selection list.

Usage

Single choice

selectionMode="single", click/arrow keys to roam, and check the selected item.

ProfileView and edit accounts
SettingsPreferences and Notifications
Shortcut keys⌘K
Disabled
Log out
tsx
<Listbox
  items={items}
  selectionMode="single"
  defaultSelectedKeys={["profile"]}
  onSelectionChange={setKeys}
/>

Multiple choice

selectionMode="multiple", multiple selections are allowed, aria-multiselectable is automatically turned on.

ProfileView and edit accounts
SettingsPreferences and Notifications
Shortcut keys⌘K
Disabled
Log out
tsx
<Listbox
  items={items}
  selectionMode="multiple"
  defaultSelectedKeys={["profile", "settings"]}
  onSelectionChange={setKeys}
/>

Pure action list

selectionMode="none" does not hold the selected state, and only relies on onAction to trigger the command.

ProfileView and edit accounts
SettingsPreferences and Notifications
Shortcut keys⌘K
Disabled
Log out
tsx
<Listbox
  items={items}
  selectionMode="none"
  onAction={(key) => console.log(key)}
  aria-label="Action List"
/>

Slot and description

startContent icon, description secondary copy, endContent shortcut key, disabled deactivated.

ProfileView and edit accounts
SettingsPreferences and Notifications
Shortcut keys⌘K
Disabled
Log out
tsx
const items = [
  { key: "profile", label: "Personal Information", description: "View and Edit Account", startContent: <User className="size-4" /> },
  { key: "shortcut", label: "Shortcut key", endContent: <kbd className="font-mono text-xs">⌘K</kbd> },
  { key: "disabled", label: "Disabled Item", disabled: true },
];

<Listbox items={items} selectionMode="single" />

When to use

Use Listbox for an always-visible, keyboard-accessible collection of options such as settings, commands, or menu items. Use selectionMode="single" or "multiple" when selection state matters, and selectionMode="none" with onAction for commands that should not remain selected. Unlike Combobox, Listbox has no input or popup and is best for a modest, flat set of visible options.

Import

ts
import { Listbox } from "@hulianui/ui"

Props

NameTypeDefaultDescription
items*ListboxItemData[]-List items; each item contains key/label, and can contain description/startContent/endContent/disabled
selectionMode"none" | "single" | "multiple""single"none creates an action-only list; single and multiple retain selection.
selectedKeysstring[]-Controlled selected keys.
defaultSelectedKeysstring[][]Initial selected keys when uncontrolled.
disabledKeysstring[][]Extra disabled keys, merged with item.disabled.
classNamestring-Container class name
styleCSSProperties-Inline styles, placed on the root element of the list. Used to express dynamic values that cannot be given by the Tailwind class (such as maxHeight determined at runtime)
aria-labelstring"\u9009\u9879\u5217\u8868"Accessible name; the built-in Chinese copy means “Option list.”

Events

EventTypeDescription
onSelectionChange(keys: string[]) => voidCalled when selection changes.
onAction(key: string) => voidTriggered when any item is activated (including none mode), used for imperative actions

Example

tsx
const [keys, setKeys] = useState<string[]>(["profile"]);
<Listbox
  items={items}
  selectionMode="single"
  selectedKeys={keys}
  onSelectionChange={setKeys}
/>

Action-only list (no selected state):

tsx
<Listbox items={items} selectionMode="none" onAction={(key) => run(key)} aria-label="Actions" />

Usage guidelines

  • With selectionMode="none", the component retains no selection. Handle activations with onAction; onSelectionChange has no meaningful value in this mode.
  • Provide aria-label when the list has no visible heading so assistive technology can identify its purpose.

Related

SecretField · Combobox · Mentions · InputOTP · Rating · Upload

Playground

ProfileView and edit accounts
SettingsPreferences and Notifications
Shortcut keys⌘K
Disabled
Log out
<Listbox
  items={items}
  selectionMode="single"
  selectedKeys={keys}
  onSelectionChange={setKeys}
/>
PreviousRemoteSelectFormsNextMentions

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Example
    • Usage guidelines
    • Related
  • Playground