From af575907c254d3233c3fd5904afc87c1db0bdcf3 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 9 Apr 2022 19:14:03 +0200 Subject: chore: add a Checkbox component --- src/components/atoms/forms/checkbox.tsx | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/components/atoms/forms/checkbox.tsx (limited to 'src/components/atoms/forms/checkbox.tsx') diff --git a/src/components/atoms/forms/checkbox.tsx b/src/components/atoms/forms/checkbox.tsx new file mode 100644 index 0000000..8babcc8 --- /dev/null +++ b/src/components/atoms/forms/checkbox.tsx @@ -0,0 +1,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) => void; + /** + * Checkbox value. + */ + value: boolean; +}; + +/** + * Checkbox component + * + * Render a checkbox type input. + */ +const Checkbox: VFC = ({ value, setValue, ...props }) => { + return ( + setValue(!value)} + {...props} + /> + ); +}; + +export default Checkbox; -- cgit v1.2.3