- Prop
value- Type
string- Default
- —
- Requirement
- required
- Description
- —
Docs Components Forms
Radio
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
import { Radio } from "@grassroot/ui-react";import * as React from "react";const radioFixture = { id: "radio", name: "engagement", value: "embedded-team", options: [ { id: "embedded-team", label: "Embedded team", value: "embedded-team" }, { id: "fixed-scope-project", label: "Fixed-scope project", value: "fixed-scope-project" }, { id: "advisory-fractional", label: "Advisory / fractional", value: "advisory-fractional" }, ],} satisfies { id: string; name: string; value: string; options: Array<{ id: string; label: string; value: string }>;}; export default function RadioDemo() { const [value, setValue] = React.useState(radioFixture.value); return ( <div className="flex flex-col gap-3.5"> {radioFixture.options.map((option) => ( <Radio key={option.id} name={`${radioFixture.name}-react`} value={option.value} checked={value === option.value} label={option.label} onChange={(event) => setValue(event.target.value)} /> ))} </div> );}- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script setup lang="ts">import { Radio } from "@grassroot/ui-vue";import { ref } from "vue";const radioFixture = { id: "radio", name: "engagement", value: "embedded-team", options: [ { id: "embedded-team", label: "Embedded team", value: "embedded-team" }, { id: "fixed-scope-project", label: "Fixed-scope project", value: "fixed-scope-project" }, { id: "advisory-fractional", label: "Advisory / fractional", value: "advisory-fractional" }, ],} satisfies { id: string; name: string; value: string; options: Array<{ id: string; label: string; value: string }>;}; const value = ref(radioFixture.value);function onChange(event: Event) { value.value = (event.target as HTMLInputElement).value;}</script> <template> <div class="flex flex-col gap-3.5"> <Radio v-for="option in radioFixture.options" :key="option.id" :checked="value === option.value" :name="`${radioFixture.name}-vue`" :value="option.value" @change="onChange" > <template #label>{{ option.label }}</template> </Radio> </div></template>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
import { Component, signal } from "@angular/core";const radioFixture = { id: "radio", name: "engagement", value: "embedded-team", options: [ { id: "embedded-team", label: "Embedded team", value: "embedded-team" }, { id: "fixed-scope-project", label: "Fixed-scope project", value: "fixed-scope-project" }, { id: "advisory-fractional", label: "Advisory / fractional", value: "advisory-fractional" }, ],} satisfies { id: string; name: string; value: string; options: Array<{ id: string; label: string; value: string }>;}; import { GrassrootRadio } from "@grassroot/ui-angular"; @Component({ selector: "app-radio-demo", standalone: true, imports: [GrassrootRadio], host: { style: "display: contents" }, template: ` <div class="flex flex-col gap-3.5"> @for (option of fixture.options; track option.id) { <grassroot-radio [name]="name" [value]="option.value" [checked]="value() === option.value" [label]="option.label" (change)="onChange($event)" /> } </div> `,})export class RadioDemoComponent { protected readonly fixture = radioFixture; protected readonly name = `${radioFixture.name}-angular`; protected readonly value = signal(radioFixture.value); protected onChange(event: Event): void { this.value.set((event.target as HTMLInputElement).value); }} export default RadioDemoComponent;- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script lang="ts"> import { Radio } from "@grassroot/ui-svelte"; const radioFixture = { id: "radio", name: "engagement", value: "embedded-team", options: [ { id: "embedded-team", label: "Embedded team", value: "embedded-team" }, { id: "fixed-scope-project", label: "Fixed-scope project", value: "fixed-scope-project" }, { id: "advisory-fractional", label: "Advisory / fractional", value: "advisory-fractional" }, ], } satisfies { id: string; name: string; value: string; options: Array<{ id: string; label: string; value: string }>; }; let value = $state(radioFixture.value); function onChange(event: Event) { value = (event.target as HTMLInputElement).value; }</script> <div class="flex flex-col gap-3.5"> {#each radioFixture.options as option (option.id)} <Radio checked={value === option.value} name={`${radioFixture.name}-svelte`} value={option.value} label={option.label} {onChange} /> {/each}</div>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
/** @jsxImportSource solid-js */import { Radio } from "@grassroot/ui-solid";import { createSignal } from "solid-js";const radioFixture = { id: "radio", name: "engagement", value: "embedded-team", options: [ { id: "embedded-team", label: "Embedded team", value: "embedded-team" }, { id: "fixed-scope-project", label: "Fixed-scope project", value: "fixed-scope-project" }, { id: "advisory-fractional", label: "Advisory / fractional", value: "advisory-fractional" }, ],} satisfies { id: string; name: string; value: string; options: Array<{ id: string; label: string; value: string }>;}; export default function RadioDemo() { const [value, setValue] = createSignal(radioFixture.value); return ( <div class="flex flex-col gap-3.5"> {radioFixture.options.map((option) => ( <Radio name={`${radioFixture.name}-solid`} value={option.value} checked={value() === option.value} label={option.label} onChange={(event) => setValue((event.target as HTMLInputElement).value)} /> ))} </div> );}Installation
API Reference
Import
import { Radio } from "@grassroot/ui-react";
import * as React from "react";
Props
Prop
Type
Default
Requirement
Description
valuestring—
required
—
toneTone | undefined"accent"optional
Brand colour of the selected ring + dot.
- Prop
tone- Type
Tone | undefined- Default
"accent"- Requirement
- optional
- Description
- Brand colour of the selected ring + dot.
Content regions
label
Native attributes
Standard DOM and ARIA attributes not listed above spread onto the root element.
Import
import { Radio } from "@grassroot/ui-vue";
import { ref } from "vue";
Props
Prop
Type
Default
Requirement
checkedboolean—
optional
valuestring—
required
disabledboolean—
optional
namestring—
optional
tone"accent" | "amber" | "teal" | "indigo""accent"optional
- Prop
checked- Type
boolean- Default
- —
- Requirement
- optional
- Prop
value- Type
string- Default
- —
- Requirement
- required
- Prop
disabled- Type
boolean- Default
- —
- Requirement
- optional
- Prop
name- Type
string- Default
- —
- Requirement
- optional
- Prop
tone- Type
"accent" | "amber" | "teal" | "indigo"- Default
"accent"- Requirement
- optional
Events
| Event | Payload |
|---|---|
change | (_event: Event) => true |
Content regions
defaultlabel
Import
import { Component, signal } from "@angular/core";
import { GrassrootRadio } from "@grassroot/ui-angular";
Props
Prop
Type
Default
Requirement
valuestring—
required
checkedbooleanfalseoptional
namestring—
optional
disabledbooleanfalseoptional
labelstring—
optional
tone"accent" | "amber" | "teal" | "indigo""accent"optional
- Prop
value- Type
string- Default
- —
- Requirement
- required
- Prop
checked- Type
boolean- Default
false- Requirement
- optional
- Prop
name- Type
string- Default
- —
- Requirement
- optional
- Prop
disabled- Type
boolean- Default
false- Requirement
- optional
- Prop
label- Type
string- Default
- —
- Requirement
- optional
- Prop
tone- Type
"accent" | "amber" | "teal" | "indigo"- Default
"accent"- Requirement
- optional
Content regions
defaultlabel
Import
import { Radio } from "@grassroot/ui-svelte";
Props
Prop
Type
Default
Requirement
checkedbooleanfalseoptional
valuestring—
required
disabledbooleanfalseoptional
namestring—
optional
toneTone"accent"optional
onChange(event: Event) => void—
optional
- Prop
checked- Type
boolean- Default
false- Requirement
- optional
- Prop
value- Type
string- Default
- —
- Requirement
- required
- Prop
disabled- Type
boolean- Default
false- Requirement
- optional
- Prop
name- Type
string- Default
- —
- Requirement
- optional
- Prop
tone- Type
Tone- Default
"accent"- Requirement
- optional
- Prop
onChange- Type
(event: Event) => void- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onChange | (event: Event) => void |
Content regions
childrenlabel
Import
import { Radio } from "@grassroot/ui-solid";
import { createSignal } from "solid-js";
Props
Prop
Type
Default
Requirement
valuestring—
required
toneRadioTone—
optional
classNamestring—
optional
- Prop
value- Type
string- Default
- —
- Requirement
- required
- Prop
tone- Type
RadioTone- Default
- —
- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
Content regions
childrenlabel
Native attributes
Standard DOM and ARIA attributes not listed above spread onto the root element.