Skip to content

Commit c7e42bc

Browse files
committed
clean up docs
1 parent fe5c705 commit c7e42bc

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

libs/design/checkbox/README.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Users can select zero, one, or any number of checkboxes. They can be used standa
66

77
The following components are available for checkboxes:
88

9-
- **<daff-checkbox>**: Individual checkbox
10-
- **<daff-checkbox-set>**: Container for grouping related checkboxes
9+
- **`<daff-checkbox>`**: Individual checkbox
10+
- **`<daff-checkbox-set>`**: Container for grouping related checkboxes
1111

1212
## Usage
1313

@@ -51,7 +51,9 @@ export class CustomComponentModule { }
5151

5252
> Deprecation notice: This method is deprecated. It's recommended to update all custom components to standalone.
5353
54-
## Basic checkbox
54+
## Anatomy
55+
56+
### Checkbox
5557
A basic checkbox allows users to make a selection. Place the label text as content inside of `<daff-checkbox>`.
5658

5759
```html
@@ -60,10 +62,10 @@ A basic checkbox allows users to make a selection. Place the label text as conte
6062
</daff-checkbox>
6163
```
6264

63-
## Checkbox Set
64-
Use `<daff-checkbox-set>` to group related checkboxes together. This provides consistent styling and helps organize multiple checkbox options under a common label.
65+
### Checkbox Set
66+
Group related checkboxes together using `<daff-checkbox-set>` for better organization and accessibility. This provides consistent styling and helps organize multiple checkbox options under a common label.
6567

66-
### Checkbox set label
68+
#### Label
6769
Use `<daff-checkbox-set-label>` to provide a descriptive label for the checkbox set. This helps users understand what the group of checkboxes represents.
6870

6971
```html
@@ -80,10 +82,10 @@ Use the `orientation` property to stack checkboxes either `vertical` (default) o
8082

8183
```html
8284
<daff-checkbox-set orientation="horizontal">
83-
<daff-checkbox-set-label>Select options</daff-checkbox-set-label>
84-
<daff-checkbox value="option1">Option 1</daff-checkbox>
85-
<daff-checkbox value="option2">Option 2</daff-checkbox>
86-
<daff-checkbox value="option3">Option 3</daff-checkbox>
85+
<daff-checkbox-set-label>Preferences</daff-checkbox-set-label>
86+
<daff-checkbox value="email">Email notifications</daff-checkbox>
87+
<daff-checkbox value="sms">SMS notifications</daff-checkbox>
88+
<daff-checkbox value="push">Push notifications</daff-checkbox>
8789
</daff-checkbox-set>
8890
```
8991

@@ -180,26 +182,19 @@ For checkbox sets:
180182

181183
<design-land-example-viewer-container example="checkbox-set-with-error"></design-land-example-viewer-container>
182184

183-
## Best practices
184-
- Always provide clear, descriptive labels for checkboxes to help users understand what they're selecting.
185-
- Group related checkboxes together using `<daff-checkbox-set>` for better organization and accessibility.
186-
- Use hints to provide additional context or instructions when needed.
187-
- Mark checkboxes as required when user input is mandatory.
188-
- Set meaningful custom IDs for checkboxes to improve accessibility and form management.
189-
190185
## Accessibility
191186
Checkbox implements the [Checkbox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/).
192187

193-
### What Daffodil provides
194-
- Each `<daff-checkbox>` has `role="checkbox"` with proper `aria-checked` state
195-
- Checkbox sets have `role="group"` with `aria-labelledby` pointing to the label
196-
- Labels are automatically associated with controls using `for` and `id` attributes
197-
- `<daff-hint>` and `<daff-error-message>` are linked via `aria-describedby`
188+
### Daffodil provides
189+
- Each `<daff-checkbox>` has `role="checkbox"` with proper `aria-checked` state.
190+
- Checkbox sets have `role="group"` with `aria-labelledby` pointing to the label.
191+
- Labels are automatically associated with controls using `for` and `id` attributes.
192+
- `<daff-hint>` and `<daff-error-message>` are linked via `aria-describedby`.
198193

199194
### Developer responsibilities
200-
- Always provide a label for each checkbox by placing text content inside `<daff-checkbox>`
201-
- Use `<daff-checkbox-set-label>` to label checkbox groups
202-
- If `<daff-checkbox-set-label>` is not provided, set an `id` to link it with the set's `aria-labelledby`
195+
Always provide clear, descriptive labels by placing text content inside `<daff-checkbox>` to help users understand what they're selecting.
196+
- Use `<daff-checkbox-set-label>` to label checkbox groups.
197+
- If `<daff-checkbox-set-label>` is not provided, set an `id` to link it with the set's `aria-labelledby`.
203198

204199
### Keyboard interaction
205200
| Key | Action |

libs/design/checkbox/src/checkbox-set/checkbox-set.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export class DaffCheckboxSetComponent {
7676

7777
/**
7878
* Whether the checkbox set is required.
79+
*
7980
* Can be set explicitly via input, or automatically set to true if any checkbox within the set is required.
8081
*/
8182
@Input({ transform: booleanAttribute })

libs/design/checkbox/src/checkbox/checkbox.component.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ export class DaffCheckboxComponent {
122122
}
123123

124124
/**
125-
* The id of the checkbox. Must be unique. If not entered by a user then it is generated.
125+
* The unique id of the checkbox. Defaults to an autogenerated value. When using this,
126+
* it's your responsibility to ensure that the id for each checkbox is unique.
127+
*
128+
* It gets assigned to the `for` attribute on the `<label>` inside of the checkbox.
126129
*/
127-
@Input() id: string = 'daff-checkbox-' + uniqueCheckboxId;
130+
@Input() id = 'daff-checkbox-' + uniqueCheckboxId;
128131

129132
/**
130133
* Event fired when a checkbox has been checked.
@@ -137,8 +140,10 @@ export class DaffCheckboxComponent {
137140
@Output() becameUnchecked: EventEmitter<void> = new EventEmitter();
138141

139142
/**
140-
* The disabled state of the checkbox. When used with Angular forms, this will automatically
141-
* be set if the form control is disabled.
143+
* @docs-private
144+
*
145+
* The disabled state of the checkbox. When used with Angular forms,
146+
* this will automatically be set if the form control is disabled.
142147
*/
143148
get disabled() {
144149
return this.ngControl?.disabled ?? this.disabledDirective.disabled;

0 commit comments

Comments
 (0)