import { useId } from 'react'; import { Chip } from '../../atoms/chip'; import { FieldError } from '../../atoms/field-error'; import { FlexBox } from '../../atoms/flex-box'; import type { ChipGroupProps } from './types'; /** * A multiple choice as a wrapping row of toggle chips, such as markets, with its error under it. * The fieldset is named and can take focus, so a form error can send the person to it. */ export function ChipGroup({ options, value, onToggle, label, error, size = 'md', disabled = false, ref, className, }: ChipGroupProps) { const errorId = useId(); const hasError = error != null && error !== false; return ( {options.map((option) => ( onToggle(option.value)} > {option.label} ))} {hasError && {error}} ); }