PillButton
A PillButton is a checkbox styled as a pill for independent filters and multiple choices.
Usage
<script>
import { PillButton } from 'fluentui-svelte';
let unread = $state(false);
</script>
<PillButton name="filter" value="unread" bind:checked={unread}>Unread</PillButton> Appearance
Choose filled, outline or brand appearance. Each appearance supports selected and unselected states.
Size
size changes height and typography together: small uses 24px/12px, medium 32px/14px, large 40px/16px and extra-large 48px/18px. Each pair gives the control height and font in pixels.
Shape
Use shape to choose circular, rounded or square corners. The default is circular.
Selection and binding
Use bind:checked to keep selection synchronized with your state. Clicking the pill or pressing Space toggles the native checkbox; external state changes update it too.
Disabled
Use disabled on individual pills or a fieldset around several pills. Disabled choices cannot receive focus, toggle or submit values, including when selected.
Icons
Use icon to show a Fluent icon before the text. Icons are decorative; give an icon-only pill an accessible name with aria-label or aria-labelledby.
Avatar
Use media for a decorative Avatar. The snippet receives the current shape; forward it to the avatar so their shapes stay synchronized. A component receives shape as a prop. Media scales with size, retains a uniform 4px inset and takes precedence over icon.
Multiple filters
Use a fieldset and legend to label independent choices. Bind each pill with bind:checked. Reuse name to submit multiple values in one form field.
Forms
Set name and value to submit a selected pill. The native form, required, defaultChecked and disabled attributes are supported. Reset restores defaultChecked and updates bind:checked. An explicit checked state takes precedence initially. required applies to each pill individually.
External form owner
Use form to associate a pill with the id of a form that does not contain it. Submission, validation and reset still use the native checkbox.
Required and validation
required applies to this particular checkbox. Pair aria-invalid with an explanatory message linked through aria-describedby. Invalid text, border and error messages use --fs-system-critical.
Using with Label
Wrap PillButton in Label to name the native checkbox. Configure label and labelPosition on the wrapper. It also names icon-only pills. For standalone pills, use visible text, aria-label or aria-labelledby.
PillButton props
| Name | Type | Default | Description |
|---|---|---|---|
ref bindable | HTMLInputElement | null | The DOM reference of the native checkbox. | |
wrapperRef bindable | HTMLElement | null | The DOM reference of the pill surface. | |
wrapperAttributes | HTMLAttributes<HTMLSpanElement> | Attributes for the pill surface. Input attributes belong on the component itself. | |
checked bindable | boolean | null | Whether the pill is checked. When omitted, defaultChecked determines the initial state. | |
appearance | 'filled' | 'outline' | 'brand' | 'filled' | The pill appearance. |
size | 'small' | 'medium' | 'large' | 'extra-large' | 'medium' | The height and text size of the pill: small is 24px/12px, medium is 32px/14px, large is 40px/16px and extra-large is 48px/18px. |
shape | 'circular' | 'rounded' | 'square' | 'circular' | The shape of the pill: circular, rounded or square. |
icon | Snippet<[SVGAttributes<SVGElement>]> | Component<SVGAttributes<SVGElement>> | An optional decorative Fluent icon before the content. | |
media | Snippet<[PillButtonMediaProps]> | Component<PillButtonMediaProps> | Decorative media before the text, usually an Avatar. Receives the pill's current shape; forward it to the media component. Fits the control height with a uniform 4px inset. Takes precedence over icon. | |
children | Snippet | The visible label. Provide aria-label or aria-labelledby when there is no visible text. | |
HTMLInputAttributes without type, children, checked, size, on: |

