CLI previewInstall commands shown on this site are not released yet.

DocsComponentsForms

Select

React example follows below.
ts
import { Select } from "@grassroot/ui-react";
const regions = [
{ value: "us-east-1", label: "us-east-1 · N. Virginia" },
{ value: "us-west-2", label: "us-west-2 · Oregon" },
{ value: "eu-west-1", label: "eu-west-1 · Ireland" },
{ value: "ap-southeast-1", label: "ap-southeast-1 · Singapore" },
];
const [value, setValue] = React.useState("us-east-1");
<Select label="Region" options={regions} value={value} onValueChange={setValue} />
ts
<script setup lang="ts">
import { ref } from "vue";
import { Select } from "@grassroot/ui-vue";
const regions = [
{ value: "us-east-1", label: "us-east-1 · N. Virginia" },
{ value: "us-west-2", label: "us-west-2 · Oregon" },
{ value: "eu-west-1", label: "eu-west-1 · Ireland" },
{ value: "ap-southeast-1", label: "ap-southeast-1 · Singapore" },
];
const value = ref("us-east-1");
</script>
<template>
<Select v-model="value" label="Region" :options="regions" />
</template>
ts
import { Component, signal } from "@angular/core";
import { GrassrootSelect } from "@grassroot/ui-angular";
@Component({
selector: "app-example",
standalone: true,
imports: [GrassrootSelect],
template: `
<grassroot-select
label="Region"
[options]="regions"
[value]="value()"
(valueChange)="value.set($event)"
/>
`,
})
export class ExampleComponent {
readonly regions = [
{ value: "us-east-1", label: "us-east-1 · N. Virginia" },
{ value: "us-west-2", label: "us-west-2 · Oregon" },
{ value: "eu-west-1", label: "eu-west-1 · Ireland" },
{ value: "ap-southeast-1", label: "ap-southeast-1 · Singapore" },
];
readonly value = signal("us-east-1");
}
ts
<script lang="ts">
import { Select } from "@grassroot/ui-svelte";
const regions = [
{ value: "us-east-1", label: "us-east-1 · N. Virginia" },
{ value: "us-west-2", label: "us-west-2 · Oregon" },
{ value: "eu-west-1", label: "eu-west-1 · Ireland" },
{ value: "ap-southeast-1", label: "ap-southeast-1 · Singapore" },
];
let value = $state("us-east-1");
</script>
<Select
label="Region"
options={regions}
value={value}
onValueChange={(next) => (value = next)}
/>
ts
import { createSignal } from "solid-js";
import { Select } from "@grassroot/ui-solid";
const regions = [
{ value: "us-east-1", label: "us-east-1 · N. Virginia" },
{ value: "us-west-2", label: "us-west-2 · Oregon" },
{ value: "eu-west-1", label: "eu-west-1 · Ireland" },
{ value: "ap-southeast-1", label: "ap-southeast-1 · Singapore" },
];
export function Example() {
const [value, setValue] = createSignal("us-east-1");
return (
<>
<Select label="Region" options={regions} value={value()} onValueChange={setValue} />
</>
);
}

Installation

bash
pnpm dlx grassroot add ui/select
bash
npx grassroot@latest add ui/select
bash
yarn dlx grassroot add ui/select
bash
bunx grassroot add ui/select

API Reference

SelectProps
PropTypeDefault
optionsrequiredSelectOption[]
valuestring | undefined
defaultValuestring | undefined
onValueChange((value: string) => void) | undefined
labelstring | undefined
placeholderstring | undefined
defaultOpenRender initially open — handy for layout/stories.boolean | undefinedfalse
classNamestring | undefined
idstring | undefined