Skip to content

Select

Select

A dropdown selection component with validation states and customization options.

Import

import { Select } from '@primitivekit/react';

Basic Usage

<Select
  label="Country"
  options={[
    { value: 'us', label: 'United States' },
    { value: 'uk', label: 'United Kingdom' },
    { value: 'ca', label: 'Canada' },
  ]}
  placeholder="Select a country"
/>

Variants

// Default variant
<Select variant="default" options={options} />

// Filled variant
<Select variant="filled" options={options} />

// Flushed variant
<Select variant="flushed" options={options} />

// Unstyled variant
<Select variant="unstyled" options={options} />

Sizes

<Select size="small" options={options} />
<Select size="medium" options={options} />
<Select size="large" options={options} />

Validation States

// Error state
<Select 
  label="Country"
  options={options}
  error="Please select a country"
/>

// Success state
<Select 
  label="Country"
  options={options}
  success="Valid selection"
/>

// Warning state
<Select 
  label="Country"
  options={options}
  warning="This option may have limitations"
/>

With Disabled Options

<Select
  label="Status"
  options={[
    { value: 'active', label: 'Active' },
    { value: 'pending', label: 'Pending' },
    { value: 'archived', label: 'Archived', disabled: true },
  ]}
/>

Controlled Select

import { useState } from 'react';

function ControlledSelect() {
  const [value, setValue] = useState('');

  return (
    <Select
      label="Country"
      value={value}
      onChange={(e) => setValue(e.target.value)}
      options={[
        { value: 'us', label: 'United States' },
        { value: 'uk', label: 'United Kingdom' },
        { value: 'ca', label: 'Canada' },
      ]}
    />
  );
}

Props

PropTypeDefaultDescription
optionsSelectOption[]requiredArray of options
size'small' | 'medium' | 'large''medium'Select size
variant'default' | 'filled' | 'flushed' | 'unstyled''default'Visual style
state'default' | 'error' | 'success' | 'warning''default'Validation state
labelstring-Label text
helperTextstring-Helper text
errorstring-Error message
successstring-Success message
warningstring-Warning message
fullWidthbooleanfalseFull width
placeholderstring-Placeholder text
valuestring | number-Controlled value
defaultValuestring | number-Default value
onChangefunction-Change handler
disabledbooleanfalseDisable select
requiredbooleanfalseRequired field

SelectOption Type

interface SelectOption {
  value: string | number;
  label: string;
  disabled?: boolean;
}

Customization

<Select
  options={options}
  style={{
    '--select-bg-color': 'rgba(240, 240, 255, 1)',
    '--select-border-color': 'rgba(100, 100, 200, 1)',
    '--select-border-radius': '12px',
    '--select-padding-x': '16px',
    '--select-font-size': '16px',
  }}
/>

Accessibility

  • ✅ Proper label association
  • ✅ ARIA attributes for states
  • ✅ Keyboard navigation
  • ✅ Screen reader support

Related Components

  • Input - Text input
  • Checkbox - Multiple selection
  • Radio - Single selection from visible options