Canopy Checkbox — Best Practices
This skill provides usage guidance, dos and don'ts, and input reference for Canopy checkbox components from @legal-and-general/canopy.
Apply this skill whenever you use LgToggleComponent (as lg-checkbox) or LgCheckboxGroupComponent.
Import
import { LgToggleComponent } from '@legal-and-general/canopy';
For grouped checkboxes:
import { LgCheckboxGroupComponent, LgToggleComponent } from '@legal-and-general/canopy';
Single Checkbox
<lg-checkbox formControlName="agreed" value="yes">
I agree to the terms and conditions
</lg-checkbox>
Checkbox Group
Use lg-checkbox-group when presenting two or more related options.
<lg-checkbox-group formControlName="colours">
Select your colours
<lg-hint>Choose all that apply</lg-hint>
<lg-toggle value="red">Red</lg-toggle>
<lg-toggle value="blue">Blue</lg-toggle>
<lg-toggle value="green">Green</lg-toggle>
</lg-checkbox-group>
LgToggleComponent Inputs
| Input | Type | Default | Required | Description |
|-------|------|---------|----------|-------------|
| id | string | auto-generated | No | HTML id attribute. |
| name | string | null | Yes | HTML name attribute. |
| value | string | null | Yes | HTML value attribute. |
| focus | boolean | null | No | Sets focus on the checkbox. |
| size | 'sm' \| 'lg' | 'lg' | No | Size of the checkbox. |
| ariaDescribedBy | string | null | No | ID of element that describes the checkbox. |
LgToggleComponent Outputs
| Output | Type | Description |
|--------|------|-------------|
| blur | EventEmitter<Event> | Emitted on blur. |
LgCheckboxGroupComponent Inputs
| Input | Type | Default | Description |
|-------|------|---------|-------------|
| id | string | auto-generated | HTML id attribute. |
| name | string | auto-generated | Sets name on all checkboxes in the group. |
| value | Array<string> | null | Sets the default checked checkboxes; must match the value of the toggle buttons. |
| focus | boolean | null | Sets focus on the fieldset. |
| disabled | boolean | false | Disables all inner checkboxes. |
| inline | boolean | false | Displays checkboxes inline. |
| ariaDescribedBy | string | null | ID of element that describes the checkboxes. |
Accessibility
- Always group related checkboxes using
lg-checkbox-groupwith a clear label. - Use
lg-hintto provide extra context where needed. - Ensure all checkboxes have clear, descriptive labels.
- Set
ariaDescribedByto link checkboxes to hint or validation messages. - Keyboard users must be able to tab through all checkboxes and toggle them with Space.
Dos and Don'ts
Do
- Do always provide a clear, descriptive label for every checkbox.
- Do use to allow the user to choose from multiple options.
- Do use a single checkbox to capture acknowledgement or consent (e.g. "I agree to the terms and conditions").
- Do use a checkbox to confirm an action has been completed (e.g. in a checklist).
Don't
- Don't rely on placeholder text or tooltips as a substitute for a label.
- Don't use negative labels.
- Don't use as part of a dark pattern.
- Don't use when a single exclusive response is required — use radio buttons instead.