Radio
A single-choice group like Select, but every option stays visible with a ● / ○ marker. Arrow keys (or j/k) move the selection.
Import
import { Radio } from '@sigx/terminal';
import type { RadioOption } from '@sigx/terminal';
Usage
/** @jsxImportSource @sigx/terminal */
import { component, defineApp, signal, Radio } from '@sigx/terminal';
import type { RadioOption } from '@sigx/terminal';
const options: RadioOption[] = [
{ label: 'Small', value: 's' },
{ label: 'Medium', value: 'm' },
{ label: 'Large', value: 'l' },
];
const App = component(() => {
const size = signal('m');
return () => (
<box border="single" label="Size">
<Radio
options={options}
model={() => size}
label="Pick a size"
autofocus
onChange={(v) => console.log('size:', v)}
/>
</box>
);
});
defineApp(<App />).mount({ clearConsole: true });
Props
| Prop | Type | Notes |
|---|---|---|
options | RadioOption[] | required — the choices |
model | Model<string> | two-way bound selected value |
label | string | caption above the group |
autofocus | boolean | grab focus on mount |
Events
| Event | Payload | When |
|---|---|---|
change | string | selection moves |
RadioOption
interface RadioOption<T = string> {
label: string;
value: T;
}
See also
- Select — a scrolling single-choice menu.
- MultiSelect — choose several.
