Skip to content
Viewership Inquire
UI Components

Switch.

On/off toggle on a native checkbox, in two sizes and two tones.

InputsAtomNo dependencies Beautiful UI, MIT

.md

Marketing automations

Auto-send weekly reportEmail the GA4 and Ads summary every Monday.
Alert on new AI citationsPost in Slack when ChatGPT cites a page.
Brand voice checkManaged by the content lead.

Using Claude Code? Give it the agent prompt and skip these steps.

  1. Import the foundation once

    foundation.css holds the tokens every component reads.

    Layout.astro
    ---
    // src/layouts/Layout.astro
    import "../styles/foundation.css";
    ---
  2. Copy Switch.astro

    Paste into src/components/viewership/switch/

  3. Use it

    Page.astro
    ---
    import Switch from "../components/viewership/switch/Switch.astro";
    ---
    
    <Switch />

Props 7

PropTypeDefaultDescription
checked boolean false Initial state.
disabled boolean false Disable the switch.
name / value / id string · Passed to the native checkbox.
label string · Accessible name if no visible label.
size "md" | "sm" "md" md 40×24; sm 30×18 (24px hit area).
tone "ink" | "accent" "ink" Track color when on.
labelPosition "start" | "end" "end" Slotted label position.

Events

EventDetailWhen
change Event Native change event. Read event.target.checked.

Source 1 file

Ported from Beautiful UI, MIT. Notices.

Used by Records Table