For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/llms-full.txt, and this page is available as Markdown at https://rickyshin93.github.io/tao-ui/components/switch.md.
v0.0.57
  • English
  • Switch

    Data Entry@rockshin/tao-ui

    Toggles a setting on or off with immediate effect.

    When to use

    Use Switch for settings that take effect immediately.

    Recommended

    • Use labels that describe the enabled state.
    • Use Checkbox when the value is submitted with a form.

    Avoid

    • Do not use the component outside its intended interaction model.

    Examples

    Basic usage

    TSX

    Labels and sizes

    TSX

    Loading and disabled states

    TSX

    Controlled switch

    onChange returns a boolean that can directly update setting state.

    Notifications enabled
    TSX

    Loading prevents repeated toggles

    Use a separate button to toggle loading and inspect the waiting state.

    TSX

    State labels and sizes

    Keep state labels concise and readable at both sizes.

    TSX

    Shared size and disabled state

    Multiple switches inherit configuration; a local disabled prop can override it.

    TSX

    API

    Switch

    PropertyDescriptionTypeDefault Value
    disabledWhether to disableboolean | undefined-
    classNameAdditional css classstring | undefined-
    styleAdditional styleCSSProperties | undefined-