← Files DataARCHIVED FILE

templates/data-app/base/src/components/Switch.jsx

623 Bytes · Sep 30, 2026 · 23:19 UTC

↓ Download file

import React from "react";


export function Switch({
  label,
  checked = false,
  onChange,
  disabled = false,
  fullWidth = false,
  size = "default",
  className = "",
}) {
  return <button type="button" className={["data-switch", className].filter(Boolean).join(" ")}
    role="switch" aria-label={label} aria-checked={checked} disabled={disabled}
    data-full-width={fullWidth || undefined} data-size={size === "compact" ? size : undefined}
    onClick={() => onChange?.(!checked)}>
    <span className="data-switch-label">{label}</span>
    <span className="data-switch-track" aria-hidden="true" />
  </button>;
}

SHA-256: 38010aef242d32133274db12e1d91323204630b47875af874b68cb81bc19b23d