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>

Component API

A brief explanation of the props that really need explaining. You can see the rest of the props here.

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.

Checked

The `checked` prop determines whether the checkbox is checked or not. It accepts a boolean value.

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.

Value

The `value` prop sets the value of the checkbox input. It is useful when the checkbox is part of a form submission.

Checkbox Props

NameTypeDescription
wrapperAs'div' \| 'label'The element the wrapper renders as. Set to `label` to show a visible label. Defaults to `div`.
childrenSnippetLabel content rendered next to the input. Only allowed when `wrapperAs="label"`.
checkedbooleanDetermines if the checkbox is checked.
indeterminatebooleanSets the checkbox to an indeterminate state.
disabledbooleanDisables the checkbox, preventing user interaction.
valuestringThe value of the checkbox input, useful for form submissions.
wrapperAttributesobjectAdditional attributes for the wrapper element.
refbindable HTMLInputElementThe DOM reference of the checkbox input element.
wrapperRefbindable HTMLDivElement \| HTMLLabelElementThe DOM reference of the checkbox wrapper element.
Input AttributesAdditional attributes for the checkbox input element.