Slab
Slab

Form

Radio Group

A set of Radios with one label, one value, and exactly one checked.

Element
<slab-radio-group>
Built on
[role=radiogroup]

Example

Here's a styled version, <slab-styled-radio-group>. It's not in the package — it's an example of what you can build with the headless element. Copy it and make it yours at the bottom of this page. Switch to "As it ships" to see the same markup with the headless element and no CSS at all. That's your starting point.

Styled example As it ships
3,000 psi
Sidewalks and patios.
4,000 psi
House foundations.
5,000 psi
Heavy loads and cold climates.
HTML
<slab-styled-radio-group label="Mix strength">
  <slab-styled-radio-group-radio label="3,000 psi" value="3000">
    <div><strong>3,000 psi</strong><br />Sidewalks and patios.</div>
  </slab-styled-radio-group-radio>
  <slab-styled-radio-group-radio label="4,000 psi" value="4000" checked>
    <div><strong>4,000 psi</strong><br />House foundations.</div>
  </slab-styled-radio-group-radio>
  <slab-styled-radio-group-radio label="5,000 psi" value="5000">
    <div><strong>5,000 psi</strong><br />Heavy loads and cold climates.</div>
  </slab-styled-radio-group-radio>
</slab-styled-radio-group>
3,000 psi
Sidewalks and patios.
4,000 psi
House foundations.
5,000 psi
Heavy loads and cold climates.
HTML
<slab-radio-group label="Mix strength">
  <slab-radio-group-radio label="3,000 psi" value="3000">
    <div><strong>3,000 psi</strong><br />Sidewalks and patios.</div>
  </slab-radio-group-radio>
  <slab-radio-group-radio label="4,000 psi" value="4000" checked>
    <div><strong>4,000 psi</strong><br />House foundations.</div>
  </slab-radio-group-radio>
  <slab-radio-group-radio label="5,000 psi" value="5000">
    <div><strong>5,000 psi</strong><br />Heavy loads and cold climates.</div>
  </slab-radio-group-radio>
</slab-radio-group>

Usage

Install
pnpm add slab-elements lit
ReactLitVueSvelteEmberHTML
import 'slab-elements/radio-group.js';
import 'slab-elements/radio-group.radio.js';

export function MyRadioGroup() {
  return (
    <slab-radio-group label="Delivery" name="delivery">
      <slab-radio-group-radio label="Standard" value="standard" checked>Standard</slab-radio-group-radio>
      <slab-radio-group-radio label="Express" value="express">Express</slab-radio-group-radio>
    </slab-radio-group>
  );
}

MyRadioGroup.jsx React 19 or later, which sets props on custom elements as properties.

import 'slab-elements/radio-group.js';
import 'slab-elements/radio-group.radio.js';
import { html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';

@customElement('my-radio-group')
export class MyRadioGroup extends LitElement {
  render() {
    return html`
      <slab-radio-group label="Delivery" name="delivery">
        <slab-radio-group-radio label="Standard" value="standard" checked>Standard</slab-radio-group-radio>
        <slab-radio-group-radio label="Express" value="express">Express</slab-radio-group-radio>
      </slab-radio-group>
    `;
  }
}

my-radio-group.ts Slab is built on Lit, so its elements are at home in Lit's templates.

<script setup>
import 'slab-elements/radio-group.js';
import 'slab-elements/radio-group.radio.js';
</script>

<template>
  <slab-radio-group label="Delivery" name="delivery">
    <slab-radio-group-radio label="Standard" value="standard" checked>Standard</slab-radio-group-radio>
    <slab-radio-group-radio label="Express" value="express">Express</slab-radio-group-radio>
  </slab-radio-group>
</template>

MyRadioGroup.vue Let Vue's compiler know slab- tags are custom elements with isCustomElement.

<script>
  import 'slab-elements/radio-group.js';
  import 'slab-elements/radio-group.radio.js';
</script>

<slab-radio-group label="Delivery" name="delivery">
  <slab-radio-group-radio label="Standard" value="standard" checked>Standard</slab-radio-group-radio>
  <slab-radio-group-radio label="Express" value="express">Express</slab-radio-group-radio>
</slab-radio-group>

MyRadioGroup.svelte Svelte binds properties and events to custom elements like any other element.

import 'slab-elements/radio-group.js';
import 'slab-elements/radio-group.radio.js';

export const MyRadioGroup = <template>
  <slab-radio-group label="Delivery" name="delivery">
    <slab-radio-group-radio label="Standard" value="standard" checked>Standard</slab-radio-group-radio>
    <slab-radio-group-radio label="Express" value="express">Express</slab-radio-group-radio>
  </slab-radio-group>
</template>;

MyRadioGroup.gjs Ember sets attributes, and a dynamic value like {{this.max}} sets the property when the element has one. {{on}} listens for any event by its name.

<script type="module">
  import 'slab-elements/radio-group.js';
  import 'slab-elements/radio-group.radio.js';
</script>

<slab-radio-group label="Delivery" name="delivery">
  <slab-radio-group-radio label="Standard" value="standard" checked>Standard</slab-radio-group-radio>
  <slab-radio-group-radio label="Express" value="express">Express</slab-radio-group-radio>
</slab-radio-group>

index.html Any bundler (or an import map) takes care of the imports.

The group dispatches no “input” or “change” of its own. Each Radio’s bubble up through it, as a native radio’s do through a <fieldset>, so listen on the group and read its value.

Keyboard

Key What it does
Tab Moves into the group at the checked Radio, or the first, and out again.
Up, Down, Left, Right Moves to the previous or next Radio and checks it, wrapping and skipping disabled ones.
Space Checks the focused Radio.
Enter Submits the form, as on a native radio.

Behavior

<slab-radio-group>

A group of Radios with no visual styles, with one label, one value, and one validity for all of them.

Radios are found by class rather than by tag name, so your subclass of Radio can be named anything. The group does what native radios do for each other: exactly one is checked, exactly one is tabbable, and the arrow keys move between them, wrapping at each end and skipping disabled ones. In a right-to-left page, Left and Right swap, as they do for native radios.

It dispatches no "input" or "change" of its own. A Radio's bubble up through it, as a native radio's do through a <fieldset>, so a listener on the group hears every one and reads the group's value.

Style it through its parts and through :state(disabled), :state(error), and :state(required). How the Radios are arranged is layout, so it's left to the styles around them.

<slab-radio-group-radio>

A Radio with no visual styles. The host is the radio, so style it directly.

There's no native radio inside it. Native radios only group when they share a tree and a name, and each of these is in its own shadow root, so the group does the grouping: it moves focus, checks one at a time, and owns the value.

Radio Group sets its :state(checked) and :state(disabled).

API

<slab-radio-group>

Attributes
Name Type Default Description
label Required string Names it. It's the accessible name, and the visible label where there is one.
disabled boolean false Disables it, as disabled does a native control: the user can't focus or use it, and a form control's value isn't submitted.
hide-label boolean false Hides the label visually and leaves it as the accessible name, for a design that shows the label some other way.
name string '' The name its value is submitted under, as a native control's name.
required boolean false Makes it invalid while it has no value, as required does a native control.
value string '' The value of the checked and enabled Radio. Not reflected, to match a native control.
custom-validity string Makes it invalid with this message, as setCustomValidity() does, and shows the message at once rather than once validity is reported, for an error the page already knows about, such as one from a server. Removing it, or setting it to an empty string, makes it valid again, unless something else makes it invalid.
Properties
Name Type Description
form Read-only HTMLFormElement | null The form it belongs to, or null.
labels Read-only NodeList The <label> elements associated with it, as a native control's labels: each <label for> that names its id, and a <label> around it.
validationMessage Read-only string What's wrong, as the validity message says it: the message given to setCustomValidity() or setValidity(), or else the browser's own. Empty while it's valid.
validity Read-only ValidityState Its ValidityState, as a native control's.
willValidate Read-only boolean Whether its validity is checked when its form submits. It isn't while it's disabled or read-only.
Methods
Signature Description
checkValidity(): boolean Whether its value is valid. Dispatches "invalid" when it isn't, as a native control's does.
focus(options?: FocusOptions): void Focuses it, or the part of it that takes focus.
reportValidity(): boolean Whether its value is valid. When it isn't, dispatches "invalid" and shows the validity message, as a native control's does.
resetValidityFeedback(): void Clears the validity feedback without changing validity.
setCustomValidity(message: string): void Makes it invalid with a message of your own, or valid again with an empty one, as a native control's does.
setValidity(flags?: ValidityStateFlags, message?: string): void Sets its validity and message, as ElementInternals.setValidity() does, for checks of your own beyond setCustomValidity().
Events
Name Type Description
invalid Event When a check finds its value invalid, as a native control's does. Cancel it to leave the validity message unshown, after a blur, a submit or reportValidity(), and focus where it is.
Slots
Name Type Description
(default) Radio
description Element | string Text that describes it, such as a hint or what the validity message means. It's its accessible description.
validity-message Element | string Shown in place of the validity message's text while it's invalid and the message shows, for wording of your own, a translation, or a link. It's part of its accessible description, and validationMessage stays the browser's or setCustomValidity()'s.
CSS parts
Name Description
description Text about the group, and its validity message when it has one
label The label
radios The Radios
validity-message The validity message, which says why the value is invalid
CSS states
Name Description
:state(disabled) While it's disabled.
:state(error) While it's invalid and its validity message shows, which is once its validity is reported, as when its form is submitted.
:state(required) While it's required, for styles such as an asterisk.

<slab-radio-group-radio>

Attributes
Name Type Default Description
label Required string Names it. It's the accessible name, and the visible label where there is one.
checked boolean false Like a native radio, the attribute is the default state and the property is the current one. Style :state(checked) rather than [checked].
disabled boolean false Disables it, as disabled does a native control: the user can't focus or use it, and a form control's value isn't submitted.
value string '' What its Radio Group submits while it's checked.
Properties
Name Type Description
defaultChecked boolean Whether it starts checked, and is checked again when its form resets. It's the checked attribute, as a native input's defaultChecked is, so setting it sets the attribute, and checked with it.
Events
Name Type Description
input Event As the user changes its value, as a native control's does. Setting it from code doesn't dispatch it.
change Event When the user changes its value, as a native control's does. Setting it from code doesn't dispatch it.
Slots
Name Type Description
(default) Element | string The label, plus anything else a design puts in a Radio
CSS states
Name Description
:state(checked) While it's checked.
:state(disabled) While it's disabled.

Copy and own it

<slab-styled-radio-group> isn't in the package. It's an example — copy it into your project and change whatever you want. Keyboard, focus, ARIA, forms, and events all come from the headless element, and the styles only reach in through ::part() and :state(), same as yours would.

ReactLitVueSvelteEmber

The same styles, written from outside the element, so there's nothing to subclass. The CSS styles every <slab-radio-group> on the page. Import tokens.css, the colors and fonts every styled example shares, once, wherever your global styles go.

Each component registers its headless element and imports its CSS. Use it like the element: its props are the element's attributes and properties.

RadioGroup.jsx
import 'slab-elements/radio-group.js';
import './radio-group.css';
import 'slab-elements/radio-group.radio.js';
import './radio-group.radio.css';

export function RadioGroup(props) {
  return <slab-radio-group {...props} />;
}

export function RadioGroupRadio(props) {
  return <slab-radio-group-radio {...props} />;
}
radio-group.css
slab-radio-group {
  color: var(--ink);
  display: grid;
  font-family: var(--font-body);
}

slab-radio-group::part(label) {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-block-end: 0.5rem;
}

slab-radio-group:state(required)::part(label)::after {
  color: var(--ember-deep);
  content: ' *' / '';
}

slab-radio-group::part(radios) {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

/*
  Spaced by what's in it rather than by a gap, so a description with
  nothing in it takes no room, and a control beside the field lines up
  with its bottom edge.
*/
slab-radio-group::part(description) {
  color: var(--ash);
  display: grid;
  font-size: 0.875rem;
}

slab-radio-group > [slot='description'] {
  margin-block-start: 0.375rem;
}

slab-radio-group::part(validity-message) {
  color: var(--ember-deep);
  font-weight: 600;
  margin-block-start: 0.375rem;
}

slab-radio-group::part(validity-message)::before {
  content: '■ ' / '';
}
radio-group.radio.css
slab-radio-group-radio {
  align-items: start;
  background-color: var(--paper);
  border: var(--border);
  cursor: pointer;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: auto 1fr;
  padding: 0.875rem 1rem;
  transition:
    border-color 100ms,
    box-shadow 100ms,
    translate 100ms;
}

slab-radio-group-radio:hover {
  background-color: var(--chalk);
}

slab-radio-group-radio:focus-visible {
  outline: 3px solid var(--ember);
  outline-offset: 2px;
}

slab-radio-group-radio:state(checked) {
  background-color: var(--paper);
  border-color: var(--ember);
  box-shadow: var(--shadow);
  translate: -2px -2px;
}

slab-radio-group-radio:state(disabled) {
  border-style: dashed;
  box-shadow: none;
  color: var(--ash);
  cursor: not-allowed;
  translate: none;
}

/* The mark. Checked, an ember dot sits inside a ring of paper. */
slab-radio-group-radio::before {
  background-color: var(--paper);
  block-size: 1.125rem;
  border: var(--border);
  border-radius: 50%;
  box-sizing: border-box;
  content: '';
  inline-size: 1.125rem;
  margin-block-start: 0.125rem;
}

slab-radio-group-radio:state(checked)::before {
  background: radial-gradient(
    circle,
    var(--ember) 0 0.25rem,
    var(--paper) 0.3rem
  );
  border-color: var(--ember);
}

@media (forced-colors: active) {
  slab-radio-group-radio::before {
    forced-color-adjust: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  slab-radio-group-radio {
    transition: none;
  }
}
tokens.css
:root {
  /* Secondary text. 6.8:1 and 6.9:1 on paper. */
  --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
  --border: 2px solid var(--ink);

  /* Behind disabled and read-only controls, and hovered rows. */
  --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

  /*
    The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
    enough for borders, fills and large text, but not always for small text,
    which takes "--ember-deep".
  */
  --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

  /*
    Orange for small text on paper, and for paper text on it. 5.7:1 and
    7.4:1.
  */
  --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
  --font-body: var(
    --slab-styled-font-body,
    'IBM Plex Sans',
    system-ui,
    sans-serif
  );
  --font-display: var(
    --slab-styled-font-display,
    'Zilla Slab',
    rockwell,
    'Roboto Slab',
    serif
  );
  --font-mono: var(
    --slab-styled-font-mono,
    'IBM Plex Mono',
    ui-monospace,
    monospace
  );
  --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
  --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

  /* The hard, offset shadow a raised surface casts. */
  --shadow: 4px 4px 0 var(--ink);
}

/*
  Forced colors, such as Windows' contrast themes, replace every color that
  isn't a system color, so ember fills and paper marks all become the same
  background, and a checked Checkbox looks like an unchecked one. The palette
  becomes the user's system colors instead, which are kept. Ember is the
  highlight, the color of what's selected, and ember-deep, being for text and
  for paper text on it, is the text color.
*/
@media (forced-colors: active) {
  :host {
    --ash: GrayText;
    --chalk: Canvas;
    --ember: Highlight;
    --ember-deep: CanvasText;
    --ink: CanvasText;
    --paper: Canvas;
  }
}

Under the hood, it's just the headless element, subclassed, with styles set. That's it. To use it, copy these files, swap the tag in @customElement() for one of your own, and import it. tokens.styles.ts holds the colors and fonts every styled example shares, so you only need it once.

radio-group.ts
import { customElement } from 'lit/decorators.js';
import RadioGroup from 'slab-elements/radio-group.js';
import styles from './radio-group.styles.js';
import tokens from './tokens.styles.js';

declare global {
  interface HTMLElementTagNameMap {
    'slab-styled-radio-group': StyledRadioGroup;
  }
}

/**
 * Radio Group, styled: its Radios laid in a row of cards, like bricks in a
 * course, wrapping when there isn't room.
 */
@customElement('slab-styled-radio-group')
export default class StyledRadioGroup extends RadioGroup {
  static override styles = [tokens, styles];
}
radio-group.styles.ts
import { css } from 'lit';

export default css`
  :host {
    color: var(--ink);
    display: grid;
    font-family: var(--font-body);
  }

  [part~='label'] {
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 600;
    margin-block-end: 0.5rem;
  }

  :host(:state(required)) [part~='label']::after {
    color: var(--ember-deep);
    content: ' *' / '';
  }

  [part~='radios'] {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  }

  /*
    Spaced by what's in it rather than by a gap, so a description with
    nothing in it takes no room, and a control beside the field lines up
    with its bottom edge.
  */
  [part~='description'] {
    color: var(--ash);
    display: grid;
    font-size: 0.875rem;
  }

  ::slotted([slot='description']) {
    margin-block-start: 0.375rem;
  }

  [part~='validity-message'] {
    color: var(--ember-deep);
    font-weight: 600;
    margin-block-start: 0.375rem;

    &::before {
      content: '■ ' / '';
    }
  }
`;
radio-group.radio.ts
import { customElement } from 'lit/decorators.js';
import Radio from 'slab-elements/radio-group.radio.js';
import styles from './radio-group.radio.styles.js';
import tokens from './tokens.styles.js';

declare global {
  interface HTMLElementTagNameMap {
    'slab-styled-radio-group-radio': StyledRadio;
  }
}

/**
 * Radio, styled: a card with a round mark in its corner. Checked, its border
 * turns ember and it lifts off the page on a hard shadow.
 */
@customElement('slab-styled-radio-group-radio')
export default class StyledRadio extends Radio {
  static override styles = [tokens, styles];
}
radio-group.radio.styles.ts
import { css } from 'lit';

export default css`
  :host {
    align-items: start;
    background-color: var(--paper);
    border: var(--border);
    cursor: pointer;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: auto 1fr;
    padding: 0.875rem 1rem;
    transition:
      border-color 100ms,
      box-shadow 100ms,
      translate 100ms;
  }

  :host(:hover) {
    background-color: var(--chalk);
  }

  :host(:focus-visible) {
    outline: 3px solid var(--ember);
    outline-offset: 2px;
  }

  :host(:state(checked)) {
    background-color: var(--paper);
    border-color: var(--ember);
    box-shadow: var(--shadow);
    translate: -2px -2px;
  }

  :host(:state(disabled)) {
    border-style: dashed;
    box-shadow: none;
    color: var(--ash);
    cursor: not-allowed;
    translate: none;
  }

  /* The mark. Checked, an ember dot sits inside a ring of paper. */
  :host::before {
    background-color: var(--paper);
    block-size: 1.125rem;
    border: var(--border);
    border-radius: 50%;
    box-sizing: border-box;
    content: '';
    inline-size: 1.125rem;
    margin-block-start: 0.125rem;
  }

  :host(:state(checked))::before {
    background: radial-gradient(
      circle,
      var(--ember) 0 0.25rem,
      var(--paper) 0.3rem
    );
    border-color: var(--ember);
  }

  /*
    Forced colors drop gradients, and the dot is one. Its colors are system
    colors there, so it can keep them.
  */
  @media (forced-colors: active) {
    :host::before {
      forced-color-adjust: none;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    :host {
      transition: none;
    }
  }
`;
tokens.styles.ts
import { css } from 'lit';

/*
  The styled components' palette and type, taken from the logo: ink for the
  courses, ember for the base, paper behind them.

  Each is a short alias for a "--slab-styled-*" property, with the default as
  its fallback. Retheming is "--slab-styled-ember" and the rest on ":root",
  which every shadow root inherits. Were the defaults declared under those
  names here instead, each host's own declaration would shadow the page's.

  Each default is "light-dark()", so the components follow the page's
  "color-scheme": "dark" for dark, "light" for light, and "light dark" to
  follow the operating system. Ink and paper trade places in the dark, so
  ink is always the text and paper always what's behind it. Contrast is given
  as light, then dark.
*/
export default css`
  :host {
    /* Secondary text. 6.8:1 and 6.9:1 on paper. */
    --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
    --border: 2px solid var(--ink);

    /* Behind disabled and read-only controls, and hovered rows. */
    --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

    /*
      The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
      enough for borders, fills and large text, but not always for small text,
      which takes "--ember-deep".
    */
    --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

    /*
      Orange for small text on paper, and for paper text on it. 5.7:1 and
      7.4:1.
    */
    --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
    --font-body: var(
      --slab-styled-font-body,
      'IBM Plex Sans',
      system-ui,
      sans-serif
    );
    --font-display: var(
      --slab-styled-font-display,
      'Zilla Slab',
      rockwell,
      'Roboto Slab',
      serif
    );
    --font-mono: var(
      --slab-styled-font-mono,
      'IBM Plex Mono',
      ui-monospace,
      monospace
    );
    --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
    --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

    /* The hard, offset shadow a raised surface casts. */
    --shadow: 4px 4px 0 var(--ink);
  }

  /*
    Forced colors, such as Windows' contrast themes, replace every color that
    isn't a system color, so ember fills and paper marks all become the same
    background, and a checked Checkbox looks like an unchecked one. The palette
    becomes the user's system colors instead, which are kept. Ember is the
    highlight, the color of what's selected, and ember-deep, being for text and
    for paper text on it, is the text color.
  */
  @media (forced-colors: active) {
    :host {
      --ash: GrayText;
      --chalk: Canvas;
      --ember: Highlight;
      --ember-deep: CanvasText;
      --ink: CanvasText;
      --paper: Canvas;
    }
  }
`;

The same styles, written from outside the element, so there's nothing to subclass. The CSS styles every <slab-radio-group> on the page. Import tokens.css, the colors and fonts every styled example shares, once, wherever your global styles go.

Each component registers its headless element and imports its CSS. Use it like the element: its props are the element's attributes and properties.

RadioGroup.vue
<script setup>
import 'slab-elements/radio-group.js';
import './radio-group.css';
</script>

<template>
  <slab-radio-group><slot /></slab-radio-group>
</template>
RadioGroupRadio.vue
<script setup>
import 'slab-elements/radio-group.radio.js';
import './radio-group.radio.css';
</script>

<template>
  <slab-radio-group-radio><slot /></slab-radio-group-radio>
</template>
radio-group.css
slab-radio-group {
  color: var(--ink);
  display: grid;
  font-family: var(--font-body);
}

slab-radio-group::part(label) {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-block-end: 0.5rem;
}

slab-radio-group:state(required)::part(label)::after {
  color: var(--ember-deep);
  content: ' *' / '';
}

slab-radio-group::part(radios) {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

/*
  Spaced by what's in it rather than by a gap, so a description with
  nothing in it takes no room, and a control beside the field lines up
  with its bottom edge.
*/
slab-radio-group::part(description) {
  color: var(--ash);
  display: grid;
  font-size: 0.875rem;
}

slab-radio-group > [slot='description'] {
  margin-block-start: 0.375rem;
}

slab-radio-group::part(validity-message) {
  color: var(--ember-deep);
  font-weight: 600;
  margin-block-start: 0.375rem;
}

slab-radio-group::part(validity-message)::before {
  content: '■ ' / '';
}
radio-group.radio.css
slab-radio-group-radio {
  align-items: start;
  background-color: var(--paper);
  border: var(--border);
  cursor: pointer;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: auto 1fr;
  padding: 0.875rem 1rem;
  transition:
    border-color 100ms,
    box-shadow 100ms,
    translate 100ms;
}

slab-radio-group-radio:hover {
  background-color: var(--chalk);
}

slab-radio-group-radio:focus-visible {
  outline: 3px solid var(--ember);
  outline-offset: 2px;
}

slab-radio-group-radio:state(checked) {
  background-color: var(--paper);
  border-color: var(--ember);
  box-shadow: var(--shadow);
  translate: -2px -2px;
}

slab-radio-group-radio:state(disabled) {
  border-style: dashed;
  box-shadow: none;
  color: var(--ash);
  cursor: not-allowed;
  translate: none;
}

/* The mark. Checked, an ember dot sits inside a ring of paper. */
slab-radio-group-radio::before {
  background-color: var(--paper);
  block-size: 1.125rem;
  border: var(--border);
  border-radius: 50%;
  box-sizing: border-box;
  content: '';
  inline-size: 1.125rem;
  margin-block-start: 0.125rem;
}

slab-radio-group-radio:state(checked)::before {
  background: radial-gradient(
    circle,
    var(--ember) 0 0.25rem,
    var(--paper) 0.3rem
  );
  border-color: var(--ember);
}

@media (forced-colors: active) {
  slab-radio-group-radio::before {
    forced-color-adjust: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  slab-radio-group-radio {
    transition: none;
  }
}
tokens.css
:root {
  /* Secondary text. 6.8:1 and 6.9:1 on paper. */
  --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
  --border: 2px solid var(--ink);

  /* Behind disabled and read-only controls, and hovered rows. */
  --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

  /*
    The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
    enough for borders, fills and large text, but not always for small text,
    which takes "--ember-deep".
  */
  --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

  /*
    Orange for small text on paper, and for paper text on it. 5.7:1 and
    7.4:1.
  */
  --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
  --font-body: var(
    --slab-styled-font-body,
    'IBM Plex Sans',
    system-ui,
    sans-serif
  );
  --font-display: var(
    --slab-styled-font-display,
    'Zilla Slab',
    rockwell,
    'Roboto Slab',
    serif
  );
  --font-mono: var(
    --slab-styled-font-mono,
    'IBM Plex Mono',
    ui-monospace,
    monospace
  );
  --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
  --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

  /* The hard, offset shadow a raised surface casts. */
  --shadow: 4px 4px 0 var(--ink);
}

/*
  Forced colors, such as Windows' contrast themes, replace every color that
  isn't a system color, so ember fills and paper marks all become the same
  background, and a checked Checkbox looks like an unchecked one. The palette
  becomes the user's system colors instead, which are kept. Ember is the
  highlight, the color of what's selected, and ember-deep, being for text and
  for paper text on it, is the text color.
*/
@media (forced-colors: active) {
  :host {
    --ash: GrayText;
    --chalk: Canvas;
    --ember: Highlight;
    --ember-deep: CanvasText;
    --ink: CanvasText;
    --paper: Canvas;
  }
}

The same styles, written from outside the element, so there's nothing to subclass. The CSS styles every <slab-radio-group> on the page. Import tokens.css, the colors and fonts every styled example shares, once, wherever your global styles go.

Import radio-group.js once, such as in your root layout, and use <slab-radio-group> as is. A Svelte component around it would take slot="…" content as its own slot and drop it.

radio-group.js
import 'slab-elements/radio-group.js';
import './radio-group.css';
import 'slab-elements/radio-group.radio.js';
import './radio-group.radio.css';
radio-group.css
slab-radio-group {
  color: var(--ink);
  display: grid;
  font-family: var(--font-body);
}

slab-radio-group::part(label) {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-block-end: 0.5rem;
}

slab-radio-group:state(required)::part(label)::after {
  color: var(--ember-deep);
  content: ' *' / '';
}

slab-radio-group::part(radios) {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

/*
  Spaced by what's in it rather than by a gap, so a description with
  nothing in it takes no room, and a control beside the field lines up
  with its bottom edge.
*/
slab-radio-group::part(description) {
  color: var(--ash);
  display: grid;
  font-size: 0.875rem;
}

slab-radio-group > [slot='description'] {
  margin-block-start: 0.375rem;
}

slab-radio-group::part(validity-message) {
  color: var(--ember-deep);
  font-weight: 600;
  margin-block-start: 0.375rem;
}

slab-radio-group::part(validity-message)::before {
  content: '■ ' / '';
}
radio-group.radio.css
slab-radio-group-radio {
  align-items: start;
  background-color: var(--paper);
  border: var(--border);
  cursor: pointer;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: auto 1fr;
  padding: 0.875rem 1rem;
  transition:
    border-color 100ms,
    box-shadow 100ms,
    translate 100ms;
}

slab-radio-group-radio:hover {
  background-color: var(--chalk);
}

slab-radio-group-radio:focus-visible {
  outline: 3px solid var(--ember);
  outline-offset: 2px;
}

slab-radio-group-radio:state(checked) {
  background-color: var(--paper);
  border-color: var(--ember);
  box-shadow: var(--shadow);
  translate: -2px -2px;
}

slab-radio-group-radio:state(disabled) {
  border-style: dashed;
  box-shadow: none;
  color: var(--ash);
  cursor: not-allowed;
  translate: none;
}

/* The mark. Checked, an ember dot sits inside a ring of paper. */
slab-radio-group-radio::before {
  background-color: var(--paper);
  block-size: 1.125rem;
  border: var(--border);
  border-radius: 50%;
  box-sizing: border-box;
  content: '';
  inline-size: 1.125rem;
  margin-block-start: 0.125rem;
}

slab-radio-group-radio:state(checked)::before {
  background: radial-gradient(
    circle,
    var(--ember) 0 0.25rem,
    var(--paper) 0.3rem
  );
  border-color: var(--ember);
}

@media (forced-colors: active) {
  slab-radio-group-radio::before {
    forced-color-adjust: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  slab-radio-group-radio {
    transition: none;
  }
}
tokens.css
:root {
  /* Secondary text. 6.8:1 and 6.9:1 on paper. */
  --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
  --border: 2px solid var(--ink);

  /* Behind disabled and read-only controls, and hovered rows. */
  --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

  /*
    The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
    enough for borders, fills and large text, but not always for small text,
    which takes "--ember-deep".
  */
  --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

  /*
    Orange for small text on paper, and for paper text on it. 5.7:1 and
    7.4:1.
  */
  --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
  --font-body: var(
    --slab-styled-font-body,
    'IBM Plex Sans',
    system-ui,
    sans-serif
  );
  --font-display: var(
    --slab-styled-font-display,
    'Zilla Slab',
    rockwell,
    'Roboto Slab',
    serif
  );
  --font-mono: var(
    --slab-styled-font-mono,
    'IBM Plex Mono',
    ui-monospace,
    monospace
  );
  --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
  --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

  /* The hard, offset shadow a raised surface casts. */
  --shadow: 4px 4px 0 var(--ink);
}

/*
  Forced colors, such as Windows' contrast themes, replace every color that
  isn't a system color, so ember fills and paper marks all become the same
  background, and a checked Checkbox looks like an unchecked one. The palette
  becomes the user's system colors instead, which are kept. Ember is the
  highlight, the color of what's selected, and ember-deep, being for text and
  for paper text on it, is the text color.
*/
@media (forced-colors: active) {
  :host {
    --ash: GrayText;
    --chalk: Canvas;
    --ember: Highlight;
    --ember-deep: CanvasText;
    --ink: CanvasText;
    --paper: Canvas;
  }
}

The same styles, written from outside the element, so there's nothing to subclass. The CSS styles every <slab-radio-group> on the page. Import tokens.css, the colors and fonts every styled example shares, once, wherever your global styles go.

Each component registers its headless element and imports its CSS. Use it like the element: its attributes and its content go to the element.

RadioGroup.gjs
import 'slab-elements/radio-group.js';
import './radio-group.css';

export const RadioGroup = <template>
  <slab-radio-group ...attributes>{{yield}}</slab-radio-group>
</template>;
RadioGroupRadio.gjs
import 'slab-elements/radio-group.radio.js';
import './radio-group.radio.css';

export const RadioGroupRadio = <template>
  <slab-radio-group-radio ...attributes>{{yield}}</slab-radio-group-radio>
</template>;
radio-group.css
slab-radio-group {
  color: var(--ink);
  display: grid;
  font-family: var(--font-body);
}

slab-radio-group::part(label) {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-block-end: 0.5rem;
}

slab-radio-group:state(required)::part(label)::after {
  color: var(--ember-deep);
  content: ' *' / '';
}

slab-radio-group::part(radios) {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

/*
  Spaced by what's in it rather than by a gap, so a description with
  nothing in it takes no room, and a control beside the field lines up
  with its bottom edge.
*/
slab-radio-group::part(description) {
  color: var(--ash);
  display: grid;
  font-size: 0.875rem;
}

slab-radio-group > [slot='description'] {
  margin-block-start: 0.375rem;
}

slab-radio-group::part(validity-message) {
  color: var(--ember-deep);
  font-weight: 600;
  margin-block-start: 0.375rem;
}

slab-radio-group::part(validity-message)::before {
  content: '■ ' / '';
}
radio-group.radio.css
slab-radio-group-radio {
  align-items: start;
  background-color: var(--paper);
  border: var(--border);
  cursor: pointer;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: auto 1fr;
  padding: 0.875rem 1rem;
  transition:
    border-color 100ms,
    box-shadow 100ms,
    translate 100ms;
}

slab-radio-group-radio:hover {
  background-color: var(--chalk);
}

slab-radio-group-radio:focus-visible {
  outline: 3px solid var(--ember);
  outline-offset: 2px;
}

slab-radio-group-radio:state(checked) {
  background-color: var(--paper);
  border-color: var(--ember);
  box-shadow: var(--shadow);
  translate: -2px -2px;
}

slab-radio-group-radio:state(disabled) {
  border-style: dashed;
  box-shadow: none;
  color: var(--ash);
  cursor: not-allowed;
  translate: none;
}

/* The mark. Checked, an ember dot sits inside a ring of paper. */
slab-radio-group-radio::before {
  background-color: var(--paper);
  block-size: 1.125rem;
  border: var(--border);
  border-radius: 50%;
  box-sizing: border-box;
  content: '';
  inline-size: 1.125rem;
  margin-block-start: 0.125rem;
}

slab-radio-group-radio:state(checked)::before {
  background: radial-gradient(
    circle,
    var(--ember) 0 0.25rem,
    var(--paper) 0.3rem
  );
  border-color: var(--ember);
}

@media (forced-colors: active) {
  slab-radio-group-radio::before {
    forced-color-adjust: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  slab-radio-group-radio {
    transition: none;
  }
}
tokens.css
:root {
  /* Secondary text. 6.8:1 and 6.9:1 on paper. */
  --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
  --border: 2px solid var(--ink);

  /* Behind disabled and read-only controls, and hovered rows. */
  --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

  /*
    The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
    enough for borders, fills and large text, but not always for small text,
    which takes "--ember-deep".
  */
  --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

  /*
    Orange for small text on paper, and for paper text on it. 5.7:1 and
    7.4:1.
  */
  --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
  --font-body: var(
    --slab-styled-font-body,
    'IBM Plex Sans',
    system-ui,
    sans-serif
  );
  --font-display: var(
    --slab-styled-font-display,
    'Zilla Slab',
    rockwell,
    'Roboto Slab',
    serif
  );
  --font-mono: var(
    --slab-styled-font-mono,
    'IBM Plex Mono',
    ui-monospace,
    monospace
  );
  --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
  --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

  /* The hard, offset shadow a raised surface casts. */
  --shadow: 4px 4px 0 var(--ink);
}

/*
  Forced colors, such as Windows' contrast themes, replace every color that
  isn't a system color, so ember fills and paper marks all become the same
  background, and a checked Checkbox looks like an unchecked one. The palette
  becomes the user's system colors instead, which are kept. Ember is the
  highlight, the color of what's selected, and ember-deep, being for text and
  for paper text on it, is the text color.
*/
@media (forced-colors: active) {
  :host {
    --ash: GrayText;
    --chalk: Canvas;
    --ember: Highlight;
    --ember-deep: CanvasText;
    --ink: CanvasText;
    --paper: Canvas;
  }
}