- Prop
options- Type
SegmentedOption[]- Default
- —
- Requirement
- required
- Description
- —
Docs Components Forms
Segmented
React example follows below.
Vue example follows below.
Angular example follows below.
Svelte example follows below.
Solid example follows below.
- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
const segmentedFixture = { id: "segmented", defaultValue: "grid", options: [ { value: "grid", label: "Grid" }, { value: "list", label: "List" }, { value: "board", label: "Board" }, ],} as const; import { Segmented } from "@grassroot/ui-react"; export default function SegmentedDemo() { return ( <div> <Segmented defaultValue={segmentedFixture.defaultValue} options={[...segmentedFixture.options]} /> </div> );}- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script setup lang="ts">import { ref } from "vue";const segmentedFixture = { id: "segmented", defaultValue: "grid", options: [ { value: "grid", label: "Grid" }, { value: "list", label: "List" }, { value: "board", label: "Board" }, ],} as const; import { Segmented } from "@grassroot/ui-vue";const value = ref(segmentedFixture.defaultValue);</script><template> <div><Segmented v-model="value" :options="[...segmentedFixture.options]" /></div></template>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
import { Component } from "@angular/core";const segmentedFixture = { id: "segmented", defaultValue: "grid", options: [ { value: "grid", label: "Grid" }, { value: "list", label: "List" }, { value: "board", label: "Board" }, ],} as const; import { GrassrootSegmented } from "@grassroot/ui-angular";@Component({ selector: "app-segmented-demo", standalone: true, imports: [GrassrootSegmented], template: `<div> <grassroot-segmented [options]="fixture.options" [value]="fixture.defaultValue" /> </div>`,})export class SegmentedDemoComponent { protected readonly fixture = segmentedFixture;}export default SegmentedDemoComponent;- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script lang="ts"> const segmentedFixture = { id: "segmented", defaultValue: "grid", options: [ { value: "grid", label: "Grid" }, { value: "list", label: "List" }, { value: "board", label: "Board" }, ], } as const; import { Segmented } from "@grassroot/ui-svelte";</script> <div> <Segmented options={[...segmentedFixture.options]} defaultValue={segmentedFixture.defaultValue} /></div>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
/** @jsxImportSource solid-js */const segmentedFixture = { id: "segmented", defaultValue: "grid", options: [ { value: "grid", label: "Grid" }, { value: "list", label: "List" }, { value: "board", label: "Board" }, ],} as const; import { Segmented } from "@grassroot/ui-solid";export default function SegmentedDemo() { return ( <div> <Segmented options={[...segmentedFixture.options]} defaultValue={segmentedFixture.defaultValue} /> </div> );}Installation
API Reference
Import
import { Segmented } from "@grassroot/ui-react";
Props
Prop
Type
Default
Requirement
Description
optionsSegmentedOption[]—
required
—
namestring | undefined—
optional
Shared radio group name.
valuestring | undefined—
optional
—
defaultValuestring | undefined—
optional
—
onValueChange((value: string) => void) | undefined—
optional
—
classNamestring | undefined—
optional
—
- Prop
name- Type
string | undefined- Default
- —
- Requirement
- optional
- Description
- Shared radio group name.
- Prop
value- Type
string | undefined- Default
- —
- Requirement
- optional
- Description
- —
- Prop
defaultValue- Type
string | undefined- Default
- —
- Requirement
- optional
- Description
- —
- Prop
onValueChange- Type
((value: string) => void) | undefined- Default
- —
- Requirement
- optional
- Description
- —
- Prop
className- Type
string | undefined- Default
- —
- Requirement
- optional
- Description
- —
Events
| Event | Payload |
|---|---|
onValueChange | ((value: string) => void) | undefined |
Import
import { ref } from "vue";
import { Segmented } from "@grassroot/ui-vue";
Props
Prop
Type
Default
Requirement
optionsSegmentedOption[]—
required
namestring | undefined—
optional
modelValuestring | undefined—
optional
- Prop
options- Type
SegmentedOption[]- Default
- —
- Requirement
- required
- Prop
name- Type
string | undefined- Default
- —
- Requirement
- optional
- Prop
modelValue- Type
string | undefined- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
update:modelValue | [value: string] |
Import
import { Component } from "@angular/core";
import { GrassrootSegmented } from "@grassroot/ui-angular";
Props
Prop
Type
Default
Requirement
optionsreadonly SegmentedOption[]—
required
namestring—
optional
valuestring—
optional
- Prop
options- Type
readonly SegmentedOption[]- Default
- —
- Requirement
- required
- Prop
name- Type
string- Default
- —
- Requirement
- optional
- Prop
value- Type
string- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
valueChange | string |
Import
import { Segmented } from "@grassroot/ui-svelte";
Props
Prop
Type
Default
Requirement
optionsSegmentedOption[]—
required
namestring—
optional
valuestring—
optional
defaultValuestring—
optional
onValueChange(value: string) => void—
optional
classNamestring—
optional
- Prop
options- Type
SegmentedOption[]- Default
- —
- Requirement
- required
- Prop
name- Type
string- Default
- —
- Requirement
- optional
- Prop
value- Type
string- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string- Default
- —
- Requirement
- optional
- Prop
onValueChange- Type
(value: string) => void- Default
- —
- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onValueChange | (value: string) => void |
Import
import { Segmented } from "@grassroot/ui-solid";
Props
Prop
Type
Default
Requirement
optionsSegmentedOption[]—
required
namestring—
optional
valuestring—
optional
defaultValuestring—
optional
onValueChange(value: string) => void—
optional
classNamestring—
optional
- Prop
options- Type
SegmentedOption[]- Default
- —
- Requirement
- required
- Prop
name- Type
string- Default
- —
- Requirement
- optional
- Prop
value- Type
string- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string- Default
- —
- Requirement
- optional
- Prop
onValueChange- Type
(value: string) => void- Default
- —
- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onValueChange | (value: string) => void |