Skip to content

Radio

A Radio Button is a component that enables a user to select a single option from a set of choices.

Basic Usage

vue
<template>
  <div class="spr-flex spr-flex-col spr-items-start spr-gap-2">
    <spr-radio id="radio1" v-model="radioModel" name="radio_name" value="value1">Radio Label 1</spr-radio>
    <spr-radio id="radio2" v-model="radioModel" name="radio_name" value="value2">Radio Label 2</spr-radio>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';

const radioModel = ref('');
</script>

Active

vue
<template>
  <spr-radio id="radio1" v-model="radioModel" name="radio_name" value="value1">Radio Label 1</spr-radio>
  <spr-radio id="radio2" v-model="radioModel" name="radio_name" value="value2">Radio Label 2</spr-radio>
</template>

<script lang="ts" setup>
import { ref } from 'vue';

const radioModel = ref('value2');
</script>

Disabled

Add the disabled attribute to the <spr-radio> component to disable the radio button.

vue
<template>
  <div class="spr-flex spr-flex-col spr-items-start spr-gap-2">
    <spr-radio id="disabledradio1" v-model="radioModel" name="radio_name" value="value1">Radio Label 1</spr-radio>
    <spr-radio id="disabledradio2" v-model="radioModel" name="radio_name" value="value2" disabled>
      Radio Label 2
    </spr-radio>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';

const radioModel = ref('');
</script>

API Reference

Props

NameDescriptionTypeDefault
idUnique identifier for the radio input element. Required for accessibility and label association.stringRequired
modelValueCurrent selected value used with v-model for two-way binding. When this matches the radio's value prop, the radio is selected.string | number | booleanundefined
nameName attribute for the radio input element. Radio buttons in the same group should share the same name to ensure only one can be selected at a time.stringRequired
valueThe value associated with this radio button. When the radio is selected, this value is assigned to the modelValue.string | number | booleanRequired
disabledWhen set to true, the radio button becomes non-interactive and appears visually disabled. Users cannot select a disabled radio button.booleanfalse
descriptionAdditional explanatory text displayed below the radio label to provide more context or details about this option.stringundefined
borderedWhen set to true, adds a border around the entire radio component (including the label), providing visual separation from surrounding elements.booleanfalse
fullWidthWhen set to true, the radio component will stretch to fill the full width of its container. When false, it will only be as wide as its content.booleanfalse

Events

NameDescriptionParameters
update:modelValueEmitted when the radio button is selected. This event is used for v-model binding to work correctly.(value: string | number | boolean) - The value of the selected radio button

Slots

NameDescription
defaultContent to be displayed as the radio button's label. This typically contains text but can include other elements for more complex labels.

Animation

AnimationDescription
animate-shadow-growApplied when the radio button is selected, creating a smooth transition from an empty circle to a filled circle with a white center.

Product Uses

Sprout HR