Menu

Menu

On this page

On this page

Radio

Allow users to select a single option from a set.

npm install @vrembem/radio
Copied!
SCSS
@use "@vrembem/radio";
Copied!

Options

Radio uses design token CSS variables in a reference and fallback pattern. Variables are referenced in the component's styles but are not directly defined; instead, they are provided with sensible fallbacks.

VariableFallback
--vb-radio-color
Copied!
--vb-radio-accent
Copied!
--vb-radio-fill
Copied!
--vb-radio-size
Copied!
--vb-radio-border-width
Copied!
2px
Copied!
--vb-radio-dot-size
Copied!
0.5em
Copied!

Basic usage

Radio form controls are composed using the <input type="radio"> element along with the .radio class.

HTML
<input class="radio" type="radio" />
Copied!

Labels

For radio buttons with labels, just wrap the radio element along with label text using the <label> element.


HTML
<label>
  <input class="radio" type="radio" />
  <span>Radio with a label</span>
</label>
Copied!

Disabled

Adding the boolean disabled attribute to the input element will provide visual indication that the radio is not available for use.



HTML
<input class="radio" type="radio" disabled checked />
Copied!

Invalid

Adding the is-invalid class or aria-invalid="true" attribute to the radio component will provide visual indication that the form-control value is invalid. Invalid state is also triggered by the native :user-invalid state.

HTML
<input class="radio is-invalid" type="radio" />
Copied!