Saltearse al contenido

Select

Esta página aún no está disponible en tu idioma.

A custom select element that just works.

  • Option 1
  • Option 2
  • Option 3

You can set a default value using the defaultValue prop:

  • Option 1
  • Option 2
  • Option 3

You can use the isRequired prop to mark the select input as required. This will also add a red * to the label.

If you need to access the element’s value later on, you can pass the name prop. It will then appear in any FormData you construct. If no name is set, a random one is generated for the component.

Additionally, you can either disable the entire select input by using the disabled prop, or disable individual options by adding disabled: true to the option you want to disable:

SelectFormExample.astro
---
import { Select } from '@studiocms/ui/components';
---
<Select
label='Select Element'
defaultValue='opt-1'
isRequired
disabled
name='select-element'
options={[
// ...
{
label: 'Option X',
value: 'opt-x',
disabled: true
},
// ...
]}
/>

Normally, the input has a minimum width and extends as needed. You can force it to take up the entire width of its parent container by setting the fullWidth prop to true:

  • Option 1
  • Option 2
  • Option 3

You can adjust the placeholder shown in the select by passing the placeholder prop:

  • Option 1
  • Option 2
  • Option 3