Select Component

The Select component allows users to choose one or multiple options from a dropdown list.

Props

PropTypeDefaultDescription
optionsArray<Option>[]Array of options to display in the dropdown
placeholderstring"Select an option"Placeholder text when no option is selected
multiplebooleanfalseAllow multiple selections
onChangefunctionundefinedCallback function when an option is selected
labelstringundefinedLabel text for the select component
size"xs" | "sm" | "md" | "lg" | "xl""md"Sets the size of the select component
variant"primary" | "secondary" | "success" | "warning" | "error" | "ghost""primary"Sets the color variant of the select component
requiredbooleanfalseWhether the select is required
classNamestring""Additional CSS classes for the select component
wrapperClassstring""Additional CSS classes for the wrapper element
labelClassstring""Additional CSS classes for the label element
labelTextClassstring""Additional CSS classes for the label text
sxReact.CSSProperties{}Custom styles to be applied to the select component
renderOptionfunctionundefinedCustom render function for option items
hideSearchbooleanfalseHide the search input in the dropdown

Usage

import { Select } from 'knoxui-react';

const options = [
  { value: 'option1', label: 'Option 1' },
  { value: 'option2', label: 'Option 2' },
  { value: 'option3', label: 'Option 3' },
];

<Select
  options={options}
  onChange={(option) => setSelectedOption(option)}
  placeholder="Select an option"
/>

Examples

Basic Usage

Multiple Selection

Sizes

Variants

With Label

Required Select