blob: 8babcc8a160f69e65b886d7bc837a0bd38a4b0ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import { SetStateAction, VFC } from 'react';
export type CheckboxProps = {
/**
* One or more ids that refers to the checkbox name.
*/
'aria-labelledby'?: string;
/**
* Add classnames to the checkbox.
*/
className?: string;
/**
* Checkbox id attribute.
*/
id: string;
/**
* Checkbox name attribute.
*/
name: string;
/**
* Callback function to set checkbox value.
*/
setValue: (value: SetStateAction<boolean>) => void;
/**
* Checkbox value.
*/
value: boolean;
};
/**
* Checkbox component
*
* Render a checkbox type input.
*/
const Checkbox: VFC<CheckboxProps> = ({ value, setValue, ...props }) => {
return (
<input
type="checkbox"
checked={value}
onChange={() => setValue(!value)}
{...props}
/>
);
};
export default Checkbox;
|