# @arterial/switch

> Another React Material Switch

Latest version **3.0.0** (published 2020-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @arterial/switch
pnpm add @arterial/switch
yarn add @arterial/switch
bun add @arterial/switch
```

## 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.0 |
| Published | 2020-12-24 |
| First published | 2020-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | jdc2000 |
| Maintainers | jdc2000 |

## Links

- npm: https://www.npmjs.com/package/@arterial/switch
- Repository: https://github.com/jdc2000/arterial-components
- Homepage: https://github.com/jdc2000/arterial-components#readme
- Issues: https://github.com/jdc2000/arterial-components/issues
- npm.io page: https://npm.io/package/@arterial/switch

## Dependencies (3)

- [classnames](https://npm.io/package/classnames.md) ^2.2.6
- [@material/switch](https://npm.io/package/@material/switch.md) ^8.0.0
- [@arterial/form-field](https://npm.io/package/@arterial/form-field.md) ^3.0.0

## Recent versions

- 3.0.0 (latest) — 2020-12-24
- 2.0.3 — 2020-10-02
- 2.0.2 — 2020-08-01
- 2.0.1 — 2020-07-20
- 2.0.0 — 2020-07-06
- 1.2.0 — 2020-06-09
- 1.1.0 — 2020-06-09
- 1.0.6 — 2020-06-08
- 1.0.5 — 2020-06-08
- 1.0.4 — 2020-06-01
- 1.0.3 — 2020-05-26
- 1.0.2 — 2020-05-26
- 1.0.1 — 2020-05-26
- 1.0.0 — 2020-05-26
- 1.0.0-alpha.6 — 2020-05-18
- … 4 more at https://npm.io/package/@arterial/switch/versions

## README

# Arterial Switch

[Another React Material Switch](https://arterialjs.org/switches)

## Installation

```zsh
npm install @arterial/switch
```

## Usage

### Styles

#### Sass

```scss
@use "@material/switch/index.scss" as switch;
@include switch.core-styles;
```

#### CSS

```jsx
import '@material/switch/dist/mdc.switch.css';
```

### JSX

```jsx
import {Switch} from '@arterial/switch';
```

## Checked Switch

```jsx
function Checked() {
  const [checked, setChecked] = useState(true);
  return (
    <Switch
      checked={checked}
      id="switch-checked"
      onChange={() => setChecked(!checked)}
    />
  );
}
```

## Unchecked Switch

```jsx
function Unchecked() {
  const [checked, setChecked] = useState(false);
  return (
    <Switch
      checked={checked}
      id="switch-unchecked"
      onChange={() => setChecked(!checked)}
    />
  );
}
```

## Other Variants

### Label

```jsx
function Label() {
  const [checked, setChecked] = useState(false);
  return (
    <Switch
      checked={checked}
      id="switch-label"
      label="Switch"
      onChange={() => setChecked(!checked)}
    />
  );
}
```

### Align End

```jsx
function AlignEnd() {
  const [checked, setChecked] = useState(true);
  return (
    <Switch
      alignEnd
      checked={checked}
      id="switch-align-end"
      label="Switch"
      onChange={() => setChecked(!checked)}
    />
  );
}
```

### Disabled

```jsx
function Disabled() {
  const [checked, setChecked] = useState(true);
  return (
    <Switch
      checked={checked}
      disabled
      id="switch-disabled"
      label="Switch"
      onChange={() => setChecked(!checked)}
    />
  );
}
```

## Props

### Switch

| Name      | Type     | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| alignEnd  | boolean  | Aligns root element on the right side of the label. |
| checked   | boolean  | Indicates whether the element is checked.           |
| className | string   | Classes to be applied to the root element.          |
| disabled  | boolean  | Indicates whether the element is disabled.          |
| id        | string   | Id of the element.                                  |
| label     | string   | Text to be displayed next to the root element.      |
| onChange  | function | Change event handler.                               |
| style     | object   | Styles to be applied to the root element.           |
| value     | string   | Value of input.                                     |

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