- Components
- select
Select
Customizable dropdown for single or multiple selection options.
Demo
<div class="w-full space-y-3">
<x-ui.select name="select-country" id="select-country">
<option value="DRC">DR Congo</option>
<option value="TZ">Tanzania</option>
<option value="MA">Morocco</option>
<option value="NG">Nigeria</option>
</x-ui.select>
<x-ui.select name="select-country" id="select-country"
variant="flush" class="bg-muted">
<option value="DRC">DR Congo</option>
<option value="TZ">Tanzania</option>
<option value="MA">Morocco</option>
<option value="NG">Nigeria</option>
</x-ui.select>
</div>
For a select you can style — search, icons, avatars, groups or several values — use the Listbox , or the Autocomplete when people should type first.
Installation
php artisan flexi:add select
With label
<div class="w-full space-y-4">
<x-ui.select label="Country" name="select-country_label" id="select-country_label">
<option value="DRC">DR Congo</option>
<option value="TZ">Tanzania</option>
<option value="MA">Morocco</option>
<option value="NG">Nigeria</option>
</x-ui.select>
<x-ui.select inlined-label label="Country" label-class="min-w-max" name="select-country_inlined" id="select-country_inlined"
variant="flush" class="bg-muted">
<option value="DRC">DR Congo</option>
<option value="TZ">Tanzania</option>
<option value="MA">Morocco</option>
<option value="NG">Nigeria</option>
</x-ui.select>
</div>
With Icon
Icon Indicator
<div class="relative w-full">
<x-ui.select name="select-country" id="select-country" class="pe-9" :indicator="false">
<option value="DRC">DR Congo</option>
<option value="TZ">Tanzania</option>
<option value="MA">Morocco</option>
<option value="NG">Nigeria</option>
</x-ui.select>
<span aria-hidden="true"
class="absolute right-3 inset-y-px text-muted-foreground pointer-events-none flex items-center">
<x-ui.icon name="ph--caret-up-down" class="flex text-sm" />
</span>
</div>
Indicator color
The arrow is drawn in CSS, not with an image: --ui-select-indicator-color
sets its color (--muted-foreground
in every theme), --ui-select-indicator-stroke
its weight and --ui-select-indicator-size
its width. --ui-select-indicator-image
replaces it with your own image.
<div class="grid w-full max-w-md gap-3 sm:grid-cols-2">
<x-ui.select aria-label="Primary arrow" class="[--ui-select-indicator-color:var(--color-primary)] [--ui-select-indicator-stroke:2px]">
<option>Primary arrow</option>
</x-ui.select>
<x-ui.select aria-label="On a filled select" class="border-transparent bg-primary text-primary-foreground [--ui-select-indicator-color:var(--color-primary-foreground)]">
<option>On a filled select</option>
</x-ui.select>
</div>
References
Composition
| Prop | Description |
|---|---|
x-ui.select
|
The main select component |
x-ui.input.group
|
A container wrapper for select groups that provides consistent styling and layout |
x-ui.input.leading
|
A leading element container for selects, typically used for icons or text that appears before the select content. Can be positioned absolutely or inline. |
x-ui.input.trailing
|
A trailing element container for selects, typically used for icons or text that appears after the select content. Can be positioned absolutely or inline. |
Select Props
To configure the select component you can use the following props. All props are optional.
| Prop | Description |
|---|---|
size
(string)
|
The size of the select. Options: "sm", "md", "lg", "none". Default: "md" |
disabled
(boolean)
|
Whether the select is disabled. Default: false |
readonly
(boolean)
|
Whether the select is readonly. Default: false |
label
(string)
|
The label text for the select. Default: null |
variant
(string)
|
The variant of the select. Options: "default", "ghost", "flush", "unstyled". Default: "default" |
labelPosition
(top|inline)
|
Position of the label relative to the select. Options: "top", "inline". Default: "top" |
labelClass
(string)
|
Additional CSS classes for the label. Default: '' |
indicator
(boolean)
|
Controls the dropdown indicator visibility. Default: true |
class
(string)
|
Additional CSS classes for the select. Default: '' |
Group Props
The select component uses the same input group component. See input component references for group props.