<BaseRadio /> · A simple radio component.
<template>
<BaseRadioGroup v-model="value">
<BaseRadio
label="Option 1"
value="Option 1"
/>
<BaseRadio
label="Option 2"
value="Option 2"
/>
<BaseRadio
value="Option 3"
label="Option 3"
/>
</BaseRadioGroup>
</template>
<script setup lang="ts">
const value = ref('Option 1')
</script>
The Group component is a container for the Radio components. The Radio component is a simple radio button.
<template>
<BaseRadioGroup>
<BaseRadio />
<BaseRadio />
<BaseRadio />
</BaseRadioGroup>
</template>
This component has props that you can use to modify its visual style.
| Model | Type |
|---|---|
model-value | AcceptableValueThe controlled value of the radio item to check. Can be binded as `v-model`. |
| Prop | Type |
|---|---|
itemsdefault: [] | BaseRadioProps[] |
default-valuedefault: - | AcceptableValueThe value of the radio item that should be checked when initially rendered. Use when you do not need to control the state of the radio items. |
disableddefault: - | booleanWhen `true`, prevents the user from interacting with radio items. |
orientationdefault: - | DataOrientationThe orientation of the component. |
dirdefault: - | DirectionThe reading direction of the combobox when applicable. If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. |
loopdefault: - | booleanWhen `true`, keyboard navigation will loop from last item to first, and vice versa. |
as-childdefault: - | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
asdefault: - | AsTag | ComponentThe element or component this component should render as. Can be overwritten by `asChild`. |
namedefault: - | stringThe name of the field. Submitted with its owning form as part of a name/value pair. |
requireddefault: - | booleanWhen `true`, indicates that the user must set the value before the owning form can be submitted. |
| Slot | Type |
|---|---|
#default | any |
| Prop | Type |
|---|---|
labeldefault: - | stringThe label for the radio input. |
variantdefault: "default" | "default" | "primary" | "dark" | "none"The variant of the radio. |
classesdefault: {} | { root?: string | string[]; indicator?: string | string[]; label?: string | string[]; labelWrapper?: string | string[]; }Optional classes to pass to the inner components. |
asdefault: - | AsTag | ComponentThe element or component this component should render as. Can be overwritten by `asChild`. |
as-childdefault: - | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
disableddefault: - | booleanWhen `true`, prevents the user from interacting with the radio item. |
namedefault: - | stringThe name of the field. Submitted with its owning form as part of a name/value pair. |
requireddefault: - | booleanWhen `true`, indicates that the user must set the value before the owning form can be submitted. |
valuedefault: - | AcceptableValueThe value given as data when submitted with a `name`. |
iddefault: - | string |
| Event | Emitted Value Type |
|---|---|
select | [event: any] |
| Slot | Type |
|---|---|
#default | any |
#error | any |
Use the variant prop to change the color of the radio.
<template>
<BaseRadioGroup v-model="value">
<BaseRadio
value="Option 1"
label="Option 1"
variant="primary"
/>
</BaseRadioGroup>
</template>
<script setup lang="ts">
const value = ref('Option 1')
</script>
Set the variant prop to none and use tailwind classes to customize the radio.
<template>
<BaseRadioGroup v-model="value">
<BaseRadio
value="Option 1"
label="Option 1"
variant="none"
class="bg-green-500/10 dark:bg-green-500/20 border-1 border-muted-300 dark:border-muted-700 text-green-700 dark:text-green-400"
/>
</BaseRadioGroup>
</template>
<script setup lang="ts">
const value = ref('Option 1')
</script>