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>Default</Checkbox>

Label

Pass the label text as children. The root is a <div>, and the text renders in a separate <label> associated with the checkbox through for and id. Inside a Label, it is not rendered: the Label names the checkbox.

<Checkbox>I'm Labeled</Checkbox>
<Checkbox aria-label="Without visible text" />

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.

Form Control Attributes

Attributes and events apply to the native form field; ref gives you access to it. For the container, use wrapperAttributes and wrapperRef.

Checkbox Props

NameTypeDefaultDescription
ref bindableHTMLInputElement | nullThe DOM reference of the checkbox element.
wrapperRef bindableHTMLDivElement | nullThe DOM reference of the checkbox wrapper element.
wrapperAttributesHTMLAttributesThe attributes to spread on the wrapper element.
indeterminate bindableboolean | nullRenders 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 bindableboolean | nullWhether the checkbox is checked.
disabledbooleanDisables the user interaction.
childrenSnippetThe content of the label associated with the checkbox. Inside a Label, it is not rendered
HTMLInputAttributes without on:, children
Edit this Doc View as Markdown