2022-09-30 11:39:35 -04:00
---
2022-10-25 09:18:18 -04:00
group: Widgets
title: Select
weight: 23
2022-09-30 11:39:35 -04:00
---
2022-11-02 15:42:21 -04:00
- **Name:** `select`
- **UI:** Select input
- **Data type:** `string`, `number`, `list of strings` or `list of numbers`
2022-09-30 11:39:35 -04:00
The select widget allows you to pick a string value from a dropdown menu.
2022-11-02 15:42:21 -04:00
## Widget options
2022-09-30 11:39:35 -04:00
2022-11-02 15:42:21 -04:00
For common options, see [Common widget options](/docs/widgets#common-widget-options).
2022-09-30 11:39:35 -04:00
2022-11-07 10:27:58 -05:00
| Name | Type | Default | Description |
| -------- | ----------------------------------------------------------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options | list of strings<br />\| list of numbers<br />\| object of `label` and `value` | | <ul><li>`string` or `number` - The dropdown displays the value directly</li><li>object with `label` and `value` fields - The label displays in the dropdown and the value saves in the file</li></ul> |
| default | string<br />\| number<br />\| list of string<br />\| list of number | `''` or `[]` | _Optional_. The default value for the field. Accepts a string. Defaults to an empty array if `multiple` is `true` |
| multiple | boolean | `false` | _Optional_. Allow multiple values/options to be selected |
| min | number | | _Optional_. Minimum number of items. Ignored if **multiple** is `false` |
| max | number | | _Optional_. Maximum number of items; ignored if **multiple** is `false` |
2022-09-30 11:39:35 -04:00
2022-11-02 15:42:21 -04:00
## Examples
2022-09-30 11:39:35 -04:00
2022-11-02 15:42:21 -04:00
### Options As Strings
2022-09-30 11:39:35 -04:00
2022-11-07 10:27:58 -05:00
<CodeTabs>
2022-09-30 11:39:35 -04:00
```yaml
2022-11-02 15:42:21 -04:00
name: align
label: Align Content
widget: select
options: ['left', 'center', 'right']
2022-09-30 11:39:35 -04:00
```
2022-11-07 10:27:58 -05:00
```js
name: 'align',
label: 'Align Content',
widget: 'select',
options: ['left', 'center', 'right'],
```
</CodeTabs>
2022-09-30 11:39:35 -04:00
Selecting the `center` option, will save the value as:
```yaml
2022-11-02 15:42:21 -04:00
align: center
```
### Options As Numbers
2022-11-07 10:27:58 -05:00
<CodeTabs>
2022-11-02 15:42:21 -04:00
```yaml
name: align
label: Align Content
widget: select
options: [1, 2, 3]
```
2022-11-07 10:27:58 -05:00
```js
name: 'align',
label: 'Align Content',
widget: 'select',
options: [1, 2, 3],
```
</CodeTabs>
2022-11-02 15:42:21 -04:00
Selecting the `2` option, will save the value as:
```yaml
align: 2
2022-09-30 11:39:35 -04:00
```
2022-11-02 15:42:21 -04:00
### Options As Objects
2022-09-30 11:39:35 -04:00
2022-11-07 10:27:58 -05:00
<CodeTabs>
2022-09-30 11:39:35 -04:00
```yaml
2022-11-04 17:41:12 -04:00
name: airport-code
2022-11-02 15:42:21 -04:00
label: City
widget: select
options:
- label: Chicago
value: ORD
- label: Paris
value: CDG
- label: Tokyo
value: HND
2022-09-30 11:39:35 -04:00
```
2022-11-07 10:27:58 -05:00
```js
name: 'airport-code',
label: 'City',
widget: 'select',
options: [
{
label: 'Chicago',
value: 'ORD'
},
{
label: 'Paris',
value: 'CDG'
},
{
label: 'Tokyo',
value: 'HND'
},
],
```
</CodeTabs>
2022-09-30 11:39:35 -04:00
Selecting the `Chicago` option, will save the value as:
```yaml
2022-11-02 15:42:21 -04:00
airport-code: ORD
2022-09-30 11:39:35 -04:00
```
2022-11-02 15:42:21 -04:00
### Multiple
2022-09-30 11:39:35 -04:00
2022-11-07 10:27:58 -05:00
<CodeTabs>
2022-09-30 11:39:35 -04:00
```yaml
2022-11-02 15:42:21 -04:00
name: 'tags'
label: 'Tags'
widget: 'select'
multiple: true
options: ['Design', 'UX', 'Dev']
default: ['Design']
2022-09-30 11:39:35 -04:00
```
2022-11-07 10:27:58 -05:00
```js
name: 'tags',
label: 'Tags',
widget: 'select',
multiple: true,
options: ['Design', 'UX', 'Dev'],
default: ['Design'],
```
</CodeTabs>
2022-11-02 15:42:21 -04:00
### Min and Max
2022-09-30 11:39:35 -04:00
2022-11-07 10:27:58 -05:00
<CodeTabs>
2022-09-30 11:39:35 -04:00
```yaml
2022-11-02 15:42:21 -04:00
name: 'tags'
label: 'Tags'
widget: 'select'
multiple: true
min: 1
max: 3
options: ['Design', 'UX', 'Dev']
default: ['Design']
2022-09-30 11:39:35 -04:00
```
2022-11-07 10:27:58 -05:00
```js
name: 'tags',
label: 'Tags',
widget: 'select',
multiple: true,
min: 1,
max: 3,
options: ['Design', 'UX', 'Dev'],
default: ['Design'],
```
</CodeTabs>