3.0.0 • Published 3 years ago

@arterial/switch v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Arterial Switch

Another React Material Switch

Installation

npm install @arterial/switch

Usage

Styles

Sass

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

CSS

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

JSX

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

Checked Switch

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

Unchecked Switch

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

Other Variants

Label

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

Align End

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

Disabled

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

Props

Switch

NameTypeDescription
alignEndbooleanAligns root element on the right side of the label.
checkedbooleanIndicates whether the element is checked.
classNamestringClasses to be applied to the root element.
disabledbooleanIndicates whether the element is disabled.
idstringId of the element.
labelstringText to be displayed next to the root element.
onChangefunctionChange event handler.
styleobjectStyles to be applied to the root element.
valuestringValue of input.
3.0.0

3 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.3

4 years ago

1.0.0-alpha.6

4 years ago

1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.0

4 years ago