enes

PillButton

A PillButton is a checkbox styled as a pill for independent filters and multiple choices.

Unread Unread Unread

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.

filled filled · Selected outline outline · Selected brand brand · Selected

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.

small small · Selected medium medium · Selected large large · Selected extra-large extra-large · Selected

Shape

Use shape to choose circular, rounded or square corners. The default is circular.

circular circular · Selected rounded rounded · Selected square square · Selected

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.

Unread Not selected

Disabled

Use disabled on individual pills or a fieldset around several pills. Disabled choices cannot receive focus, toggle or submit values, including when selected.

Disabled Selected Outline Brand
Disabled filters Unread

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.

Calendar Selected Calendar Calendar Calendar

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.

Alex Alex Alex Alex Alex Alex Alex Alex

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.

Message filters
Unread Flagged Attachments
{"unread":true,"flagged":false,"attachments":false}

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.

Unread Flagged

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.

Unread

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.

Accept notifications

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.

Unread

PillButton props

NameTypeDefaultDescription
ref bindableHTMLInputElement | nullThe DOM reference of the native checkbox.
wrapperRef bindableHTMLElement | nullThe DOM reference of the pill surface.
wrapperAttributesHTMLAttributes<HTMLSpanElement>Attributes for the pill surface. Input attributes belong on the component itself.
checked bindableboolean | nullWhether 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.
iconSnippet<[SVGAttributes<SVGElement>]> | Component<SVGAttributes<SVGElement>>An optional decorative Fluent icon before the content.
mediaSnippet<[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.
childrenSnippetThe visible label. Provide aria-label or aria-labelledby when there is no visible text.
HTMLInputAttributes without type, children, checked, size, on:
Edit this Doc View as Markdown