# treactr-toggle

> An elegant, accessible toggle component for React. Also a glorified checkbox.

Latest version **3.0.9** (published 2022-02-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install treactr-toggle
pnpm add treactr-toggle
yarn add treactr-toggle
bun add treactr-toggle
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.9 |
| Published | 2022-02-18 |
| First published | 2017-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kevin Chau |
| Maintainers | kevinchau |
| Keywords | toggle, component, react, react-component |

## Links

- npm: https://www.npmjs.com/package/treactr-toggle
- Repository: https://github.com/kevin-chau/treactr-toggle
- Issues: https://github.com/kevin-chau/treactr-toggle/issues
- npm.io page: https://npm.io/package/treactr-toggle

## Dependencies (1)

- [classnames](https://npm.io/package/classnames.md) ^2.2.5

## 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

- 3.0.9 (latest) — 2022-02-18
- 3.0.8 — 2017-02-27
- 3.0.7 — 2017-02-27
- 3.0.6 — 2017-02-27
- 3.0.5 — 2017-02-25
- 3.0.4 — 2017-02-25
- 3.0.3 — 2017-02-25
- 3.0.2 — 2017-02-25
- 3.0.1 — 2017-02-24
- 3.0.0 — 2017-02-24

## README

An elegant, accessible toggle component for React. Also a glorified checkbox.

<img src="https://camo.githubusercontent.com/7b82df5ece8794631d7b004a6fd1d9fe32a336b6/68747470733a2f2f64337676366c703535716a6171632e636c6f756466726f6e742e6e65742f6974656d732f334132783052335a3245337130523069304531692f53637265656e2532305265636f7264696e67253230323031362d31312d3234253230617425323031312e3433253230414d2e6769663f582d436c6f75644170702d56697369746f722d49643d643661386464343439306336316166646261386130613230383232373361613126763d3631613139333333" height="32px" />

See [usage and examples](http://aaronshaf.github.io/react-toggle/).

## Props

The component takes the following props.

| Prop              | Type       | Description |
|-------------------|------------|-------------|
| `checked`         | _boolean_  | If `true`, the toggle is checked. If `false`, the toggle is unchecked. Use this if you want to treat the toggle as a controlled component |
| `defaultChecked`  | _boolean_  | If `true` on initial render, the toggle is checked. If `false` on initial render, the toggle is unchecked. Use this if you want to treat the toggle as an uncontrolled component |
| `onChange`        | _function_ | Callback function to invoke when the user clicks on the toggle. The function signature should be the following: `function(e) { }`. To get the current checked status from the event, use `e.target.checked`. |
| `name`            | _string_   | The value of the `name` attribute of the wrapped \<input\> element |
| `value`           | _string_   | The value of the `value` attribute of the wrapped \<input\> element |
| `id`              | _string_   | The value of the `id` attribute of the wrapped \<input\> element |
| `aria-labelledby` | _string_   | The value of the `aria-labelledby` attribute of the wrapped \<input\> element |
| `aria-label`      | _string_   | The value of the `aria-label` attribute of the wrapped \<input\> element |
| `disabled`        | _boolean_  | If `true`, the toggle is enabled. If `false`, the toggle is disabled |

## Installation

```bash
npm install treactr-toggle
```

Include the component's [CSS](./style.css).

## Development

```javascript
npm install
npm run dev
```

## Build

```javascript
npm run build
```

## License

MIT

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