Skip to content

Switch ​

Sizes

Loading...

States

Loading...

A Switch component for toggling settings.

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

Import ​

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

Usage ​

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

Properties ​

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseCurrent checked state (controlled). When set, the component reflects this state and does not manage its own state.
disableddisabledbooleanfalseDisables the switch and prevents interaction.
requiredrequiredbooleanfalseMarks the switch as required for form validation.
sizesizeSize'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 (uncontrolled). Only used on first render; ignored after mount.
ariaLabelaria-labelstring | nullnullAccessible label for screen readers when no visible label is provided.

Events ​

EventDetailDescription
flint-switch-change&#123; checked: boolean &#125;Dispatched when the switch state changes. Detail: &#123; checked: boolean &#125;

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 Parts ​

NameDescription
baseThe switch's base wrapper element.
controlThe switch track element.
thumbThe switch thumb (knob) element.
labelThe label text element.

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—