Back to Tooljet

Switch — Rocket Design Spec

frontend/src/components/ui/Rocket/Switch/Switch.spec.md

3.20.154-lts2.0 KB
Original Source

Switch — Rocket Design Spec

<!-- figma: https://www.figma.com/design/XQdM9x8x9YHcj1lUK8abUG/Rocket-components?node-id=93-52599 --> <!-- synced: 2026-03-25 -->

Overview

Toggle switch component for binary on/off states. Single-part component (Shape D) wrapping shadcn Switch primitive (Radix @radix-ui/react-switch). No visual variants, no size variants — token overrides only.

Dimensions

ElementSizeTailwind
track28×16 (inc. 2px transparent border)tw-h-4 tw-w-7 tw-border-2
thumb12×12tw-h-3 tw-w-3
thumb travel0 → 12pxdata-[state=unchecked]:tw-translate-x-0 / data-[state=checked]:tw-translate-x-3

Props

PropTypeValuesDefault
disabledbooleanfalse

States

StateBehaviour
unchecked (default)Off appearance — neutral track
checkedOn appearance — accent track, thumb slides right
disabledReduced opacity, no pointer events
focus-visibleFocus ring

Token Mapping

ElementStateToolJet tokenTailwind class
track bguncheckedswitch-tagtw-bg-switch-tag
track bgcheckedswitch-background-ondata-[state=checked]:tw-bg-switch-background-on
thumb bgswitch-tabtw-bg-switch-tab
trackdisableddisabled:tw-opacity-50 disabled:tw-cursor-not-allowed disabled:tw-pointer-events-none
trackfocusinteractive-focus-outlinefocus-visible:tw-ring-2 focus-visible:tw-ring-interactive-focus-outline focus-visible:tw-ring-offset-1

CVA Shape

Shape D — no CVA (static classes)

Notes

  • No variants or sizes — single visual appearance
  • Track transitions between switch-background-off and switch-background-on on toggle
  • Thumb uses switch-tab token (white in light, dark in dark mode)
  • tw-border-solid required on any border elements (preflight is off)
  • Radix v1 uses data-[state=checked] / data-[state=unchecked] attributes