Forms

Select.

A short list, kept out of the way until needed.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/select.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.

Grouped choices with stable values

Icons and descriptions explain each choice while forms keep the canonical ID.

Keyboard

  • Open the list with Enter or Space.
  • Arrow keys move between enabled choices; type a label for typeahead.
  • Enter selects; Escape closes and returns focus to the trigger.

States covered

  • controlled value
  • controlled popup
  • groups
  • icons
  • descriptions
  • disabled option
  • native form
  • clearable

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-select-rich-options.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 '@bld8/ui/styles.css';
import { useRef, useState } from 'react';
import { Archive, Cloud, Server } from 'lucide-react';
import { Button, Select, type Option } from '@bld8/ui';

const targets: Option[] = [
  { value: 'cluster-preview', label: 'Preview cluster', group: 'Delivery', icon: Cloud, description: 'Quick checks before a release.' },
  { value: 'cluster-primary', label: 'Primary cluster', group: 'Delivery', icon: Server, description: 'The production destination.' },
  { value: 'cluster-archive', label: 'Archive cluster', group: 'History', icon: Archive, description: 'Kept for existing deployments.', disabled: true }

];
export default function GroupedSelectExample() {
  const [value, setValue] = useState<string | null>('cluster-preview');
  const [open, setOpen] = useState(false);
  const [submitted, setSubmitted] = useState('Not submitted');
  const trigger = useRef<HTMLButtonElement>(null);
  return <form aria-label="Deployment selection example" onSubmit={event => {
    event.preventDefault(); setSubmitted(String(new FormData(event.currentTarget).get('deployment') ?? ''));
  }} style={{ display: 'grid', gap: 16, maxWidth: 440 }}>
    <Select label="Deployment target" name="deployment" options={targets} value={value} onValueChange={setValue}
      open={open} onOpenChange={setOpen} inputRef={trigger} clearable hint="The submitted value is a cluster ID." />
    <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
      <Button variant="secondary" onClick={() => { trigger.current?.focus(); setOpen(true); }}>Open target list</Button>
      <Button type="submit">Read deployment value</Button>
    </div>
    <output aria-label="Deployment form value">{submitted}</output>
  </form>;
}

Empty choices and validation

Show the unavailable state, load choices explicitly and retain useful field feedback.

Keyboard

  • The empty list explains why no choice can be made.
  • After loading choices, use normal select keyboard navigation.
  • The managed field remains disabled and cannot change.

States covered

  • empty options
  • required
  • invalid
  • disabled field
  • recovery

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-select-empty-validation.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 '@bld8/ui/styles.css';
import { useState } from 'react';
import { Button, Select, type Option } from '@bld8/ui';
const destinations: Option[] = [{ value: 'edge', label: 'Edge destination' }, { value: 'batch', label: 'Batch destination' }];
export default function EmptySelectExample() {
  const [available, setAvailable] = useState(false);
  const [value, setValue] = useState<string | null>(null);
  const [attempted, setAttempted] = useState(false);
  const [submitted, setSubmitted] = useState('Not submitted');
  return <form aria-label="Destination validation example" noValidate onSubmit={event => {
    event.preventDefault(); setAttempted(true); setSubmitted(value ?? 'Choose a destination first.');
  }} style={{ display: 'grid', gap: 16, maxWidth: 440 }}>
    <Select label="Release destination" name="destination" options={available ? destinations : []} value={value} onValueChange={setValue}
      required emptyMessage="No destinations are available." placeholder="Choose a destination"
      error={attempted && !value ? 'Choose a release destination.' : undefined}
      hint={available ? 'Choices are ready.' : 'Load the example destinations to continue.'} />
    <Select label="Managed region" options={[{ value: 'central', label: 'Central region' }]} defaultValue="central" disabled hint="Managed by the application." />
    <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}><Button variant="secondary" onClick={() => setAvailable(true)} disabled={available}>Load example destinations</Button><Button type="submit">Check destination</Button></div>
    <output aria-label="Destination validation result">{submitted}</output>
  </form>;
}

External forms and native reset

Associate choices with a separate form. Native reset restores uncontrolled defaults; the application owns controlled values.

Keyboard

  • Choose a different value with the normal list keyboard controls.
  • Submit reads the canonical IDs from the external form.
  • Reset restores uncontrolled defaults without reporting a user change.

States covered

  • external form
  • required
  • uncontrolled defaults
  • native reset
  • controlled reset ownership

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-choice-native-form-reset.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 { useId, useState } from 'react';
import { Button, Combobox, MultiSelect, Select, type Option } from '@bld8/ui';
import '@bld8/ui/styles.css';
const choices: Option[] = [{ value: 'alpha-id', label: 'Alpha environment' }, { value: 'beta-id', label: 'Beta environment' }];
export default function ExternalChoiceFormExample() {
  const formId = useId();
  const [controlled, setControlled] = useState<string | null>('alpha-id');
  const [changes, setChanges] = useState(0);
  const [result, setResult] = useState('Not submitted');
  const changed = () => setChanges(count => count + 1);
  return <div style={{ display: 'grid', gap: 16, maxWidth: 440 }}>
    <Select label="Resettable environment" name="nativeSelect" form={formId} options={choices} defaultValue="alpha-id" required onValueChange={changed} />
    <Combobox label="Resettable search" name="nativeCombo" form={formId} options={choices} defaultValue="alpha-id" required onValueChange={changed} />
    <MultiSelect label="Resettable reviewers" name="nativeMulti" form={formId} options={choices} defaultValue={['alpha-id']} required onValueChange={changed} />
    <Combobox label="Application-owned environment" name="controlledCombo" form={formId} options={choices} value={controlled} onValueChange={setControlled} />
    <form id={formId} aria-label="External choice form" onSubmit={event => {
      event.preventDefault(); const data = new FormData(event.currentTarget);
      setResult(['nativeSelect', 'nativeCombo', 'nativeMulti', 'controlledCombo'].map(name => data.getAll(name).map(String).join(',')).join(' | '));
    }} style={{ display: 'grid', gap: 12 }}>
      <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}><Button type="submit">Read external choice values</Button><Button type="reset" variant="secondary">Reset external choices</Button></div>
      <output aria-label="External choice values">{result}</output>
      <output aria-label="Choice change count">{changes}</output>
    </form>
  </div>;
}

Quick reference

React / TypeScript
<Select label="Visibility" options={[{value:"private",label:"Private"},{value:"public",label:"Public"}]} defaultValue="private" />

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

Built on Base UI Select. Stable-ID options accept optional description, icon, group and search terms. Supports controlled/default value and popup state, native name/form, hint/error, required, disabled, visible-input ref and blur. Custom option rows must be presentational. Arrow keys and typeahead select options; empty content is explicit.

Select

Select public properties
PropTypeDefault
labelRequiredstring—
optionsRequiredreadonly Option[]

Stable, unique values; labels and optional rich content are display only.

—
clearableboolean | undefinedfalse
defaultOpenboolean | undefinedfalse
defaultValuestring | null | undefinednull
density"compact" | "comfortable" | undefined'comfortable'
disabledboolean | undefined—
emptyMessagestring | undefined—
errorstring | undefined—
formstring | undefined—
hintstring | undefined—
inputRefRef<HTMLButtonElement> | undefined—
labelVisibility"hidden" | "visible" | undefined'visible'
namestring | undefined—
onBlurFocusEventHandler<HTMLButtonElement> | undefined—
onOpenChange((open: boolean) => void) | undefined—
onOpenChangeComplete((open: boolean) => void) | undefined—
onValueChange((value: string | null) => void) | undefined—
openboolean | undefined

Optional controlled popup state, independent of the selected value.

—
placeholderstring | undefined—
readOnlyboolean | undefined—
renderOption((option: Option) => ReactNode) | undefined

A presentational row body; do not add nested interactive elements.

—
requiredboolean | undefined—
valuestring | null | undefined—

Option

Option public properties
PropTypeDefault
labelRequiredstring—
valueRequiredstring—
descriptionstring | undefined—
disabledboolean | undefined—
groupstring | undefined—
iconLucideIcon | undefined—
searchTermsstring[] | undefined—

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.