Skip to Content
Cristal

Forms

Radio group

Pick a single option from a list, under a visible title.

<cr-radio-group>CrRadioGroup

Example

Options are child option elements, as with CrSelect, stacked under the label title. When the choice changes, the dot flows from the old circle to the new one: it stretches in the direction of the choice, then shrinks back. A disabled option cannot be picked.

Prefer radio buttons to a dropdown when there are few options (about 5 or fewer): they all stay visible. For 2 to 4 short options side by side, see the segmented control.

Chosen delivery: standard

'use client';

import { useState } from 'react';
import { CrBox, CrRadioGroup } from '@cristal-ui/react';

export default function RadioGroupBasic() {
  const [delivery, setDelivery] = useState('standard');

  return (
    <CrBox display="flex" direction="column" gap="lg">
      <CrRadioGroup label="Delivery method" name="delivery" required value={delivery} onCrChange={(event) => setDelivery(event.detail)}>
        <option value="standard">Standard, 3 to 5 days</option>
        <option value="express">Express, 24 h</option>
        <option value="relay" disabled>
          Pickup point (unavailable)
        </option>
        <option value="store">In-store pickup</option>
      </CrRadioGroup>
      <p>Chosen delivery: {delivery}</p>
    </CrBox>
  );
}

In a form

The chosen value is submitted under name. No option is chosen by default; with required, submitting is blocked until one is: the message "Choose one of the options." shows under the group and focus moves to it.

If the user asked their system to reduce motion, the dot appears straight in the chosen circle, without flowing.

error-animation animates the error when it appears and on every rejected submit (zigzag, badge, echo…): see Animated error.

Accessibility

  • The group follows the W3C radio group pattern: role="radiogroup" named by its visible title (aria-labelledby), each option role="radio" with aria-checked.
  • A single Tab stop enters the group: on the chosen option, or on the first available one when none is chosen.
  • Arrow keys (down and right, up and left) move to the next or previous option and pick it, wrapping and skipping disabled options; Space picks the focused option.
  • required is announced (aria-required); the error is linked to the group with aria-describedby and aria-invalid.
  • The chosen option does not rely on colour alone: a solid dot appears in its circle.

API

Properties

PropertyTypeDefaultDescription
disabledbooleanfalseDésactive le groupe.
errorAnimation"drop" | "echo" | "jitter" | "none" | "pop" | "wobble" | "zigzag"'none'Animation de l'erreur quand elle apparaît et à chaque envoi refusé : none (par défaut), zigzag, pop, drop, echo, jitter ou wobble.
label (obligatoire)string—Titre affiché au-dessus des options, et nom du groupe pour les lecteurs d'écran.
namestring—Nom envoyé avec le formulaire.
requiredbooleanfalseRend le choix obligatoire.
valuestring''Valeur de l'option choisie ; aucune par défaut.

Events

Reactevent.detailDescription
onCrChangestringÉmis quand l'option choisie change ; detail : sa valeur.

CSS parts

To style it from outside: cr-radio-group::part(name) { … }

PartDescription
errorLe message d'erreur.
labelLe titre du groupe.
optionUne option.

On this page