- Prop
options- Type
ToggleGroupOption[]- Default
- —
- Requirement
- required
Docs Components Primitives
ToggleGroup
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 toggleGroupFixture = { id: "toggle-group", single: { defaultValue: "left", options: [ { value: "left", label: "Left" }, { value: "center", label: "Center" }, { value: "right", label: "Right", disabled: true }, ], }, multiple: { defaultValue: ["bold"], options: [ { value: "bold", label: "Bold" }, { value: "italic", label: "Italic" }, { value: "underline", label: "Underline" }, ], },} as const; import { ToggleGroup } from "@grassroot/ui-react"; export default function ToggleGroupDemo() { return ( <div> <ToggleGroup options={[...toggleGroupFixture.single.options]} defaultValue={toggleGroupFixture.single.defaultValue} /> <ToggleGroup type="multiple" options={[...toggleGroupFixture.multiple.options]} defaultValue={[...toggleGroupFixture.multiple.defaultValue]} /> </div> );}- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script setup lang="ts">import { ref } from "vue";const toggleGroupFixture = { id: "toggle-group", single: { defaultValue: "left", options: [ { value: "left", label: "Left" }, { value: "center", label: "Center" }, { value: "right", label: "Right", disabled: true }, ], }, multiple: { defaultValue: ["bold"], options: [ { value: "bold", label: "Bold" }, { value: "italic", label: "Italic" }, { value: "underline", label: "Underline" }, ], },} as const; import { ToggleGroup } from "@grassroot/ui-vue";const single = ref(toggleGroupFixture.single.defaultValue);const multiple = ref([...toggleGroupFixture.multiple.defaultValue]);</script><template> <div> <ToggleGroup v-model="single" :options="[...toggleGroupFixture.single.options]" /><ToggleGroup v-model="multiple" type="multiple" :options="[...toggleGroupFixture.multiple.options]" /> </div></template>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
import { Component } from "@angular/core";const toggleGroupFixture = { id: "toggle-group", single: { defaultValue: "left", options: [ { value: "left", label: "Left" }, { value: "center", label: "Center" }, { value: "right", label: "Right", disabled: true }, ], }, multiple: { defaultValue: ["bold"], options: [ { value: "bold", label: "Bold" }, { value: "italic", label: "Italic" }, { value: "underline", label: "Underline" }, ], },} as const; import { GrassrootToggleGroup } from "@grassroot/ui-angular";@Component({ selector: "app-toggle-group-demo", standalone: true, imports: [GrassrootToggleGroup], template: `<div> <grassroot-toggle-group [options]="fixture.single.options" [defaultValue]="fixture.single.defaultValue" /><grassroot-toggle-group type="multiple" [options]="fixture.multiple.options" [defaultValue]="fixture.multiple.defaultValue" /> </div>`,})export class ToggleGroupDemoComponent { protected readonly fixture = toggleGroupFixture;}export default ToggleGroupDemoComponent;- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script lang="ts"> const toggleGroupFixture = { id: "toggle-group", single: { defaultValue: "left", options: [ { value: "left", label: "Left" }, { value: "center", label: "Center" }, { value: "right", label: "Right", disabled: true }, ], }, multiple: { defaultValue: ["bold"], options: [ { value: "bold", label: "Bold" }, { value: "italic", label: "Italic" }, { value: "underline", label: "Underline" }, ], }, } as const; import { ToggleGroup } from "@grassroot/ui-svelte";</script> <div> <ToggleGroup options={[...toggleGroupFixture.single.options]} defaultValue={toggleGroupFixture.single.defaultValue} /><ToggleGroup type="multiple" options={[...toggleGroupFixture.multiple.options]} defaultValue={[...toggleGroupFixture.multiple.defaultValue]} /></div>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
/** @jsxImportSource solid-js */const toggleGroupFixture = { id: "toggle-group", single: { defaultValue: "left", options: [ { value: "left", label: "Left" }, { value: "center", label: "Center" }, { value: "right", label: "Right", disabled: true }, ], }, multiple: { defaultValue: ["bold"], options: [ { value: "bold", label: "Bold" }, { value: "italic", label: "Italic" }, { value: "underline", label: "Underline" }, ], },} as const; import { ToggleGroup } from "@grassroot/ui-solid";export default function ToggleGroupDemo() { return ( <div> <ToggleGroup options={[...toggleGroupFixture.single.options]} defaultValue={toggleGroupFixture.single.defaultValue} /> <ToggleGroup type="multiple" options={[...toggleGroupFixture.multiple.options]} defaultValue={[...toggleGroupFixture.multiple.defaultValue]} /> </div> );}Installation
API Reference
Import
import { ToggleGroup } from "@grassroot/ui-react";
Props
Prop
Type
Default
Requirement
optionsToggleGroupOption[]—
required
classNamestring | undefined—
optional
type"single" | "multiple" | undefined—
optional
valuestring | string[] | undefined—
optional
defaultValuestring | string[] | undefined—
optional
onValueChange((value: string) => void) | ((value: string[]) => void) | undefined—
optional
- Prop
className- Type
string | undefined- Default
- —
- Requirement
- optional
- Prop
type- Type
"single" | "multiple" | undefined- Default
- —
- Requirement
- optional
- Prop
value- Type
string | string[] | undefined- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string | string[] | undefined- Default
- —
- Requirement
- optional
- Prop
onValueChange- Type
((value: string) => void) | ((value: string[]) => void) | undefined- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onValueChange | ((value: string) => void) | ((value: string[]) => void) | undefined |
Import
import { ref } from "vue";
import { ToggleGroup } from "@grassroot/ui-vue";
Props
Prop
Type
Default
Requirement
optionsToggleGroupOption[]—
required
type"single" | "multiple" | undefined"single"optional
modelValuestring | string[] | undefined—
optional
- Prop
options- Type
ToggleGroupOption[]- Default
- —
- Requirement
- required
- Prop
type- Type
"single" | "multiple" | undefined- Default
"single"- Requirement
- optional
- Prop
modelValue- Type
string | string[] | undefined- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
update:modelValue | [value: string | string[]] |
Import
import { Component } from "@angular/core";
import { GrassrootToggleGroup } from "@grassroot/ui-angular";
Props
Prop
Type
Default
Requirement
optionsreadonly ToggleGroupOption[]—
required
type"single" | "multiple""single"optional
valuestring | string[]—
optional
defaultValuestring | string[]—
optional
- Prop
options- Type
readonly ToggleGroupOption[]- Default
- —
- Requirement
- required
- Prop
type- Type
"single" | "multiple"- Default
"single"- Requirement
- optional
- Prop
value- Type
string | string[]- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string | string[]- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
valueChange | string | string[] |
Import
import { ToggleGroup } from "@grassroot/ui-svelte";
Props
Prop
Type
Default
Requirement
optionsToggleGroupOption[]—
required
type"single" | "multiple""single"optional
valuestring | string[]—
optional
defaultValuestring | string[]—
optional
onValueChange(value: string | string[]) => void—
optional
classNamestring—
optional
- Prop
options- Type
ToggleGroupOption[]- Default
- —
- Requirement
- required
- Prop
type- Type
"single" | "multiple"- Default
"single"- Requirement
- optional
- Prop
value- Type
string | string[]- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string | string[]- Default
- —
- Requirement
- optional
- Prop
onValueChange- Type
(value: string | string[]) => void- Default
- —
- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onValueChange | (value: string | string[]) => void |
Import
import { ToggleGroup } from "@grassroot/ui-solid";
Props
Prop
Type
Default
Requirement
optionsToggleGroupOption[]—
required
classNamestring—
optional
type"single" | "multiple" | undefined"single"optional
valuestring | string[] | undefined—
optional
defaultValuestring | string[] | undefined—
optional
onValueChange((value: string) => void) | ((value: string[]) => void) | undefined—
optional
- Prop
options- Type
ToggleGroupOption[]- Default
- —
- Requirement
- required
- Prop
className- Type
string- Default
- —
- Requirement
- optional
- Prop
type- Type
"single" | "multiple" | undefined- Default
"single"- Requirement
- optional
- Prop
value- Type
string | string[] | undefined- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string | string[] | undefined- Default
- —
- Requirement
- optional
- Prop
onValueChange- Type
((value: string) => void) | ((value: string[]) => void) | undefined- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onValueChange | ((value: string) => void) | ((value: string[]) => void) | undefined |