Created
November 18, 2025 21:28
-
-
Save alexmkio/4c27eea61fd052f049dc014b3215e956 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as RadixCheckbox from '@radix-ui/react-checkbox'; | |
| import { useId } from 'react'; | |
| import CheckmarkIcon from '@components/icons/Checkmark'; | |
| import styles from './Checkbox.module.scss'; | |
| type CheckboxProps = { | |
| label?: string; | |
| id?: string; | |
| } & RadixCheckbox.CheckboxProps; | |
| const Checkbox = (props: CheckboxProps) => { | |
| const generatedId = useId(); | |
| const { label, id = `checkbox-${generatedId}`, checked, onCheckedChange, required = false, disabled = false, name, value } = props; | |
| return ( | |
| <div className={styles.container}> | |
| <RadixCheckbox.Root | |
| className={styles.root} | |
| checked={checked} | |
| onCheckedChange={onCheckedChange} | |
| id={id} | |
| required={required} | |
| disabled={disabled} | |
| name={name} | |
| value={value} | |
| > | |
| <RadixCheckbox.Indicator className={styles.indicator}> | |
| {disabled ? <CheckmarkIcon className={styles.disabledIcon} /> : <CheckmarkIcon />} | |
| </RadixCheckbox.Indicator> | |
| </RadixCheckbox.Root> | |
| {label && ( | |
| <label className={styles.label} htmlFor={id}> | |
| {label} | |
| </label> | |
| )} | |
| </div> | |
| ); | |
| }; | |
| export default Checkbox; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment