componente · @solu30/ui-kit/input
Switch
Interruptor de encendido y apagado, sin etiqueta propia y con estado indeterminado.
137 sitios de import en 10 de 15 verticales — un archivo que la importa cuenta una vez, monte una instancia o veinte.
- TheCharterPanel
- carlosmartinpavon
- cmp-packages
- dietaly
- easycharter
- elliot
- gestorsalon
- luigi
- pagebuilder
- prepchat
El componente, montado
Cargando el espécimen…
export function SwitchMatrix() {
const [notify, setNotify] = useState(true)
const [autoConfirm, setAutoConfirm] = useState(false)
const [openNow, setOpenNow] = useState(true)
return (
<Stage label="Switch · dos tamaños nomás, sin lg" tall wide>
<div className="flex w-full flex-col gap-4">
<div className="flex flex-wrap items-center gap-6">
<Switch checked={notify} onCheckedChange={setNotify} size="sm" />
<Switch checked={notify} onCheckedChange={setNotify} size="md" />
<Switch checked={false} onCheckedChange={() => {}} disabled />
<Switch checked indeterminate onCheckedChange={() => {}} />
</div>
<div className="grid w-full grid-cols-1 gap-3 sm:grid-cols-2">
<SwitchWithLabel
label="Confirmación automática"
description="Reservas de hasta 20 invitados se aprueban solas"
checked={autoConfirm}
onChange={setAutoConfirm}
color="success"
/>
<SwitchWithLabel
label="Salón abierto hoy"
checked={openNow}
onChange={setOpenNow}
color="danger"
disabled
/>
<SwitchWithLabel
label="Sincronizando con el calendario del catamarán"
checked
onChange={() => {}}
loading
/>
</div>
</div>
</Stage>
)
}De specimens/input.tsx · SwitchMatrix: el espécimen del Muestrario, no un ejemplo oficial del paquete. Muestra cómo se usa la pieza de verdad, montada contra los tipos instalados —eso es lo que vale— pero no es documentación del kit.
Cómo se usa
import { Switch } from '@solu30/ui-kit/input'Props
| Prop | Requerida | Tipo | Qué hace |
|---|---|---|---|
| checked | opcional | boolean | — |
| onCheckedChange | opcional | (checked: boolean) => void | — |
| size | opcional | "sm" | "md" | — |
| disabled | opcional | boolean | — |
| indeterminate | opcional | boolean | — |
| className | opcional | string | — |
| id | opcional | string | — |
| name | opcional | string | — |
| aria-label | opcional | string | Accessible name for the switch. Forwarded as-is to the element that carries `role="switch"`. Typed explicitly (instead of extending `ButtonHTMLAttributes`) so a consumer cannot override `role`, `aria-checked`, or swap `onCheckedChange` for a native `onChange`. |
| aria-labelledby | opcional | string | — |
| aria-describedby | opcional | string | — |
Ejemplo del paquete
const [activo, setActivo] = useState(false)
// Controlado siempre: `checked` + `onCheckedChange`, nunca `onChange`.
// Sin etiqueta visible, el nombre accesible es obligatorio.
<Switch checked={activo} onCheckedChange={setActivo} aria-label="Recibir avisos" />Del @example del JSDoc de @solu30/ui-kit, sin editar: son 65 de los 541 símbolos. La sangría y los renglones en blanco son los del paquete.