enes

Toggle Switch

A toggle switch represents a physical switch that allows someone to choose between two mutually exclusive options. For example, 'On/Off' and 'Show/Hide'. Choosing an option should produce an immediate result.

Usage

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

<ToggleSwitch aria-label="Notifications" />
<ToggleSwitch label="Toggle me" />
<ToggleSwitch label="I'm disabled" disabled />

States

A toggle switch can be labeled, checked or disabled.

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.

Component Props

NameTypeDefaultDescription
checked bindableboolean | nullWhether the switch is on.
ref bindableHTMLInputElement | nullThe DOM reference of the input element.
labelstringThe label displayed next to the input element. Inside a Label, it is not rendered
wrapperAttributesHTMLAttributesThe attributes to spread on the wrapper element.
wrapperRef bindableHTMLDivElement | nullThe DOM reference of the wrapper element.
Element Attributes (input)
Edit this Doc View as Markdown