import classNames from 'classnames'; import { type ReactNode } from 'react'; import { trackEvent } from '../../lib/analytics'; import { Icon } from './Icon'; import { HStack } from './Stacks'; export interface CheckboxProps { checked: boolean | 'indeterminate'; title: ReactNode; onChange: (checked: boolean) => void; className?: string; disabled?: boolean; inputWrapperClassName?: string; hideLabel?: boolean; fullWidth?: boolean; event?: string; } export function Checkbox({ checked, onChange, className, inputWrapperClassName, disabled, title, hideLabel, fullWidth, event, }: CheckboxProps) { return (
{ onChange(checked === 'indeterminate' ? true : !checked); if (event != null) { trackEvent('button', 'click', { id: event, checked: checked ? 'on' : 'off' }); } }} />
{!hideLabel && title}
); }