Skip to content

Radio button set - AvRadioButtonSet

✨ Introduction

The AvRadioButtonSet automatically manages the addition of AvRadioButton in a group according to the AvRadioButton present in the default slot.

Radio buttons allow the user to select a single option from a list.

The radio button cannot be used on its own: a minimum of 2 options is required. It is preferable not to select a default option, so that the user choice is conscious (especially if the choice is mandatory).

🏗️ Structure

The AvRadioButtonSet component consists of the following elements:

  • A <div> element encompassing the entire radio group.
  • A <fieldset> element containing the radio buttons and associated messages.
  • A legend (legend) defined by the legend prop and customizable with the legend slot.
  • A hint (hint) defined by the hint prop and customizable with the hint slot.
  • A group of individual radio buttons rendered by the AvRadioButton component.
  • An information, error or validation message, displayed below the group of radio buttons (optional).

🏷️ Props

NameTypeDefaultMandatoryDescription
namestringName of the radio group, applied to each radio <input name>. Used for form submission and accessibility.
legendstringundefinedLabel (legend) for the radio group, rendered visually as a title. Helps screen readers understand the group context.
modelValuestring | number | boolean | undefinedCurrent selected value in the radio group. Must match one of the options values.
disabledbooleanfalseIf true, disables all radio buttons in the group.
requiredbooleanfalseIf true, marks the group as required and shows a required indicator.
smallbooleanfalseIf true, displays the radio buttons in compact (small) mode.
inlinebooleanfalseIf true, displays the radio buttons inline (horizontally).
errorMessagestringundefinedOptional global error message displayed below the group. If set, indicates a validation error.
validMessagestringundefinedOptional global valid message displayed below the group. If set, confirms successful validation.
hintstring''Optional hint text displayed below the legend. Provides guidance or extra information.

🔊 Events

NameData (payload)Description
'update:modelValue'Value (string | number | boolean) of the selected radio buttonEmitted when a radio button is selected.

🎨 Slots

NameDescription
defaultDefault slot for adding radio button (each radio button must be in an AvRadioButton).

🚀 Storybook demos

You can find examples of use and demo of the component on its dedicated Storybook page.

💡 Examples of use

vue
<template>
  <AvRadioButtonSet
    v-model="selected"
    name="test-group"
    legend="Choisissez une option"
    hint="Ce choix est requis"
    :inline="true"
    :small="false"
    valid-message="Une erreur s’est produite"
  >
    <AvRadioButton value="option1">
      <div>
        <span class="b2-bold">Option 1</span><br>
        <span class="b2-regular">Contenu riche avec description</span>
      </div>
    </AvRadioButton>

    <AvRadioButton value="option2">
      <div>
        <span class="b2-bold">Option 2</span><br>
        <span class="b2-regular">Autre contenu personnalisé</span>
      </div>
    </AvRadioButton>

    <AvRadioButton
      value="option3"
      :disabled="true"
    >
      <div>
        <span class="b2-bold">Option 3 (désactivée)</span><br>
        <span class="b2-regular">Texte grisé et inaccessible</span>
      </div>
    </AvRadioButton>
  </AvRadioButtonSet>
</template>