# SbCheckbox A checkbox component with support for labels, indeterminate state, and color variants. ## Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | Value | bool | false | Checkbox checked state (two-way bindable) | | ValueChanged | EventCallback\ | - | Callback when value changes | | Label | string? | null | Checkbox label text | | Indeterminate | bool | false | Whether the checkbox is in indeterminate state | | Disabled | bool | false | Whether the checkbox is disabled | | Color | SbColor | SbColor.Primary | Checkbox accent color | | Id | string? | null | Element ID for the input | | Class | string? | null | Additional CSS classes | | Style | string? | null | Inline styles | | AdditionalAttributes | Dictionary\? | null | Additional HTML attributes (CaptureUnmatchedValues) | ## Events | Event | Type | Description | |-------|------|-------------| | ValueChanged | EventCallback\ | Fired when the checkbox value changes | ## Templates / Slots (RenderFragments) | Slot | Type | Description | |------|------|-------------| | ChildContent | RenderFragment | Custom label content (takes precedence over Label parameter) | ### Template Usage Examples #### Custom Label with ChildContent ```razor I agree to the Terms of Service and Privacy Policy ``` ## CSS Classes - `sb-checkbox` - Base class - `sb-checkbox--{color}` - Color variant (primary, secondary, success, danger, etc.) - `sb-checkbox--checked` - Checked state - `sb-checkbox--indeterminate` - Indeterminate state - `sb-checkbox--disabled` - Disabled state - `sb-checkbox__input` - Hidden native input - `sb-checkbox__box` - Visual checkbox box - `sb-checkbox__check` - Check icon - `sb-checkbox__indeterminate` - Minus icon for indeterminate - `sb-checkbox__label` - Label text ## Accessibility - Uses native `` - `aria-checked` indicates current state (true/false/mixed) - Label wraps input for click area expansion - Keyboard accessible (Space to toggle) ## Examples ### Basic Usage ```razor ``` ### Color Variants ```razor ``` ### Indeterminate State ```razor ``` ### Disabled States ```razor ``` ### With Rich Label Content ```razor Remember this device for 30 days ``` ### Form Validation ```razor ``` ### Select All Pattern ```razor @code { private bool selectAll; private bool isIndeterminate; private List items = new(); private void OnSelectAllChanged(bool value) { selectAll = value; isIndeterminate = false; foreach (var item in items) { item.Selected = value; } } private void OnItemChanged() { var selectedCount = items.Count(i => i.Selected); selectAll = selectedCount == items.Count; isIndeterminate = selectedCount > 0 && selectedCount < items.Count; } } @foreach (var item in items) { } ```