FilterCheckbox
Reusable checkbox component for filter options with optional icon, count display, and disabled state. Used by SearchSidebar for content types, subjects, technology (with icons), and persons.
Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
option | { value: string; label: string; count: number; iconSrc?: string } | Yes | - | Filter option data; iconSrc shows icon before label (e.g. technology icons) |
isChecked | boolean | Yes | - | Whether the checkbox is checked |
isDisabled | boolean | Yes | - | Whether the checkbox is disabled (typically when count is 0) |
onChange | (value: string, checked: boolean) => void | Yes | - | Callback when checkbox state changes |
ariaLabel | string | Yes | - | Accessibility label for the checkbox |
Usage
import FilterCheckbox from '@/components/molecules/FilterCheckbox';
<FilterCheckbox
option={{ value: 'blogpost', label: 'Blogs', count: 15 }}
isChecked={selectedTypes.includes('blogpost')}
isDisabled={false}
onChange={(value, checked) => handleChange(value, checked)}
ariaLabel="Filter by Blogs"
/>
// With icon (e.g. technology filter)
<FilterCheckbox
option={{ value: 'react', label: 'react', count: 8, iconSrc: '/technologies/react.svg' }}
isChecked={selectedTechnology.includes('react')}
isDisabled={false}
onChange={handleTechnologyChange}
ariaLabel="Filter by react"
/>Features
- Optional icon: When
option.iconSrcpresent, renders Image before label (16x16) - Disabled state: Greyed out when disabled (opacity, cursor)
- Count display: Shows result count badge
- Accessibility: ARIA labels and disabled attributes
- Hover effects: Text color changes when enabled
Notes
- Used by SearchSidebar; technology options include iconSrc from
getTechnologyIconSrc() - Prevents onChange when disabled