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

NameDescriptionTypeDefault
idthe id of the `input` elementstring-
namethe name attribute of the `input` elementstring-
disabledif `true`, the component is disabledbooleanfalse
valuethe value of the componentany-
borderedAdd border to the componentBooleanfalse
fullWidthDefines if component is fit-content or full widthBooleanfalse

Product Uses

Sprout HR