@cas-smartdesign/radio-button-group
v6.0.8
Published
Radio button and radio button group elements with SmartDesign look & feel
Readme
@cas-smartdesign/radio-button-group
A radio-button-group and a radio-button element based on lit-element with SmartDesign 3.0 look & feel.
This element must be used together with the design tokens of SmartDesign. For an independent application, make sure to include the @cas-smartdesign/design-tokens package. For a web app / web widget, refer to the official documentation about design token usage.
radio-button-group
The group accepts any element as a button, not just sd-radio-button. The checked state is reflected on the slotted elements as follows:
sd-radio-buttonchildren are toggled via theircheckedattribute.- Any other element (e.g.
sd-button variant="selection"for a segmented control) is toggled via the standardaria-pressedattribute ("true"/"false").
Attributes
layout- Defines the layout in which the buttons are placed
- Possible values:
"horizontal","vertical"
uncheck-allowed- Defines whether if buttons can be deselected explicitly
disabled- Defines whether if the group is disabled
Properties
layout,uncheckAllowed,disabled- Reflects the corresponding attribute
value- Reflects the value of the checked button in the group
Custom events
sd-radio-button-group-value-change: CustomEvent<IValueChangeEvent>- This event is dispatched when the value is changed because of a user interaction
- A button checked in the markup, or added to the group checked, sets
valuewithout this event
Validation
The element could show validation messages via an sd-field-validation-message element which can be configured with the following attributes & properties which are all delegated to that:
validationMessagevalidationIconSrcvalidationLevel
CSS Custom Properties
--sd-radio-button-group-gap- Defines the gap between the radio buttons in the group.
Focus ring
The group does not draw focus rings itself — they are drawn by
@cas-smartdesign/focus-ring (an optional peer dependency). Install it
once per application, not per component:
import { FocusRing } from "@cas-smartdesign/focus-ring";
FocusRing.install();The real focus stays on the group host; the group publishes the visually focused button via
aria-activedescendant, so the ring wraps the focused button (radio button or segmented
sd-button) instead of the whole group. The ring's shape follows each button's own
border-radius — for a segmented control this includes the per-corner radii of the first/last
button. Keyboard navigation (Tab, arrow keys) shows the ring; clicking a button does not.
radio-button
Attributes
checked- Defines whether if the button is checked
value- Defines the value of the button
focused- Set by the group on the button it shows as focused
disabled- Defines whether if the interaction with the button is disabled
label- Defines the text of the label
oneline: boolean- The label of the button may wrap into multiple lines without this option.
Properties
checked,value,disabled,label- Reflects the corresponding attribute
focusedandonelineare attributes only
CSS Custom Properties
--sd-radio-button-checked-color- Defines the color of the inner & outer circle when the button is checked
--sd-radio-button-unchecked-color- Defines the color of the outer circle and the inner circle when the button is unchecked
--sd-radio-button-padding- Defines the padding of the radio button. It is a shorthand property, so you can set all four paddings at once. (e.g.
10px 5px)
- Defines the padding of the radio button. It is a shorthand property, so you can set all four paddings at once. (e.g.
