intro

Select

A foundational dropdown selection atom styled with Curva & Concreto principles.

Select

The Select component provides a native HTML dropdown menu styled to match the TextInput atom. It is preferred over complex JS-based custom selects for standard data entry due to its superior native accessibility and smaller bundle size.

Choose a state
Please select a valid option.
State selected successfully!

Usage

Like TextInput, Select is designed to be wrapped by a FormField component.

<script>
import { FormField, Select } from 'cobogo';
const options = [
{ value: 'pf', label: 'Pessoa Física (CPF)' },
{ value: 'pj', label: 'Pessoa Jurídica (CNPJ)' }
];
let documentType = $state('');
</script>
<FormField label="Document Type" htmlFor="doc-type-select">
{#snippet children(props)}
<Select {options} bind:value={documentType} placeholder="Select type..." {...props} />
{/snippet}
</FormField>

Validation States

Validation states use the exact same color mapping as TextInput: --vermelho-soft/--vermelho for errors, and --verde-soft/--verde for success. The custom chevron icon is also automatically tinted to match the current validation state.

Props

PropTypeDefaultDescription
valuestring''The bindable value of the selected option.
optionsArray<{value: string, label: string}>[]The array of available options.
placeholderstringundefinedThe default unselectable placeholder option text.
disabledbooleanfalseWhether the select is disabled.
invalidbooleanfalseWhether the select is in an invalid state.
validbooleanfalseWhether the select is in a valid state.
size'sm' | 'md' | 'lg''md'The size variant of the select.