# @gluestack-ui/switch

> A universal headless Switch component for React Native, Next.js & React

Latest version **0.1.29** (published 2025-03-11) · 0 weekly downloads

## Install

```sh
npm install @gluestack-ui/switch
pnpm add @gluestack-ui/switch
yarn add @gluestack-ui/switch
bun add @gluestack-ui/switch
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.1.29 |
| Published | 2025-03-11 |
| First published | 2023-02-21 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5308 |
| Maintainers | vidhi499, rohit_singh, viraj-10, rayan1810, rajat693, surajahmedc, meenumakkar, madhavb230100, vaibhk002, daminipandey, amars29, geekgautam, sravankumarvelangi, gluestackadmin, geekashwini, mayankp06 |
| Keywords | react, native, react-native, switch, gluestack-ui, universal, headless, typescript, component, android, ios, nextjs |

## Links

- npm: https://www.npmjs.com/package/@gluestack-ui/switch
- Repository: https://github.com/gluestack/gluestack-ui
- Homepage: https://github.com/gluestack/gluestack-ui/tree/main/packages/unstyled/switch#readme
- Issues: https://github.com/gluestack/gluestack-ui/issues
- npm.io page: https://npm.io/package/@gluestack-ui/switch

## Dependencies (5)

- [@gluestack-ui/utils](https://npm.io/package/@gluestack-ui/utils.md) ^0.1.15
- [@react-stately/toggle](https://npm.io/package/@react-stately/toggle.md) ^3.4.4
- [@react-native-aria/focus](https://npm.io/package/@react-native-aria/focus.md) ^0.2.9
- [@gluestack-ui/form-control](https://npm.io/package/@gluestack-ui/form-control.md) ^0.1.19
- [@react-native-aria/interactions](https://npm.io/package/@react-native-aria/interactions.md) 0.2.16

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.29 (latest) — 2025-03-11
- 0.1.28 — 2025-03-03
- 0.1.27 — 2025-02-19
- 0.1.26 — 2025-02-18
- 0.1.25 — 2025-02-18
- 0.1.24 — 2025-02-18
- 0.1.23 — 2024-11-11
- 0.1.22 — 2024-07-08
- 0.1.21 — 2024-03-21
- 0.1.20 — 2024-03-18
- 0.1.19 — 2024-02-12
- 0.1.18 — 2024-01-23
- 0.1.17 — 2023-10-20
- 0.1.16 — 2023-10-19
- 0.1.15 — 2023-10-19
- … 16 more at https://npm.io/package/@gluestack-ui/switch/versions

## README

# @gluestack-ui/switch

## Installation

To use `@gluestack-ui/switch`, all you need to do is install the
`@gluestack-ui/switch` package:

```sh
$ yarn add @gluestack-ui/switch

# or

$ npm i @gluestack-ui/switch
```

## Usage

The Switch component offers a stylish alternative to the Checkbox, allowing users to enable or disable an option with a sleek sliding motion. This component is perfect for adding a touch of elegance and interactivity to your user interface. Here's an example how to use this package to create one:

```jsx
import { createSwitch } from '@gluestack-ui/switch';
import { Root } from './styled-components';

export const Switch = createSwitch({
  Root,
});
```

## Customizing the Switch:

Default styling of all these components can be found in the components/core/switch file. For reference, you can view the [source code](https://github.com/gluestack/gluestack-ui/blob/development/example/storybook/src/ui-components/Switch/index.tsx) of the styled `Switch` components.

```jsx
// import the styles
import { Root } from '../components/core/switch/styled-components';

// import the createSwitch function
import { createSwitch } from '@gluestack-ui/switch';

// Understanding the API
const Switch = createSwitch({
  Root,
});

// Using the switch component
export default () => <Switch />;
```

More guides on how to get started are available
[here](https://ui.gluestack.io/docs/components/forms/switch).

---
_Source: https://npm.io/package/@gluestack-ui/switch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
