Components › Components
Radio group
Pick one of a few. Native radios in a fieldset, so the arrow keys, one Tab stop and form submission come from the browser; the server writes which one is checked.
Styled: Radio group on ui.clarusjs.com, ready to copy, in plain CSS or Tailwind.
Size: m
tscl
@import uiRadioGroup from '@clarusjs/ui-primitives/radio-group.tscl'
@import uiRadio from '@clarusjs/ui-primitives/radio.tscl'
<uiRadioGroup name="size" label="Size" [(value)]="size">
<uiRadio value="s" label="Small" />
<uiRadio value="m" label="Medium" />
<uiRadio value="l" label="Large" [disabled]="true" />
</uiRadioGroup>namesubmits the choice with its form;labelis the fieldset's legend.[(value)]is the checked radio's value.(change)comes first with the new value;$info.cancel()keeps the current one.- Each
radiohas avalue, alabelanddisabled. It reads the group from context, so it ships no JavaScript. - Styling:
data-partradio-group,legend,radioandlabel;data-checkedanddata-disabledon each radio's label, and:checkedon the input.
From @clarusjs/ui-primitives, styled by @clarusjs/ui: @import '@clarusjs/ui/ui.css' once, and change the look with its --ui- tokens (--ui-accent, --ui-radius, --ui-font…). Without it, the part is unstyled and works the same.