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 |
|---|---|---|---|---|
| aria-activedescendant | Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. | string | - | |
| aria-atomic | Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. | Booleanish | - | |
| aria-autocomplete | Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made. | "both" | "inline" | "list" | "none" | - | |
| aria-busy | Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. | Booleanish | - | |
| aria-checked | Indicates the current "checked" state of checkboxes, radio buttons, and other widgets. | "mixed" | Booleanish | - | |
| aria-colcount | Defines the total number of columns in a table, grid, or treegrid. | Numberish | - | |
| aria-colindex | Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid. | Numberish | - | |
| aria-colspan | Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid. | Numberish | - | |
| aria-controls | Identifies the element (or elements) whose contents or presence are controlled by the current element. | string | - | |
| aria-current | Indicates the element that represents the current item within a container or set of related elements. | "date" | "location" | "page" | "step" | "time" | Booleanish | - | |
| aria-describedby | Identifies the element (or elements) that describes the object. | string | - | |
| aria-details | Identifies the element that provides a detailed, extended description for the object. | string | - | |
| aria-disabled | Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. | Booleanish | - | |
deprecated - in ARIA 1.1 | "copy" | "execute" | "link" | "move" | "none" | "popup" | - | ||
| aria-errormessage | Identifies the element that provides an error message for the object. | string | - | |
| aria-expanded | Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. | Booleanish | - | |
| aria-flowto | Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order. | string | - | |
deprecated - in ARIA 1.1 | Booleanish | - | ||
| aria-haspopup | Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. | "dialog" | "grid" | "listbox" | "menu" | "tree" | Booleanish | - | |
| aria-hidden | Indicates whether the element is exposed to an accessibility API. | Booleanish | - | |
| aria-invalid | Indicates the entered value does not conform to the format expected by the application. | "grammar" | "spelling" | Booleanish | - | |
| aria-keyshortcuts | Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. | string | - | |
| aria-label | Defines a string value that labels the current element. | string | - | |
| aria-labelledby | Identifies the element (or elements) that labels the current element. | string | - | |
| aria-level | Defines the hierarchical level of an element within a structure. | Numberish | - | |
| aria-live | Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. | "assertive" | "off" | "polite" | - | |
| aria-modal | Indicates whether an element is modal when displayed. | Booleanish | - | |
| aria-multiline | Indicates whether a text box accepts multiple lines of input or only a single line. | Booleanish | - | |
| aria-multiselectable | Indicates that the user may select more than one item from the current selectable descendants. | Booleanish | - | |
| aria-orientation | Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. | "horizontal" | "vertical" | - | |
| aria-owns | Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship. | string | - | |
| aria-placeholder | Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format. | string | - | |
| aria-posinset | Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. | Numberish | - | |
| aria-pressed | Indicates the current "pressed" state of toggle buttons. | "mixed" | Booleanish | - | |
| aria-readonly | Indicates that the element is not editable, but is otherwise operable. | Booleanish | - | |
| aria-relevant | Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. | "additions removals" | "additions text" | "additions" | "all" | "removals additions" | "removals text" | "removals" | "text additions" | "text removals" | "text" | - | |
| aria-required | Indicates that user input is required on the element before a form may be submitted. | Booleanish | - | |
| aria-roledescription | Defines a human-readable, author-localized description for the role of an element. | string | - | |
| aria-rowcount | Defines the total number of rows in a table, grid, or treegrid. | Numberish | - | |
| aria-rowindex | Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid. | Numberish | - | |
| aria-rowspan | Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid. | Numberish | - | |
| aria-selected | Indicates the current "selected" state of various widgets. | Booleanish | - | |
| aria-setsize | Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. | Numberish | - | |
| aria-sort | Indicates if items in a table or grid are sorted in ascending or descending order. | "ascending" | "descending" | "none" | "other" | - | |
| aria-valuemax | Defines the maximum allowed value for a range widget. | Numberish | - | |
| aria-valuemin | Defines the minimum allowed value for a range widget. | Numberish | - | |
| aria-valuenow | Defines the current value for a range widget. | Numberish | - | |
| aria-valuetext | Defines the human readable text alternative of aria-valuenow for a range widget. | string | - | |
| autocomplete | Native options to use in HTML5 validation, whether the value of the form's controls can be automatically completed by the browser. | 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 |
| form | Same as native form | string | - | |
| 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 | Booleanish | - | |
| 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.
