3.0.0 • Published 5 years ago
@arterial/switch v3.0.0
Arterial Switch
Installation
npm install @arterial/switchUsage
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
| 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. |
3.0.0
5 years ago
2.0.3
5 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.2.0
5 years ago
1.1.0
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
1.0.3
5 years ago
1.0.0-alpha.6
5 years ago
1.0.0-alpha.5
5 years ago
1.0.0-alpha.4
5 years ago
1.0.0-alpha.3
5 years ago
1.0.0-alpha.0
6 years ago