Documentation
Feedback
Guides
Storefront Development

Storefront Development
Storefront development
Toggle

Toggle is a customized checkbox input styled to look like a switch button.

The Toggle is a customized checkbox input styled to look like a switch button.
Example
Code

Usage

Import the component


_10
import { Toggle } from "@faststore/ui";

Import styles

To apply styles, include the following in your stylesheet:

_10
@import "@faststore/ui/src/components/molecules/Toggle/styles.scss";


Examples

Variants

Checked

Example
Code

Disabled

Example
Code

Design tokens

Local tokenDefault value/Global token linked
--fs-toggle-heightcalc(var(--fs-control-min-height) / 1.75)
--fs-toggle-bkg-color
var(--fs-control-bkg)
--fs-toggle-bkg-color-hover
var(--fs-color-primary-bkg-light)
--fs-toggle-shadowvar(--fs-shadow)
--fs-toggle-shadow-hovervar(--fs-shadow)
--fs-toggle-border-color
var(--fs-border-color)
--fs-toggle-border-color-hover
var(--fs-border-color-hover)
--fs-toggle-border-radiusvar(--fs-border-radius)
--fs-toggle-border-widthvar(--fs-border-width)
--fs-toggle-transition-timingvar(--fs-transition-timing)
--fs-toggle-transition-propertyvar(--fs-transition-property)
--fs-toggle-transition-functionvar(--fs-transition-function)

Nested Elements

Knob

Local tokenDefault value/Global token linked
--fs-toggle-knob-shadowvar(--fs-shadow)
--fs-toggle-knob-bkg-color
var(--fs-color-primary-bkg)
--fs-toggle-knob-bkg-color-hover
var(--fs-toggle-border-color-hover)
--fs-toggle-knob-border-radiusvar(--fs-border-radius-small)
--fs-toggle-knob-border-color
var(--fs-toggle-knob-bkg-color)
--fs-toggle-knob-border-color-hover
var(--fs-toggle-knob-bkg-color-hover)
--fs-toggle-knob-border-widthvar(--fs-border-width-thick)
--fs-toggle-knob-checked-bkg-color
var(--fs-control-bkg)
--fs-toggle-knob-checked-border-color
var(--fs-toggle-knob-checked-bkg-color)
--fs-toggle-knob-disabled-bkg-color
var(--fs-color-neutral-5)
--fs-toggle-knob-disabled-border-color
var(--fs-toggle-knob-disabled-bkg-color)

Icon

Local tokenDefault value/Global token linked
--fs-toggle-knob-icon-colortransparent
--fs-toggle-knob-icon-checked-color
var(--fs-toggle-checked-bkg-color)
--fs-toggle-knob-icon-checked-color-hover
var(--fs-toggle-checked-bkg-color-hover)
--fs-toggle-knob-icon-disabled-color
var(--fs-toggle-disabled-bkg-color)

Design tokens: Checked

Local tokenDefault value/Global token linked
--fs-toggle-checked-bkg-color
var(--fs-color-primary-bkg-active)
--fs-toggle-checked-bkg-color-hover
var(--fs-color-primary-bkg-hover)
---fs-toggle-checked-border-color
var(--fs-toggle-checked-bkg-color)
--fs-toggle-knob-icon-disabled-color
var(--fs-toggle-checked-bkg-color-hover)

Design tokens: Disabled

Local tokenDefault value/Global token linked
--fs-toggle-disabled-bkg-color
var(--fs-color-disabled-bkg)
---fs-toggle-disabled-border-color
var(--fs-border-color-disabled)

Data attributes

You can target and override Toggle styles using the following data attributes:
data-fs-toggle
data-fs-toggle-variant="horizontal"
data-fs-toggle-variant="vertical"
data-fs-toggle-knob

Props

NameTypeDescriptionDefault
testIdstringID to find this component in testing tools (e.g.: cypress, testing library, and jest).fs-toggle
id*stringID to identify input and corresponding label.
disabledfalse | trueSpecifies that this input should be disabled.
variant"horizontal" | "vertical"Controls the component's direction.horizontal

Contributors
2
Photo of the contributor
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
2
Photo of the contributor
Photo of the contributor
On this page