// Basic select
const html = select({
name: 'country',
options: [
{ value: 'us', label: 'United States' },
{ value: 'uk', label: 'United Kingdom' },
{ value: 'ca', label: 'Canada' },
],
});
// With label and placeholder
const labeled = select({
name: 'role',
label: 'User Role',
placeholder: 'Select a role',
options: [
{ value: 'admin', label: 'Administrator' },
{ value: 'editor', label: 'Editor' },
{ value: 'viewer', label: 'Viewer' },
],
});
// With option groups
const grouped = select({
name: 'timezone',
label: 'Timezone',
optionGroups: [
{
label: 'North America',
options: [
{ value: 'est', label: 'Eastern Time' },
{ value: 'pst', label: 'Pacific Time' },
],
},
{
label: 'Europe',
options: [
{ value: 'gmt', label: 'GMT' },
{ value: 'cet', label: 'Central European' },
],
},
],
});
// Pre-selected value
const preselected = select({
name: 'status',
value: 'active',
options: [
{ value: 'active', label: 'Active' },
{ value: 'inactive', label: 'Inactive' },
],
});