ComponentesComponents

Switch

Interruptor para ajustes que se aplican al instante.Toggle for settings applied instantly.

DiseñoDesign: coss ui (MIT) · switch.tsxMITambos · densidaddensity media · sobriaMarkdownJSON

CódigoCode

<div class="c-switch-list">
  <label class="c-switch-label"><span class="c-switch-label__text">Modo avión <span class="c-switch-label__description">Desactiva todas las conexiones</span></span><span class="c-switch"><input class="c-switch__input" type="checkbox" role="switch"><span class="c-switch__thumb"></span></span></label>
  <label class="c-switch-label"><span class="c-switch-label__text">Avisos por correo</span><span class="c-switch"><input class="c-switch__input" type="checkbox" role="switch" checked><span class="c-switch__thumb"></span></span></label>
  <label class="c-switch-label"><span class="c-switch-label__text">Sincronizar <span class="c-switch-label__description">Requiere una cuenta</span></span><span class="c-switch"><input class="c-switch__input" type="checkbox" role="switch" disabled><span class="c-switch__thumb"></span></span></label>
</div>

«Todo» trae tokens, dependencias y componente en un solo archivo, listo para abrir o dárselo a un agente.“All” bundles tokens, dependencies and the component in one file, ready to open or hand to an agent.

InstalaciónInstallation

  1. Agrega una vezAdd once tokens.css (colores, radios, tema oscuro).(colors, radii, dark theme).
  2. Copia los archivos:Copy the files: switch.html, switch.css.
  3. Para el tema oscuro, pon la claseFor the dark theme, add the class dark ento <html>.

Cuándo usarloWhen to use it

ÚsaloUse it

  • Para ajustes inmediatos (modo avión, avisos).
  • For immediate settings (airplane mode, notifications).

Mejor noAvoid

  • Dentro de un formulario con botón de enviar: usa checkbox.
  • Inside a form with a submit button: use a checkbox.

AccesibilidadAccessibility

switch
Espacio SpaceEnciende o apagaTurns on or off
  • Checkbox nativo con role=switch: se anuncia «activado / desactivado».
  • Toda la fila es clicable.
  • Native checkbox with role=switch: announced as “on / off”.
  • The whole row is clickable.

Cómo probarloHow to test it

  • Pulsa Espacio sobre «Modo avión»: se anuncia «activado».
  • Press Space on “Airplane mode”: “on” is announced.

CréditosCredits