Switch

Toggle on/off/mixed. Track de 32×16px com knob de 14px. Suporta estado indeterminado (mixed) com ícone de traço.

Formulário / Controles
Figma: 1359:1740

Preview

On / Off
Mixed (indeterminado)
Disabled

Código

Copie e cole no Claude Code para implementar este componente em pixel-perfect usando os tokens TRDR.

<!-- On -->
<button class="trdr-switch" role="switch" aria-checked="true">
  <span class="trdr-switch-track trdr-switch-track-on">
    <span class="trdr-switch-knob"></span>
  </span>
  <span>Ativar notificações</span>
</button>

<!-- Off -->
<button class="trdr-switch" role="switch" aria-checked="false">
  <span class="trdr-switch-track">
    <span class="trdr-switch-knob"></span>
  </span>
  <span>Ativar notificações</span>
</button>

<!-- Mixed -->
<button class="trdr-switch" role="switch" aria-checked="mixed">
  <span class="trdr-switch-track trdr-switch-track-mixed">
    <span class="trdr-switch-mixed-icon">
      <span class="trdr-switch-mixed-dash"></span>
    </span>
  </span>
  <span>Ativar notificações</span>
</button>

<!-- Disabled -->
<button class="trdr-switch" role="switch" aria-checked="false" disabled>
  <span class="trdr-switch-track">
    <span class="trdr-switch-knob"></span>
  </span>
  <span>Desativado</span>
</button>

Dimensões

VarianteLarguraAltura
Track32px16px
Knob14px14px
Componente total24px

Props / Variantes

PropTipoValores
Typeenum
OnOffMixed
Disabledboolean
truefalse

Tokens Utilizados

PropriedadeTokenValor
Track On / Mixedaction-brand-default
#00D4FF
Track Offsurface-primary
#4A4A4A
Track Disabledsurface-secondary
#222222
Knob
#FFFFFF
Focus borderborder-focus
#00D4FF
Label padrãocontent-primary
#FFFFFF
Label disabledcontent-tertiary
#A4A4A4

Anatomia

[button role=switch height=24px gap=8px]
  └── [Track 32×16px radius-full bg=action-brand-default|surface-primary]
        └── [Knob 14×14px radius-full white, esquerda=Off, direita=On]
        └── [Mixed: traço horizontal 8×1.5px branco centralizado]
  └── [Label 12px/500 font-secondary]

Notas

Knob: top=1px, left=1px (Off) ou right=1px (On). Foco via :focus-visible com outline border-focus.