3.0.0 • Published 3 years ago

@arterial/checkbox v3.0.0

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

Arterial Checkbox

Another React Material Checkbox

Installation

npm install @arterial/checkbox

Usage

Styles

Sass

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

CSS

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

JSX

import {Checkbox} from '@arterial/checkbox';

Checked Checkbox

function Checked() {
  const [checked, setChecked] = useState(true);
  return (
    <Checkbox
      checked={checked}
      id="checkbox-checked"
      onChange={e => setChecked(e.target.checked)}
    />
  );
}

Unchecked Checkbox

function Unchecked() {
  const [checked, setChecked] = useState(false);
  return (
    <Checkbox
      checked={checked}
      id="checkbox-unchecked"
      onChange={e => setChecked(e.target.checked)}
    />
  );
}

Indeterminate Checkbox

function Indeterminate() {
  const [checked, setChecked] = useState(false);
  const [indeterminate, setIndeterminate] = useState(true);
  return (
    <Checkbox
      checked={checked}
      id="checkbox-indeterminate"
      indeterminate={indeterminate}
      onChange={e => {
        setChecked(e.target.checked);
        setIndeterminate(e.target.indeterminate);
      }}
    />
  );
}

Other Variants

Label

function Label() {
  const [checked, setChecked] = useState(true);
  return (
    <Checkbox
      checked={checked}
      id="checkbox-label"
      label="Checkbox"
      onChange={e => setChecked(e.target.checked)}
    />
  );
}

Align End

function AlignEnd() {
  const [checked, setChecked] = useState(true);
  return (
    <Checkbox
      alignEnd
      checked={checked}
      id="checkbox-align-end"
      label="Checkbox"
      onChange={e => setChecked(e.target.checked)}
    />
  );
}

Disabled

<Checkbox
  disabled
  id="checkbox-disabled"
  label="Checkbox"
  onChange={() => {}}
/>

Props

Checkbox

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.
indeterminateboolIndicates whether the checkbox is indeterminate.
labelstringText to be displayed next to the root element.
onChangefunctionChange event handler.
ripplebooleanEnables ripple within root element. Defaults to true.
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.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

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