---
component: zui-select
package: "@zywave/zui-select"
elements: ["zui-select"]
---

<!-- Generated by scripts/node/generate-llm-docs.mjs from packages/components/zui-select/dist/custom-elements.json. Do not edit; re-run npm run docs:llm. -->

# `<zui-select>`

## Examples

### Basic select

```html
<zui-select>
  <zui-option value="monthly">Monthly</zui-option>
  <zui-option value="quarterly">Quarterly</zui-option>
  <zui-option value="annually">Annually</zui-option>
</zui-select>
```

### Select with placeholder

```html
<zui-select placeholder="Select a payment frequency">
  <zui-option value="monthly">Monthly</zui-option>
  <zui-option value="quarterly">Quarterly</zui-option>
  <zui-option value="annually">Annually</zui-option>
</zui-select>
```

### Pre-selected option

```html
<zui-select placeholder="Select a payment frequency" value="quarterly">
  <zui-option value="monthly">Monthly</zui-option>
  <zui-option value="quarterly">Quarterly</zui-option>
  <zui-option value="annually">Annually</zui-option>
</zui-select>
```

### Disabled select

```html
<zui-select placeholder="Select a payment frequency" value="quarterly" disabled>
  <zui-option value="monthly">Monthly</zui-option>
  <zui-option value="quarterly">Quarterly</zui-option>
  <zui-option value="annually">Annually</zui-option>
</zui-select>
```

### Disabled option

```html
<zui-select placeholder="Select a payment frequency">
  <zui-option value="monthly">Monthly</zui-option>
  <zui-option value="quarterly">Quarterly</zui-option>
  <zui-option value="annually" disabled>Annually</zui-option>
</zui-select>
```

### Multi-select

```html
<zui-select multiple>
  <zui-option value="finance">Finance</zui-option>
  <zui-option value="human-resources">Human resources</zui-option>
  <zui-option value="operations">Operations</zui-option>
  <zui-option value="sales">Sales</zui-option>
</zui-select>
```

### Multi-select with placeholder

```html
<zui-select placeholder="Select departments" multiple>
  <zui-option value="finance">Finance</zui-option>
  <zui-option value="human-resources">Human resources</zui-option>
  <zui-option value="operations">Operations</zui-option>
  <zui-option value="sales">Sales</zui-option>
</zui-select>
```

### Multi-select with disabled options

```html
<zui-select placeholder="Select departments" multiple>
  <zui-option value="finance" disabled>Finance</zui-option>
  <zui-option value="human-resources">Human resources</zui-option>
  <zui-option value="operations" disabled>Operations</zui-option>
  <zui-option value="sales">Sales</zui-option>
</zui-select>
```

### Disabled multi-select

```html
<zui-select placeholder="Select departments" multiple disabled>
  <zui-option value="finance">Finance</zui-option>
  <zui-option value="human-resources">Human resources</zui-option>
  <zui-option value="operations">Operations</zui-option>
  <zui-option value="sales">Sales</zui-option>
</zui-select>
```

### Select custom styles with shadow part

Use ::part(control) to style the select; this example slows the focus border transition.

```html
<style>
  .custom-select::part(control) {
    transition:
      border 1000ms ease-in-out,
      box-shadow 1000ms ease-in-out;
  }
</style>
<zui-select class="custom-select" placeholder="Select a payment frequency">
  <zui-option value="monthly">Monthly</zui-option>
  <zui-option value="quarterly">Quarterly</zui-option>
  <zui-option value="annually">Annually</zui-option>
</zui-select>
```

## API reference

If this section and the content above disagree, this section is correct.

Class: `ZuiSelectElement`

A Basic select, best for shorter declaratively created lists, by passing in `<zui-option>`'s.

### Attributes

- `placeholder` (default: `null`): `string | undefined`. Rendered as a selectable empty-value option at the top of the list; when `required` is set, this option is hidden and disabled so users must choose a real value
- `name` (default: `null`): `string | null`. The name of this element that is associated with form submission
- `disabled` (default: `false`): `boolean`. Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
- `readonly` (default: `false`): `boolean`. Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
- `autofocus` (default: `false`): `boolean`. If true, this element will be focused when connected to the document
- `multiple` (default: `false`): `boolean`. (deprecated): use zui-select-dropdown or other similar components
- `selected` (reflects): `string`. (deprecated): use `value` instead
- `value` (default: `''`): `string`. The currently selected item
- `required` (default: `false`): `boolean`. Whether a selection is required

### Properties

- `selectedIndex` (readonly): `number`. Index, numerical value for selected option
- `name` (default: `null`): `string | null`. The name of this element that is associated with form submission
- `disabled` (default: `false`): `boolean`. Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
- `readOnly` (default: `false`): `boolean`. Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
- `autofocus` (default: `false`): `boolean`. If true, this element will be focused when connected to the document

### Methods

- `item(index: number): ZuiOptionElement | null`. Return a `ZuiOptionElement` based upon number index value passed in

### Events

- `change`: `CustomEvent<string>`. Event fires when a change to select occurs; `event.detail` is the selected value string

### CSS parts

- `control`. For custom styling of the `select` element; this is exposed as a CSS shadow part and can be accessed with `::part(control)`
