Five Star Rating Radio Group

FiveStarRatingRadioGroup is a headless <fieldset role="radiogroup"> for choosing a 1-5 star rating, holding the FiveStarRatingRadioInput radios the consumer composes, with whatever labels and layout the consumer writes. It replaces the earlier five-star-rating-picker (removed 2026-11-15).

Status: experimental — new (2026-11-15), implemented and unit-tested in every headless library; not yet exercised in a composed flow.

Example

Show demo markup
<fieldset class="five-star-rating-radio-group" role="radiogroup" aria-label="Rate this service"><label class="label" for="demo-five-star-rating-g-0"><input class="five-star-rating-radio-input" type="radio" id="demo-five-star-rating-g-0" name="demo-rating" aria-label="1 star" value="1" data-value="1" /> 1 star</label><label class="label" for="demo-five-star-rating-g-1"><input class="five-star-rating-radio-input" type="radio" id="demo-five-star-rating-g-1" name="demo-rating" aria-label="2 stars" value="2" data-value="2" /> 2 stars</label><label class="label" for="demo-five-star-rating-g-2"><input class="five-star-rating-radio-input" type="radio" id="demo-five-star-rating-g-2" name="demo-rating" aria-label="3 stars" value="3" data-value="3" /> 3 stars</label><label class="label" for="demo-five-star-rating-g-3"><input class="five-star-rating-radio-input" type="radio" id="demo-five-star-rating-g-3" name="demo-rating" aria-label="4 stars" value="4" data-value="4" checked /> 4 stars</label><label class="label" for="demo-five-star-rating-g-4"><input class="five-star-rating-radio-input" type="radio" id="demo-five-star-rating-g-4" name="demo-rating" aria-label="5 stars" value="5" data-value="5" /> 5 stars</label></fieldset>
Usage example
<script lang="ts">
  import FiveStarRatingRadioGroup from "./FiveStarRatingRadioGroup.svelte";
</script>

<FiveStarRatingRadioGroup label="Size">
  <label
    ><input
      type="radio"
      name="size"
      value="s"
    /> Small</label
  >
  <label
    ><input
      type="radio"
      name="size"
      value="m"
    /> Medium</label
  >
  <label
    ><input
      type="radio"
      name="size"
      value="l"
    /> Large</label
  >
</FiveStarRatingRadioGroup>
Show Svelte source
// In your Svelte component:
import FiveStarRatingRadioGroup from "lily-design-system-svelte-headless/components/FiveStarRatingRadioGroup/FiveStarRatingRadioGroup.svelte";

<FiveStarRatingRadioGroup>
  <!-- content -->
</FiveStarRatingRadioGroup>

Usage

<FiveStarRatingRadioGroup label="Rate this service">
  <FiveStarRatingRadioInput
    value="1"
    label="1 star"
    name="rating"
  />
  <FiveStarRatingRadioInput
    value="2"
    label="2 stars"
    name="rating"
  />
  <FiveStarRatingRadioInput
    value="3"
    label="3 stars"
    name="rating"
  />
</FiveStarRatingRadioGroup>

It renders:

<fieldset
  class="five-star-rating-radio-group"
  role="radiogroup"
  aria-label="Rate this service"
>
  <input
    class="five-star-rating-radio-input"
    type="radio"
    aria-label="1 star"
    name="rating"
    value="1"
    data-value="1"
  />
  …
</fieldset>

Props

  • label: string (required) -- accessible name for the group
  • children: slot (required) -- the FiveStarRatingRadioInput elements
  • ...restProps: any additional HTML attributes spread onto the fieldset

Keyboard Interactions

  • Tab: focus the checked radio, or the first if none is checked
  • ArrowDown / ArrowRight: move to and check the next radio
  • ArrowUp / ArrowLeft: move to and check the previous radio
  • Space: check the focused radio

ARIA

  • role="radiogroup" on the <fieldset>, named by aria-label
  • Each radio is named by its own label, so a status or rating is never shown by colour alone (WCAG 1.4.1)

When to Use

  • Use when the consumer wants to lay out, order or label the options themselves, for example with a visible <label> beside each radio.
  • Use inside a form, where the native radios submit the chosen value under one name.
  • Use when a form reset must restore the starting choice without any script.
  • Use when the options need extra content between them, such as a description under each one.

When Not to Use

  • Do not use when more than one option may be chosen -- use CheckboxGroup instead.
  • Do not use for a read-only display -- use FiveStarRatingView instead.
  • Do not use for a plain set of choices with no status or rating meaning -- use RadioGroup instead.

Headless

The FiveStarRatingRadioGroup headless component provides a <fieldset> with role="radiogroup" and aria-label. It relies on native radio behaviour for selection and the keyboard. The consumer provides all visual styling, including any colour coding.

Styles

The consumer provides all CSS styling. The component renders with a .five-star-rating-radio-group class for targeting; each radio carries .five-star-rating-radio-input and data-value. No default styles are included — this is a fully headless component.

Testing

  • Verify the component renders a <fieldset> element with class five-star-rating-radio-group and role="radiogroup"
  • Verify the group is named by aria-label
  • Verify the consumer's radios render inside it
  • Verify pass-through attributes are applied

Advice

  • Designers: Give every option visible text as well as its colour or icon; colour alone fails people with colour vision deficiencies.
  • Developers: Give every FiveStarRatingRadioInput the same name, so the browser treats them as one group for the arrow keys and form submission.

Implementation Notes

  • Renders a <fieldset> with role="radiogroup" and aria-label
  • The consumer supplies one FiveStarRatingRadioInput per value (1 to 5); the group renders no option text of its own
  • Selection, the arrow keys, form submission and form reset are native radio behaviour, so the group keeps no state
  • Spreads restProps onto the fieldset, so disabled, id or data-* pass through

Related components

  • five-star-rating-radio-input — a radio input for one choice of a 1-5 star rating <input type="radio">
  • five-star-rating-view — the read-only display
  • radio-group — the general radio group

References


Lily™ and Lily Design System™ are trademarks.

Canonical contract

Generated from this component's canonical metadata — the machine-checked source the implementations are held to.

Metadata

  • Component: five-star-rating-radio-group
  • PascalCase: FiveStarRatingRadioGroup
  • Description: a fieldset radio group for selecting a 1-5 star rating
  • Status: experimental — new (2026-11-15), implemented and unit-tested in every headless library; not yet exercised in a composed flow
  • HTML tag: <fieldset>
  • CSS class: .five-star-rating-radio-group
  • Interactive: no

ARIA

  • role="radiogroup" -- on the <fieldset>, identifies the group as a set of radio buttons
  • aria-label={label} -- the group's accessible name

Keyboard

  • Tab: focus the checked radio, or the first if none is checked
  • ArrowDown / ArrowRight: move to and check the next radio
  • ArrowUp / ArrowLeft: move to and check the previous radio
  • Space: check the focused radio

Props

  • label: string (required) -- accessible name for the group, applied via aria-label
  • children: slot (required) -- the FiveStarRatingRadioInput elements
  • ...restProps: any additional HTML attributes spread onto the fieldset

Markdown

This page as Markdown, for people and AI tools: five-star-rating-radio-group.md