enes

Checkbox

Represents a control that a user can select (check) or clear (uncheck). A CheckBox can also report its value as indeterminate.

Usage

<script>
  import { Checkbox } from 'fluentui-svelte';
</script>

<Checkbox wrapperAs="label">Default</Checkbox>

Label

To display a visible label, set `wrapperAs="label"` and pass the label text as children. The wrapper then renders as a `<label>` element that wraps the input.

<Checkbox wrapperAs="label">I'm Labeled</Checkbox>
<Checkbox>I'm Unlabeled</Checkbox>

Indeterminate

The `indeterminate` prop sets the checkbox to an indeterminate state, which is useful for representing a mixed selection.

Disabled

The `disabled` prop disables the checkbox, preventing user interaction. It accepts a boolean value.

Checkbox Props

NameTypeDefaultDescription
ref bindableHTMLInputElementThe DOM reference of the checkbox element.
wrapperAs'div' | 'label''label'The DOM element used to wrap the checkbox. `label` associates the children with the input; switch to `div` when the field is wrapped in a `<Label>` of its own.
wrapperRef bindableHTMLDivElement | HTMLLabelElementThe DOM reference of the checkbox wrapper element.
wrapperAttributesPolymorphicPropsThe attributes to spread on the wrapper element.
indeterminate bindablebooleanRenders the checkbox in its mixed state, neither checked nor unchecked.
namestring | nullidThe name submitted with the form. Falls back to the id of the checkbox.
groupstring | nullThe value of the group of checkboxes this input belongs to.
checked bindablebooleanWhether the checkbox is checked.
disabledbooleanDisables the user interaction.
childrenSnippetThe content of the label. Only rendered when wrapperAs is set to label.
HTMLInputAttributes without on:, children