3.0.0 • Published 5 years ago
@arterial/radio v3.0.0
Arterial Radio
Installation
npm install @arterial/radioUsage
Styles
Sass
@use "@material/radio/radio.scss" as radio;
@include radio.core-styles;CSS
import '@material/radio/dist/mdc.radio.css';JSX
import {Radio} from '@arterial/radio';Basic Radio
function Basic() {
const [value, setValue] = useState('yes');
return (
<>
<Radio
checked={value === 'yes'}
id="radio-yes"
name="radios"
value="yes"
onChange={e => setValue(e.target.value)}
/>
<Radio
checked={value === 'no'}
id="radio-no"
name="radios"
value="no"
onChange={e => setValue(e.target.value)}
/>
</>
);
}Other Variants
Label
function Label() {
const [value, setValue] = useState('yes');
return (
<>
<Radio
checked={value === 'yes'}
id="radio-label-yes"
label="Yes"
name="radios-label"
value="yes"
onChange={e => setValue(e.target.value)}
/>
<Radio
checked={value === 'no'}
id="radio-label-no"
label="No"
name="radios-label"
value="no"
onChange={e => setValue(e.target.value)}
/>
</>
);
}Align End
function AlignEnd() {
const [value, setValue] = useState('yes');
return (
<>
<Radio
alignEnd
checked={value === 'yes'}
id="radio-align-end-yes"
label="Yes"
name="radios-align-end"
value="yes"
onChange={e => setValue(e.target.value)}
/>
<Radio
alignEnd
checked={value === 'no'}
id="radio-align-end-no"
label="No"
name="radios-align-end"
value="no"
onChange={e => setValue(e.target.value)}
/>
</>
);
}Disabled
function Disabled() {
const [value, setValue] = useState('yes');
return (
<>
<Radio
checked={value === 'yes'}
disabled
id="radio-disabled-yes"
label="Yes"
name="radios-disabled"
value="yes"
onChange={e => setValue(e.target.value)}
/>
<Radio
checked={value === 'no'}
disabled
id="radio-disabled-no"
label="No"
name="radios-disabled"
value="no"
onChange={e => setValue(e.target.value)}
/>
</>
);
}Props
Radio
| 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. |
| ripple | boolean | Enables ripple within root element. Defaults to true. |
| 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
6 years ago
1.1.0
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago
1.0.0-alpha.6
6 years ago
1.0.0-alpha.5
6 years ago
1.0.0-alpha.4
6 years ago
1.0.0-alpha.3
6 years ago
1.0.0-alpha.0
6 years ago