Skip to content

Switch ​

Sizes

Loading...

States

Loading...

A Switch component for toggling settings.

  • Tag: <flint-switch>
  • Class: FlintSwitch

Import ​

ts
import 'flint-ui'; // auto-registers all
// or
import { FlintSwitch } from 'flint-ui';

Usage ​

html
<flint-switch></flint-switch>

Properties ​

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseWhether the switch is toggled on.
disableddisabledbooleanfalseDisables the switch and prevents interaction.
requiredrequiredbooleanfalseMarks the switch as required for form validation.
sizesize'sm' | 'md' | 'lg''md'Size of the switch control.
labellabelstring''Visible label text displayed next to the switch.
namenamestring''Form field name used when submitting form data.
valuevaluestring'on'Value submitted with form data when checked.
defaultCheckeddefault-checkedbooleanfalseInitial checked state for uncontrolled usage.
ariaLabelaria-labelstring | nullnullAccessible label for screen readers when no visible label is provided.

Events ​

EventDetailDescription
flint-switch-change—Dispatched when the switch state changes. Detail: { checked: boolean }

Slots ​

NameDescription
icon-onOptional icon to show when the switch is ON.
icon-offOptional icon to show when the switch is OFF.
(default)Optional label content (used when the label prop is not set).

CSS Custom Properties ​

PropertyDefault
--flint-switch-thumb-color—
--flint-switch-width—
--flint-switch-height—
--flint-switch-bg—
--flint-switch-bg-on—
--flint-switch-thumb-offset—
--flint-switch-thumb-size—
--flint-switch-thumb-bg—
--flint-secondary-color—
--flint-primary-color—
--flint-font-family—
--flint-shadow-sm—
--flint-text-color-muted—
--flint-text-color—