Newer
Older
import { Check } from "@styled-icons/boxicons-regular";
cursor: pointer;
font-size: 18px;
user-select: none;
&:hover {
.check {
background: var(--background);
}
}
&[disabled] {
opacity: 0.5;
cursor: not-allowed;
display: flex;
flex-grow: 1;
font-size: 1rem;
font-weight: 600;
flex-direction: column;
font-size: 0.75rem;
font-weight: 400;
color: var(--secondary-foreground);
margin: 4px;
width: 24px;
height: 24px;
display: grid;
flex-shrink: 0;
place-items: center;
transition: 0.2s ease all;
svg {
color: var(--secondary-background);
}
${(props) =>
props.checked &&
css`
background: var(--accent) !important;
`}
checked: boolean;
disabled?: boolean;
className?: string;
children: Children;
description?: Children;
onChange: (state: boolean) => void;
export default function Checkbox(props: CheckboxProps) {
return (
<CheckboxBase disabled={props.disabled} className={props.className}>
<CheckboxContent>
<span>{props.children}</span>
{props.description && (
<CheckboxDescription>
{props.description}
</CheckboxDescription>
)}
</CheckboxContent>
<input
type="checkbox"
checked={props.checked}
onChange={() =>
!props.disabled && props.onChange(!props.checked)
}
/>
<Checkmark checked={props.checked} className="check">
<Check size={20} />
</Checkmark>
</CheckboxBase>
);