Skip to content
bref / ui

Svelte components, simply.

Star

PillChoiceGroup

Single or multiple choices presented as a group of Pills.

Usage

  • Focus
  • Calm
  • Energy
Svelte
<script>
	import { PillChoiceGroup } from 'bref-ui';
	const items = [
		{ id: 'focus', label: 'Focus' },
		{ id: 'calm', label: 'Calm' }
	];
	let selection = $state('focus');
</script>

<PillChoiceGroup {items} aria-label="Mood" bind:selection />

Playground

Live preview

  • Focus
  • Calm
  • Energy
Selected: focus

Settings

Appearance
Interaction
Preview
View generated code
Svelte
<script lang="ts">
	import { PillChoiceGroup } from 'bref-ui';
	import type { PillDataProps } from 'bref-ui/types';
	let items = $state<PillDataProps[]>([
		{
			id: 'focus',
			label: 'Focus',
			icon: {
				name: 'center_focus_strong'
			}
		},
		{
			id: 'calm',
			label: 'Calm'
		},
		{
			id: 'energy',
			label: 'Energy'
		}
	]);
	let selection = $state<string | string[]>('focus');
	const remove = (id: string) => {
		items = items.filter((item) => item.id !== id);
		selection = Array.isArray(selection)
			? selection.filter((selected) => selected !== id)
			: selection === id
				? ''
				: selection;
	};
</script>

<PillChoiceGroup
	{items}
	bind:selection
	aria-label="Interactive choices"
	size="medium"
	variant="neutral"
	color="foreground"
	disabled={false}
	glass={false}
	animateSelected={false}
	onDelete={remove}
/>
<p role="status">
	Selected: {Array.isArray(selection) ? selection.join(', ') || 'none' : selection || 'none'}
</p>

Native selection and form reset

Single selection
  • Focus
  • Calm
  • Energy

Single selection: focus

Multiple selection
  • Focus
  • Calm
  • Energy

Multiple selection: focus, calm

Disabled choices
  • Focus
  • Calm
  • Energy
Animated choices
  • Focus
  • Calm
  • Energy

neutral

primary
  • Focus
  • Calm
  • Energy
secondary
  • Focus
  • Calm
  • Energy
foreground
  • Focus
  • Calm
  • Energy
muted
  • Focus
  • Calm
  • Energy
info
  • Focus
  • Calm
  • Energy
success
  • Focus
  • Calm
  • Energy
warning
  • Focus
  • Calm
  • Energy
error
  • Focus
  • Calm
  • Energy

soft

primary
  • Focus
  • Calm
  • Energy
secondary
  • Focus
  • Calm
  • Energy
foreground
  • Focus
  • Calm
  • Energy
muted
  • Focus
  • Calm
  • Energy
info
  • Focus
  • Calm
  • Energy
success
  • Focus
  • Calm
  • Energy
warning
  • Focus
  • Calm
  • Energy
error
  • Focus
  • Calm
  • Energy
x-small
  • Focus
  • Calm
  • Energy
  • Focus
  • Calm
  • Energy
small
  • Focus
  • Calm
  • Energy
  • Focus
  • Calm
  • Energy
medium
  • Focus
  • Calm
  • Energy
  • Focus
  • Calm
  • Energy
large
  • Focus
  • Calm
  • Energy
  • Focus
  • Calm
  • Energy
x-large
  • Focus
  • Calm
  • Energy
  • Focus
  • Calm
  • Energy

Props and native behavior

PillChoiceGroup props
PropTypeRequiredDefaultDescription
itemsreadonly PillDataProps[]Yes—Choices with unique IDs and visible labels; icons are optional.
selectionstring | string[]Yes—Bindable ID for radio choice, or IDs for checkboxes.
disabledbooleanNofalseDisable every choice.
onDelete(id: string) => voidNoOmittedShow delete buttons and report the item ID; the consumer updates items and selection.
sizeSizeNomediumPill size.
variantExclude<Variant, 'filled'>NoneutralNeutral selects soft; soft selects filled.
colorExclude<Color, 'background'>NoforegroundTheme role for every pill, including selected choices.
animateSelectedbooleanNofalseEnable the pill highlight animation.
glassbooleanNofalseTranslucent paint and backdrop blur for the choices.

Supply aria-label or aria-labelledby for the group name. A string selection uses native radio behavior; an array uses checkboxes. Tab and arrow keys navigate radios; Space toggles focused checkboxes.