# Select

> Organism — orn-ui

> ⚠️ Requires <UIProvider>: This component (like every orn-ui component) must render inside a <UIProvider> ancestor, or it throws at runtime. See https://orn-ui-docs.vercel.app/getting-started.md

> Runs on Expo SDK 54, 55, 56 and 57, and on bare React Native >=0.81 with react >=19.1. No native modules — works in Expo Go, no prebuild.

## Installation

Install just this component (copies the source into your project, no npm dependency)
```bash
npx orn-ui add select
```

Or install the whole package and import it
```tsx
pnpm add orn-ui
import { Select } from 'orn-ui/select';
```

Depends on: core (theme + icons)

## Variants

### Default

```tsx
<Select label="Payment method" options={OPTIONS} selectedValue={value} onSelect={setValue} />
```

### Required

```tsx
<Select label="Payment method" required options={OPTIONS} selectedValue={required} onSelect={setRequired} />
```

### Error

```tsx
<Select label="Payment method" options={OPTIONS} selectedValue={undefined} onSelect={() => {}} error="Required" />
```

### Loading

```tsx
<Select label="Payment method" options={OPTIONS} selectedValue={undefined} onSelect={() => {}} isLoading />
```

## Full demo source

```tsx
const variants: VariantDef[] = [
  { label: 'Default', content: <Select label="Payment method" options={OPTIONS} selectedValue={value} onSelect={setValue} /> },
  {
    label: 'Required',
    content: <Select label="Payment method" required options={OPTIONS} selectedValue={required} onSelect={setRequired} />,
  },
  {
    label: 'Error',
    content: <Select label="Payment method" options={OPTIONS} selectedValue={undefined} onSelect={() => {}} error="Required" />,
  },
  {
    label: 'Loading',
    content: <Select label="Payment method" options={OPTIONS} selectedValue={undefined} onSelect={() => {}} isLoading />,
  },
];
return <VariantList variants={variants} />;
```

## Props

| Name | Type | Default | Description |
|---|---|---|---|
| `label?` | `string` | — | — |
| `required?` | `boolean` | false | — |
| `options` | `SelectOption<T>[]` | — | — |
| `selectedValue` | `string \| number` | — | — |
| `onSelect` | `(value: T) => void` | — | — |
| `placeholder?` | `string` | — | — |
| `error?` | `string` | — | — |
| `isLoading?` | `boolean` | false | — |
| `disabled?` | `boolean` | false | — |
| `searchable?` | `boolean` | false | Adds a search box inside the dropdown. |
| `searchPlaceholder?` | `string` | — | — |
| `maxHeight?` | `number` | 280 | Maximum height of the dropdown, if the available space allows it. |
| `onOpenChange?` | `(open: boolean) => void` | — | — |
| `containerStyle?` | `StyleProp<ViewStyle>` | — | — |
