Skip to content

Select

A neo-brutalist style dropdown select built on top of reka-ui's Select primitive, with full sub-component support.

Demo

Preview

Installation

pnpm dlx brutx-vue@latest add select

Usage

vue
<script setup>
import {
    Select,
    SelectTrigger,
    SelectContent,
    SelectItem,
    SelectValue,
    SelectGroup,
    SelectLabel,
} from 'brutx-ui-vue'
</script>

<template>
    <Select>
        <SelectTrigger class="w-[280px]">
            <SelectValue placeholder="Select a fruit" />
        </SelectTrigger>
        <SelectContent>
            <SelectGroup>
                <SelectLabel>Fruits</SelectLabel>
                <SelectItem value="apple">Apple</SelectItem>
                <SelectItem value="banana">Banana</SelectItem>
                <SelectItem value="orange">Orange</SelectItem>
                <SelectItem value="grape">Grape</SelectItem>
            </SelectGroup>
        </SelectContent>
    </Select>
</template>

Unified Usage

In addition to using individual atomic components, you can use the pre-packaged unified Select component, which supports passing an options array and automatically grouping items.

vue
<script setup>
import { ref } from 'vue'
import { Select } from 'brutx-ui-vue'

const selectedValue = ref('')

const foodOptions = [
    { label: 'Apple', value: 'apple', category: 'fruits', categoryName: 'Fruits' },
    { label: 'Banana', value: 'banana', category: 'fruits', categoryName: 'Fruits' },
    { label: 'Carrot', value: 'carrot', category: 'vegetables', categoryName: 'Vegetables' },
    { label: 'Potato', value: 'potato', category: 'vegetables', categoryName: 'Vegetables' },
    { label: 'Milk', value: 'milk' } // ungrouped
]
</script>

<template>
    <!-- Basic Usage -->
    <Select
        v-model="selectedValue"
        :options="foodOptions"
        placeholder="Select your food"
        class="w-[280px]"
    />

    <!-- Auto Grouping Usage -->
    <Select
        v-model="selectedValue"
        :options="foodOptions"
        group-field="category"
        group-label="categoryName"
        placeholder="Select food (Grouped)"
        class="w-[280px]"
    />
</template>

Using v-model

vue
<script setup>
import { ref } from 'vue'
import {
    Select,
    SelectTrigger,
    SelectContent,
    SelectItem,
    SelectValue,
} from 'brutx-ui-vue'

const selectedFruit = ref('')
</script>

<template>
    <Select v-model="selectedFruit">
        <SelectTrigger class="w-[280px]">
            <SelectValue placeholder="Select a fruit" />
        </SelectTrigger>
        <SelectContent>
            <SelectItem value="apple">Apple</SelectItem>
            <SelectItem value="banana">Banana</SelectItem>
            <SelectItem value="orange">Orange</SelectItem>
        </SelectContent>
    </Select>
</template>

Sub-components

ComponentDescription
SelectRoot component (re-exported as SelectRoot from reka-ui)
SelectTriggerButton that opens the dropdown
SelectContentDropdown content panel
SelectItemSelectable option
SelectValueDisplays the selected value
SelectGroupGroups options together
SelectLabelGroup label
SelectSeparatorVisual separator
SelectScrollUpButtonScroll up indicator
SelectScrollDownButtonScroll down indicator

Props

Select (Unified Component)

PropTypeDefaultDescription
optionsSelectOption[][]Options data source, where each item contains label, value, disabled, etc.
groupFieldstringThe key to group options by (e.g., category)
groupLabelstringThe key containing the group display label in options (e.g., categoryName), defaults to the value of groupField
placeholderstring'Select an option'Placeholder text
disabledbooleanfalseWhether disabled
requiredbooleanfalseWhether required
namestringForm field name
size'sm' | 'default' | 'lg''default'Trigger size
variant'default' | 'error' | 'success''default'Border style variant
errorMessagestringError message text
clearablebooleanfalseWhether clearable
position'popper' | 'item-aligned''popper'Dropdown menu positioning strategy
classstringRoot component (trigger) CSS class
triggerClassstringCustom trigger CSS class
contentClassstringCustom dropdown content panel CSS class
itemVariant'default' | 'primary' | 'secondary''default'Option selection variant

Select (Atomic Component)

Root component that inherits all props from reka-ui SelectRoot. Common props are listed below:

PropTypeDefaultDescription
modelValuestringSelected value, supports v-model
defaultValuestringDefault selected value
openbooleanWhether the dropdown is expanded, supports v-model:open
defaultOpenbooleanfalseWhether expanded by default
disabledbooleanfalseWhether disabled
requiredbooleanfalseWhether required
namestringForm field name

SelectTrigger

PropTypeDefaultDescription
size'sm' | 'default' | 'lg''default'Trigger size
variant'default' | 'error' | 'success''default'Border style variant
errorMessagestringError message text, only displayed when variant="error"
disabledbooleanfalseWhether disabled
clearablebooleanfalseShow clear button on hover
modelValuestring | number | nullCurrent selected value (for clearable)
classstringCustom CSS class
iconClassstringCustom icon CSS class

SelectContent

PropTypeDefaultDescription
position'popper' | 'item-aligned''popper'Positioning strategy
classstringCustom CSS class

SelectItem

PropTypeDefaultDescription
valuestring— (required)Option value
disabledbooleanfalseWhether disabled
variant'default' | 'primary' | 'secondary''default'Option style variant
classstringCustom CSS class
indicatorClassstringCustom selected indicator CSS class
iconClassstringCustom check icon CSS class
iconSize'xs' | 'sm' | 'default' | 'lg' | 'xl' | '2xl''default'Check icon size

SelectValue

Displays the selected value, inherits all props from reka-ui SelectValue.

PropTypeDefaultDescription
placeholderstringPlaceholder text

SelectLabel

PropTypeDefaultDescription
classstringCustom CSS class

SelectSeparator

PropTypeDefaultDescription
classstringCustom CSS class

SelectScrollUpButton

PropTypeDefaultDescription
classstringCustom CSS class
iconSize'xs' | 'sm' | 'default' | 'lg' | 'xl' | '2xl''default'Up arrow icon size

SelectScrollDownButton

PropTypeDefaultDescription
classstringCustom CSS class
iconSize'xs' | 'sm' | 'default' | 'lg' | 'xl' | '2xl''default'Down arrow icon size

SelectTrigger Events

EventPayloadDescription
clearTriggered when clear button is clicked

Accessibility

  • Keyboard: Supports Space / Enter to open the dropdown, Escape to close, and arrow keys to navigate options
  • ARIA Attributes: Automatically manages aria-expanded, aria-haspopup, aria-activedescendant, etc.
  • Focus Management: Focus is trapped within the dropdown when open; focus returns to the trigger when closed

Brute force builds.