Docs Components Forms

Radio

React example follows below.
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>
);
}
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>
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;
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>
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
value
string
—
required
—
tone
Tone | undefined
"accent"
optional
Brand colour of the selected ring + dot.
Prop
value
Type
string
Default
—
Requirement
required
Description
—
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
checked
boolean
—
optional
value
string
—
required
disabled
boolean
—
optional
name
string
—
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

EventPayload
change(_event: Event) => true

Content regions

  • default
  • label

Import

import { Component, signal } from "@angular/core";
import { GrassrootRadio } from "@grassroot/ui-angular";

Props

Prop
Type
Default
Requirement
value
string
—
required
checked
boolean
false
optional
name
string
—
optional
disabled
boolean
false
optional
label
string
—
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

  • default
  • label

Import

import { Radio } from "@grassroot/ui-svelte";

Props

Prop
Type
Default
Requirement
checked
boolean
false
optional
value
string
—
required
disabled
boolean
false
optional
name
string
—
optional
tone
Tone
"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

EventPayload
onChange(event: Event) => void

Content regions

  • children
  • label

Import

import { Radio } from "@grassroot/ui-solid";
import { createSignal } from "solid-js";

Props

Prop
Type
Default
Requirement
value
string
—
required
tone
RadioTone
—
optional
className
string
—
optional
Prop
value
Type
string
Default
—
Requirement
required
Prop
tone
Type
RadioTone
Default
—
Requirement
optional
Prop
className
Type
string
Default
—
Requirement
optional

Content regions

  • children
  • label

Native attributes

Standard DOM and ARIA attributes not listed above spread onto the root element.