Skip to content
portalbits
Home Docs GitHub(opens in a new tab)

Guides

Get startedFoundationsMotion

Components

All components

Buttons

ButtonIconButton

Inputs

InputSelectTextareaSlider

Selection

CheckboxToggleToggleGroupSwitchRadioGroup

Identity

AvatarBadge

Overlays

DialogPopoverTooltipDropdownMenuAlertDialog

Disclosure

TabsAccordion

Cards

AppCardArticleCardFeatureCard

Content

CarouselSectionHeaderEmptyStateAlertProgressSeparatorRowListRow

Chrome

PortalShellSidebarNavMobileNavTopBarAuthFrameColorSelectorFloatingNav

RadioGroup

One choice from a short, visible list, with optional hints.

Digest cadence

Selected: weekly

Variations

Source

<script lang="ts">
  import 'portal-bits/styles.css';
  import 'portal-bits/tokens.css';
  import type { Snippet } from 'svelte';

  let { children }: { children: Snippet } = $props();
</script>

{@render children()}
<script lang="ts">
  import RadioGroupExample from './RadioGroupExample.svelte';
</script>

<RadioGroupExample orientation={"vertical"} disabled={false} hints={true} />
<script lang="ts">
  import { RadioGroup } from 'portal-bits';
  let {
    orientation = 'vertical',
    disabled = false,
    hints = true,
  }: { orientation?: 'vertical' | 'horizontal'; disabled?: boolean; hints?: boolean } = $props();
  let cadence = $state('weekly');
</script>

<div class="stack">
  <RadioGroup
    label="Digest cadence"
    bind:value={cadence}
    {orientation}
    {disabled}
    options={[
      { value: 'daily', label: 'Daily', description: hints ? 'Every morning at 8:00.' : undefined },
      {
        value: 'weekly',
        label: 'Weekly',
        description: hints ? 'Monday mornings, one summary.' : undefined,
      },
      { value: 'never', label: 'Never', description: hints ? 'Only in-app updates.' : undefined },
    ]}
  />
  <p aria-live="polite">Selected: {cadence}</p>
</div>

<style>
  .stack {
    display: grid;
    gap: 16px;
    width: 360px;
    max-width: 100%;
  }
  p {
    margin: 0;
    color: var(--portal-muted);
    font-size: 13px;
  }
</style>

API reference

These tables list the props and snippets that RadioGroup declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.

Props

NameTypeDefaultRequiredBindingDescription
labelstringNoneYesOne-wayThe visible group label. It names the radio group.
optionsRadioOption[]NoneYesOne-wayChoices as `{ value, label, description?, disabled? }`. A description becomes the hint.
valuestring""NoBindableThe selected value. Empty means nothing is selected.
namestringNoneNoOne-waySubmits the value with a form under this name.
requiredbooleanfalseNoOne-wayRequires a choice before the form submits.
disabledbooleanfalseNoOne-wayDisables every option.
invalidbooleanfalseNoOne-waySets `aria-invalid` and a red edge on each control.
orientation'vertical' | 'horizontal'verticalNoOne-wayStack or row. Arrow keys follow it.
classstring""NoOne-wayExtra classes, added after the component classes.

Forwarded attributes

None. RadioGroup forwards no attributes.

The primitive underneath is a Bits UI peer dependency. Its own options are documented in the Bits UI Radio Group documentation. Only the props listed on this page are part of the RadioGroup contract. No data attributes are documented as stable.

Limits

  • The control borrows the Checkbox geometry and the action green. It is an adaptation.
  • Option labels are plain text. Use Checkbox when a label needs a link.

Related

  • Checkbox
  • ToggleGroup
  • Select
Previous Switch Next Avatar

On this page

  • Preview
  • Source
  • API reference
  • Props
  • Forwarded attributes
  • Limits