Skip to content
Oruga
Bulma
Bootstrap
Tailwind

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.

html
<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>
javascript
import { ref } from "vue";

const radio = ref("Jack");

Variants

Different styles can be achieved with the variant prop.

html
<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>
javascript
import { ref } from "vue";

const radio = ref("default");

Sizes

The component can be displayed in different sizes using the size prop.

html
<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>
javascript
import { ref } from "vue";

const radio = ref("small");

Radio Component

Select an option from a set of options.

html
<o-radio></o-radio>

Props

Prop nameDescriptionTypeValuesDefault
aria-activedescendantIdentifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.string-
aria-atomicIndicates 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-autocompleteIndicates 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-busyIndicates 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-checkedIndicates the current "checked" state of checkboxes, radio buttons, and other widgets."mixed" | Booleanish-
aria-colcountDefines the total number of columns in a table, grid, or treegrid.Numberish-
aria-colindexDefines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.Numberish-
aria-colspanDefines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.Numberish-
aria-controlsIdentifies the element (or elements) whose contents or presence are controlled by the current element.string-
aria-currentIndicates the element that represents the current item within a container or set of related elements."date" | "location" | "page" | "step" | "time" | Booleanish-
aria-describedbyIdentifies the element (or elements) that describes the object.string-
aria-detailsIdentifies the element that provides a detailed, extended description for the object.string-
aria-disabledIndicates that the element is perceivable but disabled, so it is not editable or otherwise operable.Booleanish-
aria-dropeffect
deprecated - in ARIA 1.1
Indicates what functions can be performed when a dragged object is released on the drop target.
"copy" | "execute" | "link" | "move" | "none" | "popup"-
aria-errormessageIdentifies the element that provides an error message for the object.string-
aria-expandedIndicates whether the element, or another grouping element it controls, is currently expanded or collapsed.Booleanish-
aria-flowtoIdentifies 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-
aria-grabbed
deprecated - in ARIA 1.1
Indicates an element's "grabbed" state in a drag-and-drop operation.
Booleanish-
aria-haspopupIndicates 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-hiddenIndicates whether the element is exposed to an accessibility API.Booleanish-
aria-invalidIndicates the entered value does not conform to the format expected by the application."grammar" | "spelling" | Booleanish-
aria-keyshortcutsIndicates keyboard shortcuts that an author has implemented to activate or give focus to an element.string-
aria-labelDefines a string value that labels the current element.string-
aria-labelledbyIdentifies the element (or elements) that labels the current element.string-
aria-levelDefines the hierarchical level of an element within a structure.Numberish-
aria-liveIndicates 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-modalIndicates whether an element is modal when displayed.Booleanish-
aria-multilineIndicates whether a text box accepts multiple lines of input or only a single line.Booleanish-
aria-multiselectableIndicates that the user may select more than one item from the current selectable descendants.Booleanish-
aria-orientationIndicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous."horizontal" | "vertical"-
aria-ownsIdentifies 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-placeholderDefines 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-posinsetDefines 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-pressedIndicates the current "pressed" state of toggle buttons."mixed" | Booleanish-
aria-readonlyIndicates that the element is not editable, but is otherwise operable.Booleanish-
aria-relevantIndicates 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-requiredIndicates that user input is required on the element before a form may be submitted.Booleanish-
aria-roledescriptionDefines a human-readable, author-localized description for the role of an element.string-
aria-rowcountDefines the total number of rows in a table, grid, or treegrid.Numberish-
aria-rowindexDefines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.Numberish-
aria-rowspanDefines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.Numberish-
aria-selectedIndicates the current "selected" state of various widgets.Booleanish-
aria-setsizeDefines 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-sortIndicates if items in a table or grid are sorted in ascending or descending order."ascending" | "descending" | "none" | "other"-
aria-valuemaxDefines the maximum allowed value for a range widget.Numberish-
aria-valueminDefines the minimum allowed value for a range widget.Numberish-
aria-valuenowDefines the current value for a range widget.Numberish-
aria-valuetextDefines the human readable text alternative of aria-valuenow for a range widget.string-
autocompleteNative 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: {
  autocomplete: "off"
}
customValidityCustom HTML 5 validation error to set on the form controlstring | ((currentValue: unknown | null , state: ValidityState) => string) | undefined-""
disabledSame as native disabledboolean-false
formSame as native formstring-
idSame as native id. Also pass the id to a wrapping o-field component. Default is a uuid.string-useId()
labelInput label, unnecessary when default slot is usedstring-
v-modelThe input value state, use v-model to make it two-way bindingunknown-
nameSame as native namestring-
nativeValueSame as native valueunknown-
overrideOverride existing theme classes completelyboolean-
requiredSame as native requiredBooleanish-
sizeSize of the controlstringsmall, medium, large
From config:
radio: {
  size: undefined
}
useHtml5ValidationEnable HTML 5 native validationboolean-
From config:
{
  useHtml5Validation: true
}
variantColor variant of the controlstringprimary, info, success, warning, danger, and any other custom color
From config:
radio: {
  variant: undefined
}

Events

Event namePropertiesDescription
update:model-valuevalue unknown - updated modelValue propmodelValue prop two-way binding
inputvalue unknown - input value
event Event - native event
on input change event
focusevent Event - native eventon input focus event
blurevent Event - native eventon input blur event
invalidevent Event - native eventon input invalid event

Slots

NameDescriptionBindings
defaultOverride the label, default is label prop

Class Inspector

Classes applied to the element:
Want to know how does the Class Inspector work?
Class propDescriptionPropsSuffixes
rootClass
Class of the root element.
checkedClass
Class of the root element when checked.
modelValue
sizeClass
Class of the root element with size.
sizesmall
medium
large
variantClass
Class of the root element with variant.
variantprimary
info
warning
danger
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 VariableDefault
$radio-spacerh.useVar("control-spacer")
$radio-disabled-opacityh.useVar("control-disabled-opacity")
$radio-width1em
$radio-height1em
$radio-colorh.useVar("font-color")
$radio-font-sizeh.useVar("font-size")
$radio-font-weighth.useVar("font-weight")
$radio-line-heighth.useVar("line-height")
$radio-box-shadowh.useVar("control-box-shadow-inset")
$radio-border-colorh.useVar("primary")
$radio-border-stylesolid
$radio-border-radiush.useVar("border-radius-rounded")
$radio-border-widthcalc(2 * h.useVar("control-border-width"))
$radio-background-colorh.useVar("white")
$radio-active-background-colorh.useVar("primary")
$radio-checked-box-shadow-length0 0 0.5em
$radio-checked-box-shadow-opacity0.8

See ➜ 📄 SCSS file

Current theme ➜ Bulma

SASS VariableDefault
$radio-size1.25em
$radio-colorsdv.$colors
$radio-active-background-colorcss.getVar("primary")
$radio-border-colorcss.getVar("grey")
$radio-shadowcss.getVar("shadow")

See ➜ 📄 SCSS file

Current theme ➜ Bootstrap

The theme does not have any custom variables for this component.

Current theme ➜ Tailwind

SASS VariableDefault

See ➜ 📄 SCSS file

Released under the MIT License.