Select

A fully accessible select component that allows users to choose one option from a list. Built with Headless UI for robust functionality.

Props

PropTypeDefaultDescription
optionsarray-Array of option objects. Each must have `id` and `name`.
selectedobject-The currently selected option object from the `options` array.
setSelectedfunction-The state setter function to update the selected option.
labelstring-An optional label displayed above the select input.

Examples

Basic Select

A standard select input with a label.

Assigned to
import { useState } from 'react';
import Select from '@/components/Select';

const people = [
  { id: 1, name: 'Wade Cooper' },
  { id: 2, name: 'Arlene Mccoy' },
  // ... more options
];

export default function MyComponent() {
  const [selected, setSelected] = useState(people[0]);

  return (
    <Select 
      label="Assigned to"
      options={people}
      selected={selected}
      setSelected={setSelected}
    />
  );
}