Select

A select dropdown component for choosing a single option from a list of choices

Installation

Terminal
pnpm add @choice-ui/select

Import

Component.tsx
import { Select, type SelectProps } from "@choice-ui/select"

Basic

Basic: The simplest usage of Select.
Features:
- Single selection dropdown - Controlled value state - Keyboard navigation support - Automatic menu dismissal on selection

Disabled

Disabled: Demonstrates disabled Select functionality.
Features:
- Disabled component prevents interaction - Visual feedback for disabled state - Selected value remains visible - Useful for conditional availability

Disabled Options

DisabledOptions: Demonstrates disabled options in Select.
Features:
- Individual options can be disabled - Disabled options cannot be selected - Visual feedback for disabled options - Maintains keyboard navigation flow

Large Size

LargeSize: Demonstrates Select with large size variant.
Features:
- Large trigger size - Large menu items - Prefix icon support - Consistent sizing across components

Light Variant

LightVariant: Demonstrates Select with light variant styling.
Features:
- Light variant visual style - Standard selection functionality - Consistent with light theme

With Icons

WithIcons: Demonstrates Select with icons for visual recognition.
Features:
- Icons displayed in menu items - Better visual recognition - Enhanced user experience
Use cases:
- Field type selection - Category selection with icons - Visual option identification

With Labels And Dividers

WithLabelsAndDividers: Demonstrates Select with labels and dividers for organization.
Features:
- Section labels for grouping - Visual dividers for separation - Better menu organization - Hierarchical menu structure
Use cases:
- Plan selection with categories - Grouped option lists - Complex menu structures

With Divider

WithDivider: Demonstrates Select with dividers for grouping options.
Features:
- Visual dividers for separation - Grouped option categories - Better menu organization
Use cases:
- Category-based selection - Grouped option lists - Visual separation of options

Long List

LongList: Demonstrates Select with a long list of options and scroll performance.
Features:
- Long list of options (100 items) - Automatic scrolling when content exceeds height - Scroll arrows for navigation - Performance optimization for large lists
Use cases:
- City/region selectors - Long option lists - Large dataset selection

Placement

Placement: Demonstrates Select with different placement options.
Features:
- Multiple placement options (bottom-start, bottom-end, etc.) - Automatic positioning adjustments - Prevents overflow beyond viewport - Flexible menu positioning

Match Trigger Width

MatchTriggerWidth: Demonstrates Select menu matching trigger width.
Features:
- Menu width matches trigger width - Consistent visual alignment - Useful for narrow triggers - Better visual consistency

Item Active

ItemActive: Demonstrates Select.Item with custom onClick action handling.
Features:
- Items with onClick behave as action items, not selection items - Clicking executes onClick handler instead of changing Select value - Menu closes after onClick handler executes - Current selection value remains unchanged - Integration with Popover for complex actions
Use cases:
- Adding action buttons within Select menus - Settings or configuration options - Secondary actions within selection menus

Close On Escape

CloseOnEscape: Demonstrates ESC key behavior control and event propagation.
Features:
- closeOnEscape prop controls ESC key behavior - When enabled (default): Pressing ESC closes menu and prevents event propagation - When disabled: Pressing ESC does NOT close menu, allowing event to propagate - Event propagation verification with counter
Use cases:
- Custom ESC key handling - Nested menu scenarios - Event propagation control

Window ESC count: 0

When select is open, pressing ESC will close it but NOT increment the counter (event is stopped).

Empty

Empty: Demonstrates Select with empty state when no options available.
Features:
- Empty state display when options array is empty - Custom empty message support - Consistent with menu styling
Use cases:
- Search results with no matches - Dynamic option lists that may be empty - Placeholder for loading states

API reference

SelectPropsTypeDefault
className
string
|
undefined
-
closeOnEscape
boolean
|
undefined
-
disabled
boolean
|
undefined
-
focusManagerProps
Partial<FloatingFocusManagerProps>
|
undefined
-
matchTriggerWidth
boolean
|
undefined
-
onChange
((value: string) => void)
|
undefined
-
onOpenChange
((open: boolean) => void)
|
undefined
-
open
boolean
|
undefined
-
placement
undefined
|
"bottom-start"
|
"bottom-end"
-
portalId
string
|
undefined
-
readOnly
boolean
|
undefined
-
root
HTMLElement
|
null
|
undefined
-
size
undefined
|
"default"
|
"large"
-
value
string
|
null
|
undefined
-
variant
undefined
|
"default"
|
"light"
|
"reset"
-