RadioGroup
One choice from a short, visible list, with optional hints.
Digest cadence
Selected: weekly
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
| Name | Type | Default | Required | Binding | Description |
|---|---|---|---|---|---|
label | string | None | Yes | One-way | The visible group label. It names the radio group. |
options | RadioOption[] | None | Yes | One-way | Choices as `{ value, label, description?, disabled? }`. A description becomes the hint. |
value | string | "" | No | Bindable | The selected value. Empty means nothing is selected. |
name | string | None | No | One-way | Submits the value with a form under this name. |
required | boolean | false | No | One-way | Requires a choice before the form submits. |
disabled | boolean | false | No | One-way | Disables every option. |
invalid | boolean | false | No | One-way | Sets `aria-invalid` and a red edge on each control. |
orientation | 'vertical' | 'horizontal' | vertical | No | One-way | Stack or row. Arrow keys follow it. |
class | string | "" | No | One-way | Extra 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.