TIS Design System

Toggle

Toggles (switches) permitem que o usuário ative ou desative uma configuração instantaneamente. Construido com um checkbox nativo estilizado e role="switch".Toggles (switches) let users turn a setting on or off instantly. Built with a styled native checkbox and role="switch".

Quando usarWhen to use

Use toggles quandoUse toggles when
O usuário precisa ativar/desativar uma configuração com efeito imediato. Modo escuro, notificações, feature flags, preferencias de salvamento automatico.The user needs to turn an on/off setting that takes effect immediately. Dark mode, notifications, feature flags, auto-save preferences.
Não use toggles quandoDon't use toggles when
A mudança requer envio de formulário — use um Checkbox. Quando há mais de duas opcoes — use Radio ou Select.The change requires form submission — use a Checkbox instead. When there are more than two options — use Radio or Select.

AnatomiaAnatomy

1 2 3 4
1 Input (.ds-toggle) — <input type="checkbox"> estilizado com role="switch".
2 Track — fundo CSS que muda de cor conforme o estado checked.
3 Thumb — pseudo-elemento CSS que desliza esquerda/direita.
4 Content Frame (.ds-toggle__content) — envolve label, description e helper.
1 Input (.ds-toggle) — styled <input type="checkbox"> with role="switch".
2 Track — CSS background that changes color based on checked state.
3 Thumb — CSS pseudo-element that slides left/right.
4 Content Frame (.ds-toggle__content) — wraps label, description and helper text.

PadrãoDefault

<label class="ds-toggle-label">
  <input type="checkbox" class="ds-toggle" role="switch">
  <span class="ds-toggle__content">
    <span class="ds-toggle__label">Notifications</span>
  </span>
</label>

Com descrição e texto auxiliarWith description and helper text

<label class="ds-toggle-label">
  <input type="checkbox" class="ds-toggle" role="switch" checked>
  <span class="ds-toggle__content">
    <span class="ds-toggle__label">Automatic updates</span>
    <span class="ds-toggle__description">Keep your software up to date...</span>
    <span class="ds-toggle__helper">Requires a stable internet connection.</span>
  </span>
</label>

TamanhosSizes

<!-- Small -->
<input type="checkbox" class="ds-toggle ds-toggle--sm" role="switch">

<!-- Medium -->
<input type="checkbox" class="ds-toggle" role="switch">

<!-- Large -->
<input type="checkbox" class="ds-toggle ds-toggle--lg" role="switch">

DesabilitadoDisabled

<input type="checkbox" class="ds-toggle" role="switch" disabled>

EstadosStates

StateCSS triggerVisual changeToken
Off---Neutral track with dark thumbcomponent.toggle.track.fill.off.default, component.toggle.thumb.fill.off.default
Off hover:hoverDarker neutral track/thumbcomponent.toggle.track.fill.off.hover, component.toggle.thumb.fill.off.hover
On:checkedPrimary track with light thumbcomponent.toggle.track.fill.on.default, component.toggle.thumb.fill.on.default
On hover:checked:hoverDarker primary trackcomponent.toggle.track.fill.on.hover, component.toggle.thumb.fill.on.hover
Focus:focus-visible2px outline ringcomponent.toggle.focus-ring.radius.default + component.focus-ring.*
Disabled[disabled]Muted track, thumb and labelcomponent.toggle.track.fill.*.disabled, semantic.content.disabled

Boas práticasBest practices

Faça
Labels descrevem a configuração: "Dark mode", "Email notifications".Labels describe the setting: "Dark mode", "Email notifications".
Não faça
"Enable dark mode" e redundante com o estado do toggle."Enable dark mode" is redundant with the toggle state itself.
Faça
Posicione o toggle a esquerda do conteúdo. O alinhamento deve ser ao topo.Place toggle left of content. Alignment should be to the top.
Não faça
Não use toggle para ações que precisam de confirmação. Use um Button + dialog.Don't use toggle for actions needing confirmation. Use a Button + dialog instead.

Diretrizes de conteúdoContent guidelines

RegraRuleExemploExample
Use um substantivo para o labelUse a noun phrase for the label"Dark mode", "Auto-save", "Email notifications"
Não use "Enable/Disable"Don't use "Enable/Disable""Notifications" — não "Enable notifications""Notifications" — not "Enable notifications"
Mantenha labels curtos (1-3 palavras)Keep labels short (1-3 words)"Auto-save" — não "Automatically save my work every 5 minutes""Auto-save" — not "Automatically save my work every 5 minutes"

Mapeamento de tokensToken mapping

PropriedadePropertyToken ComponentVariável CSSCSS variable
target height/gapcomponent.toggle.target.{height,gap}.*--ds-toggle-target-*
track sizecomponent.toggle.track.{width,height}.*--ds-toggle-track-*
track fillcomponent.toggle.track.fill.*.*--ds-toggle-track-fill-*
track bordercomponent.toggle.track.border-color.*.*--ds-toggle-track-border-color-*
thumb size/fillcomponent.toggle.thumb.{size,fill}.*--ds-toggle-thumb-*
focus ringcomponent.toggle.focus-ring.radius.default + component.focus-ring.*--ds-focus-ring-* + --ds-toggle-focus-ring-radius-default
label/helper/descriptioncomponent.form-field.*--ds-form-field-*

Classes CSSCSS classes

ClasseClassDescriçãoDescription
ds-toggleSwitch estilizado (checkbox nativo)Custom styled switch (native checkbox)
ds-toggle-labelWrapper do controle (envolve track + conteúdo)Control wrapper (wraps track + content)
ds-toggle--smTamanho pequeno (28x16px)Small size (28x16px)
ds-toggle--lgTamanho grande (56x32px)Large size (56x32px)
ds-toggle__contentFrame vertical com label, description e helper textVertical frame stacking label, description, and helper text
ds-toggle__labelTexto do label (label/md)Label text (label/md)
ds-toggle__descriptionTexto descritivo multiline (body/sm)Multiline description text (body/sm)
ds-toggle__helperTexto auxiliar (caption/sm)Helper annotation (caption/sm)

Interação por tecladoKeyboard interaction

TeclaKeyAçãoAction
TabMove o foco para o toggleMoves focus to the toggle
SpaceAlterna ligado/desligadoToggles on/off
EnterNÃO alterna (comportamento padrão de switch)Does NOT toggle (standard switch behavior)

Toggles desabilitados ([disabled]) são removidos da ordem de tabulação automaticamente pelo navegador.Disabled toggles ([disabled]) are removed from tab order automatically by the browser.

AccessibilityAccessibility

Critério WCAGWCAG criterionRequisitoRequirementStatus
4.1.2 Name, Role, Value (A)role="switch" + aria-checked gerenciados pelo checkbox nativorole="switch" + aria-checked managed by native checkbox
2.4.11 Focus Appearance (AA)Focus ring visível via :focus-visibleFocus ring visible via :focus-visible
2.5.8 Target Size min (AA)Label estende a área de clique além do toggleLabel extends click target beyond the toggle itself
1.4.1 Use of Color (A)Posição + cor comunicam o estado (thumb desliza esquerda/direita)Position + color both communicate state (thumb slides left/right)
Resumo de atributos ARIAARIA attributes summary
role="switch" — obrigatório no checkbox para que leitores de tela o anunciem como switch.
aria-checked — gerenciado automaticamente pelo <input type="checkbox"> nativo.
O conteúdo textual deve estar dentro de .ds-toggle__content.
role="switch" — required on the checkbox so screen readers announce it as a switch.
aria-checked — managed automatically by the native <input type="checkbox">.
Textual content must be inside .ds-toggle__content.

RelacionadosRelated