Radio
The Radio input component uses HTML's native radio inputs to allow a user to select one value from a set of options. The component supports the W3C ARIA APG Radio Group Pattern. Use it with the Field component to access all the functionalities.
Examples
Base
A radio component will render one selection at a time. Use the native-value property to specify the value that will be used as the modelValue property when the specific radio is checked.
Show code
<section>
<o-field>
<o-radio
v-model="radio"
name="base"
native-value="Flint"
label="Flint" />
<o-radio
v-model="radio"
name="base"
native-value="Silver"
label="Silver" />
<o-radio
v-model="radio"
name="base"
native-value="Jack"
label="Jack" />
<o-radio
v-model="radio"
name="base"
native-value="Vane"
label="Vane"
disabled />
</o-field>
<p><b>Selection:</b> {{ radio }}</p>
</section>
import { ref } from "vue";
const radio = ref("Jack");
Variants
Different styles can be achieved with the variant prop.
Show code
<section>
<o-field>
<o-radio
v-model="radio"
name="variants"
native-value="default"
label="Default" />
</o-field>
<o-field>
<o-radio
v-model="radio"
name="variants"
native-value="primary"
variant="primary"
label="Primary" />
</o-field>
<o-field>
<o-radio
v-model="radio"
name="variants"
native-value="success"
variant="success"
label="Success" />
</o-field>
<o-field>
<o-radio
v-model="radio"
name="variants"
native-value="info"
variant="info"
label="Info" />
</o-field>
<o-field>
<o-radio
v-model="radio"
name="variants"
native-value="warning"
variant="warning"
label="Warning" />
</o-field>
<o-field>
<o-radio
v-model="radio"
name="variants"
native-value="danger"
variant="danger"
label="Danger" />
</o-field>
<p><b>Selection:</b> {{ radio }}</p>
</section>
import { ref } from "vue";
const radio = ref("default");
Sizes
The component can be displayed in different sizes using the size prop.
Show code
<section>
<o-field>
<o-radio
v-model="radio"
name="sizes"
native-value="small"
size="small"
label="Small" />
</o-field>
<o-field>
<o-radio
v-model="radio"
name="sizes"
native-value="default"
label="Default" />
</o-field>
<o-field>
<o-radio
v-model="radio"
name="sizes"
native-value="medium"
size="medium"
label="Medium" />
</o-field>
<o-field>
<o-radio
v-model="radio"
name="sizes"
native-value="large"
size="large"
label="Large" />
</o-field>
<p><b>Selection:</b> {{ radio }}</p>
</section>
import { ref } from "vue";
const radio = ref("small");
Radio Component
Select an option from a set of options.
<o-radio></o-radio>Props
| Prop name | Description | Type | Values | Default |
|---|---|---|---|---|
| autocomplete | Same as native autocomplete options to use in HTML5 validation | string | - | From config: radio: { |
| customValidity | Custom HTML 5 validation error to set on the form control | string | ((currentValue: unknown | null , state: ValidityState) => string) | undefined | - | |
| disabled | Same as native disabled | boolean | - | false |
| id | Same as native id. Also pass the id to a wrapping o-field component. Default is a uuid. | string | - | useId() |
| label | Input label, unnecessary when default slot is used | string | - | |
| v-model | The input value state, use v-model to make it two-way binding | unknown | - | |
| name | Same as native name | string | - | |
| nativeValue | Same as native value | unknown | - | |
| override | Override existing theme classes completely | boolean | - | |
| required | Same as native required | boolean | - | false |
| size | Size of the control | string | small, medium, large | From config: radio: { |
| useHtml5Validation | Enable html 5 native validation | boolean | - | From config: { |
| variant | Color variant of the control | string | primary, info, success, warning, danger, and any other custom color | From config: radio: { |
Events
| Event name | Properties | Description |
|---|---|---|
| update:model-value | value unknown - updated modelValue prop | modelValue prop two-way binding |
| input | value unknown - input valueevent Event - native event | on input change event |
| focus | event Event - native event | on input focus event |
| blur | event Event - native event | on input blur event |
| invalid | event Event - native event | on input invalid event |
Slots
| Name | Description | Bindings |
|---|---|---|
| default | Override the label, default is label prop |
Class Inspector
| Class prop | Description | Props | Suffixes | |
|---|---|---|---|---|
| rootClass | Class of the root element. | |||
| checkedClass | Class of the root element when checked. | modelValue | ||
| sizeClass | Class of the root element with size. | size | small | |
| variantClass | Class of the root element with variant. | variant | primary | |
| disabledClass | Class of the root element when disabled. | disabled | ||
| inputClass | Class of the native input element. | |||
| labelClass | Class of the radio label element. |
Sass Variables
Current theme ➜ Oruga
| SASS Variable | Default |
|---|---|
| $radio-spacer | h.useVar("control-spacer") |
| $radio-disabled-opacity | h.useVar("control-disabled-opacity") |
| $radio-width | 1em |
| $radio-height | 1em |
| $radio-color | h.useVar("font-color") |
| $radio-font-size | h.useVar("font-size") |
| $radio-font-weight | h.useVar("font-weight") |
| $radio-line-height | h.useVar("line-height") |
| $radio-box-shadow | h.useVar("control-box-shadow-inset") |
| $radio-border-color | h.useVar("primary") |
| $radio-border-style | solid |
| $radio-border-radius | h.useVar("border-radius-rounded") |
| $radio-border-width | calc(2 * h.useVar("control-border-width")) |
| $radio-background-color | h.useVar("white") |
| $radio-active-background-color | h.useVar("primary") |
| $radio-checked-box-shadow-length | 0 0 0.5em |
| $radio-checked-box-shadow-opacity | 0.8 |
See ➜ 📄 SCSS file
Current theme ➜ Bulma
| SASS Variable | Default |
|---|---|
| $radio-size | 1.25em |
| $radio-colors | dv.$colors |
| $radio-active-background-color | css.getVar("primary") |
| $radio-border-color | css.getVar("grey") |
| $radio-shadow | css.getVar("shadow") |
See ➜ 📄 SCSS file
Current theme ➜ Bootstrap
The theme does not have any custom variables for this component.
