---
title: Switch
sidebar_label: Switch
---
import { StoryWithControls } from '../../../../src/components/StorybookWrapper';
# Switch
A toggle switch for boolean on/off states. Supports loading indicators, sizing, and an HTML title attribute for accessibility tooltips.
## Live Example
## Try It
Edit the code below to experiment with the component:
```tsx live
function Demo() {
const [checked, setChecked] = React.useState(true);
return (
Dashboard Settings
{[
{
label: 'Email notifications',
checked: notifications,
onChange: setNotifications,
title: 'Toggle email notifications',
},
{
label: 'Dark mode',
checked: darkMode,
onChange: setDarkMode,
title: 'Toggle dark mode',
},
{
label: 'Auto-refresh data',
checked: autoRefresh,
onChange: setAutoRefresh,
title: 'Toggle auto-refresh',
},
].map(({ label, checked, onChange, title }) => (
{label}
))}
);
}
```
## Props
| Prop | Type | Default | Description |
| ---------- | --------- | ------------------ | ----------------------------------------------------------------------------------- |
| `disabled` | `boolean` | `false` | Whether the switch is disabled. |
| `loading` | `boolean` | `false` | Whether to show a loading spinner inside the switch. |
| `title` | `string` | `"Toggle feature"` | HTML title attribute shown as a browser tooltip on hover. Useful for accessibility. |
## Import
```tsx
import { Switch } from '@superset-ui/core/components';
```
---
:::tip[Improve this page]
This documentation is auto-generated from the component's Storybook story.
Help improve it by [editing the story file](https://github.com/apache/superset/edit/master/superset-frontend/packages/superset-ui-core/src/components/Switch/Switch.stories.tsx).
:::