Radio Groups

Capture user feedback limited to a small set of options.

javascript
import { RadioGroup, RadioItem } from '@brainandbones/skeleton';

Examples

Selected 0

Selected horz

typescript
import { writable, type Writable } from 'svelte/store';

const storeLayout: Writable<string> = writable('horz');
html
<RadioGroup selected={storeLayout}>
    <RadioItem value="horz">Horizontal</RadioItem>
    <RadioItem value="vert">Vertical</RadioItem>
</RadioGroup>

To set display width to 100% use display="flex"

html
<RadioGroup display="flex"></RadioGroup>

Properties

Radio Group

Prop Type Values Required Description
selectedWritableanyProvide a Svelte writable to store the selected state value.
displaystringinline-flex-Provide classes to set the display style.
backgroundstringbg-surface-300 dark:bg-surface-700-Provide classes to set the base background color.
hoverstringhover:bg-primary-500/10-Provide classes to set the hover style.
accentstringbg-primary-500 !text-white-Provide classes to set the highlighted accent color.
colorstringtext-white-Provide classes to set the highlighted text color.
fillstring--Provide classes to set the highlighted SVG fill color.
roundedstringrounded-Provide classes to set the border radius.

Radio Item

Can override props hover, accent, color, fill, rounded.

Prop Type Description
valueanyThe item's selection value.

Accessibility

ARIA Guidelines

Radio Group

Prop Required Description
label-Defines a semantic ARIA label.

Radio Item

Prop Required Description
label-Defines a semantic ARIA label.

Keyboard Interactions

Keys Description
TabMoves focus to the next focusable RadioItem.
Shift + Tab Moves focus to the previous focusable RadioItem.
Space or EnterChecks the focused radio button if it is not already checked