@salesforce/mcp-provider-lwc-experts 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.bundle.js +109 -117
- package/knowledge/graphql/generation-guide.md +212 -0
- package/knowledge/graphql/generation-mutation.md +265 -0
- package/knowledge/graphql/generation-query.md +235 -0
- package/knowledge/graphql/generation-schema.md +20 -0
- package/knowledge/graphql/schema/shared.graphqls +1140 -0
- package/knowledge/o11y/activityApi.md +64 -0
- package/knowledge/o11y/bestPractices.md +106 -0
- package/knowledge/o11y/counterMetrics.md +61 -0
- package/knowledge/o11y/errorTracking.md +70 -0
- package/knowledge/o11y/initialization.md +46 -0
- package/knowledge/o11y/lifecycleInstrumentation.md +91 -0
- package/knowledge/o11y/logApi.md +53 -0
- package/knowledge/o11y/schemaUsage.md +48 -0
- package/knowledge/slds/styling-hooks/README.md +408 -0
- package/knowledge/slds/styling-hooks/categories/color.md +963 -0
- package/knowledge/slds/styling-hooks/categories/radius.md +526 -0
- package/knowledge/slds/styling-hooks/categories/shadow.md +489 -0
- package/knowledge/slds/styling-hooks/categories/sizing.md +667 -0
- package/knowledge/slds/styling-hooks/categories/spacing.md +501 -0
- package/knowledge/slds/styling-hooks/categories/typography.md +708 -0
- package/knowledge/slds/styling-hooks/global-semantic/accent-hooks.md +207 -0
- package/knowledge/slds/styling-hooks/global-semantic/feedback-hooks.md +819 -0
- package/knowledge/slds/styling-hooks/global-semantic/surface-hooks.md +215 -0
- package/knowledge/slds/styling-hooks/guidance.md +906 -0
- package/knowledge/slds/styling-hooks/metadata/hooks-index.json +6576 -0
- package/knowledge/utam/generation-guide.md +499 -0
- package/knowledge/utam/generation-workflow.md +243 -0
- package/knowledge/utam/namespaces-mapping.md +26 -0
- package/knowledge/utam/utam-json-schema.md +720 -0
- package/knowledge/utils.ts +27 -0
- package/package.json +4 -3
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-create-list-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-create-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-delete-list-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-delete-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-info-by-name.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-infos-by-name.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-infos-by-object-name.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-object-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-preferences.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-records-by-name.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-update-list-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-update-list-preferences.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-update-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/lds-wire-adapter-types.json +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-count.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-info-batch.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-records-batch.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-records.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-lists-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-object-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-object-infos.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-picklist-values-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-picklist-values.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-records.md +0 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
# SLDS Spacing System: Comprehensive Guide for Coding Agents
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The SLDS spacing system includes **48 spacing hooks** (10% of all 473 global hooks) that create consistent whitespace, rhythm, and visual hierarchy across interfaces. All spacing follows a **4-point grid system** aligned with the root font size.
|
|
6
|
+
|
|
7
|
+
**Total Spacing Hooks:** 48
|
|
8
|
+
|
|
9
|
+
- **Base Spacing:** 12 hooks (`spacing-1` through `spacing-12`)
|
|
10
|
+
- **Density-Aware (All Sides):** 12 hooks (`spacing-var-1` through `spacing-var-12`)
|
|
11
|
+
- **Density-Aware (Vertical):** 12 hooks (`spacing-var-block-1` through `spacing-var-block-12`)
|
|
12
|
+
- **Density-Aware (Horizontal):** 12 hooks (`spacing-var-inline-1` through `spacing-var-12`)
|
|
13
|
+
|
|
14
|
+
**Reference:** [SLDS Spacing and Sizing](https://www.lightningdesignsystem.com/2e1ef8501/p/03d6b0-spacing-and-sizing)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Base Spacing Scale (`--slds-g-spacing-*`)
|
|
19
|
+
|
|
20
|
+
### Complete Scale
|
|
21
|
+
|
|
22
|
+
| Hook | Value | Pixels @ 16px Root | Legacy Name | Common Use |
|
|
23
|
+
| --------------------- | ------- | ------------------ | ----------- | --------------------------------- |
|
|
24
|
+
| `--slds-g-spacing-1` | 0.25rem | 4px | xx-small | Minimal gaps, tight spacing |
|
|
25
|
+
| `--slds-g-spacing-2` | 0.5rem | 8px | x-small | Icon-text gaps, compact padding |
|
|
26
|
+
| `--slds-g-spacing-3` | 0.75rem | 12px | small | Small component padding |
|
|
27
|
+
| `--slds-g-spacing-4` | 1rem | 16px | medium | Standard padding, common margins |
|
|
28
|
+
| `--slds-g-spacing-5` | 1.5rem | 24px | large | Generous padding, section spacing |
|
|
29
|
+
| `--slds-g-spacing-6` | 2rem | 32px | x-large | Large component spacing |
|
|
30
|
+
| `--slds-g-spacing-7` | 2.5rem | 40px | xx-large | Major section dividers |
|
|
31
|
+
| `--slds-g-spacing-8` | 3rem | 48px | xxx-large | Page section spacing |
|
|
32
|
+
| `--slds-g-spacing-9` | 3.5rem | 56px | - | Large layout spacing |
|
|
33
|
+
| `--slds-g-spacing-10` | 4rem | 64px | - | Major layout divisions |
|
|
34
|
+
| `--slds-g-spacing-11` | 4.5rem | 72px | - | Extra large spacing |
|
|
35
|
+
| `--slds-g-spacing-12` | 5rem | 80px | - | Maximum spacing |
|
|
36
|
+
|
|
37
|
+
### When to Use Base Spacing
|
|
38
|
+
|
|
39
|
+
✅ **Use base spacing when:**
|
|
40
|
+
|
|
41
|
+
- Fixed spacing is required regardless of density setting
|
|
42
|
+
- Creating layout structures that shouldn't change
|
|
43
|
+
- Defining spacing in non-interactive components
|
|
44
|
+
- Setting gaps in flexbox/grid that should remain constant
|
|
45
|
+
|
|
46
|
+
❌ **Don't use base spacing when:**
|
|
47
|
+
|
|
48
|
+
- Component needs to adapt to user density preferences
|
|
49
|
+
- Interactive elements need density-aware padding
|
|
50
|
+
- Form elements should respond to compact/comfy modes
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Density-Aware Spacing
|
|
55
|
+
|
|
56
|
+
SLDS provides three types of density-aware spacing that automatically adjust when users switch between **comfy** (default) and **compact** display modes.
|
|
57
|
+
|
|
58
|
+
### All-Sides Spacing (`--slds-g-spacing-var-*`)
|
|
59
|
+
|
|
60
|
+
Applies equally to top, bottom, left, and right. Use when padding should be uniform on all sides.
|
|
61
|
+
|
|
62
|
+
| Hook | Comfy Value | Compact Value | Use For |
|
|
63
|
+
| ------------------------- | -------------- | -------------- | ---------------- |
|
|
64
|
+
| `--slds-g-spacing-var-1` | 0.25rem (4px) | 0.125rem (2px) | Minimal padding |
|
|
65
|
+
| `--slds-g-spacing-var-2` | 0.5rem (8px) | 0.125rem (2px) | Tight padding |
|
|
66
|
+
| `--slds-g-spacing-var-3` | 0.75rem (12px) | 0.25rem (4px) | Small padding |
|
|
67
|
+
| `--slds-g-spacing-var-4` | 1rem (16px) | 0.5rem (8px) | Standard padding |
|
|
68
|
+
| `--slds-g-spacing-var-5` | 1.5rem (24px) | 0.75rem (12px) | Generous padding |
|
|
69
|
+
| `--slds-g-spacing-var-6` | 2rem (32px) | 1rem (16px) | Large padding |
|
|
70
|
+
| `--slds-g-spacing-var-7` | 2.5rem (40px) | 1.5rem (24px) | XL padding |
|
|
71
|
+
| `--slds-g-spacing-var-8` | 3rem (48px) | 2rem (32px) | XXL padding |
|
|
72
|
+
| `--slds-g-spacing-var-9` | 3.5rem (56px) | 2.5rem (40px) | XXXL padding |
|
|
73
|
+
| `--slds-g-spacing-var-10` | 4rem (64px) | 3rem (48px) | Major padding |
|
|
74
|
+
| `--slds-g-spacing-var-11` | 4.5rem (72px) | 3.5rem (56px) | Extra large |
|
|
75
|
+
| `--slds-g-spacing-var-12` | 5rem (80px) | 4rem (64px) | Maximum padding |
|
|
76
|
+
|
|
77
|
+
**Example:**
|
|
78
|
+
|
|
79
|
+
```css
|
|
80
|
+
.card {
|
|
81
|
+
/* Adapts to density - uniform padding on all sides */
|
|
82
|
+
padding: var(--slds-g-spacing-var-4); /* 16px comfy, 8px compact */
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### Vertical Spacing (`--slds-g-spacing-var-block-*`)
|
|
89
|
+
|
|
90
|
+
Controls top and bottom spacing. Use with `padding-block` or `margin-block` CSS properties.
|
|
91
|
+
|
|
92
|
+
| Hook | Comfy Value | Compact Value | Use For |
|
|
93
|
+
| ------------------------------- | -------------- | -------------- | ----------------- |
|
|
94
|
+
| `--slds-g-spacing-var-block-1` | 0.25rem (4px) | 0.125rem (2px) | Minimal vertical |
|
|
95
|
+
| `--slds-g-spacing-var-block-2` | 0.5rem (8px) | 0.25rem (4px) | Tight vertical |
|
|
96
|
+
| `--slds-g-spacing-var-block-3` | 0.75rem (12px) | 0.5rem (8px) | Small vertical |
|
|
97
|
+
| `--slds-g-spacing-var-block-4` | 1rem (16px) | 0.5rem (8px) | Standard vertical |
|
|
98
|
+
| `--slds-g-spacing-var-block-5` | 1.5rem (24px) | 0.75rem (12px) | Generous vertical |
|
|
99
|
+
| `--slds-g-spacing-var-block-6` | 2rem (32px) | 1rem (16px) | Large vertical |
|
|
100
|
+
| `--slds-g-spacing-var-block-7` | 2.5rem (40px) | 1.5rem (24px) | XL vertical |
|
|
101
|
+
| `--slds-g-spacing-var-block-8` | 3rem (48px) | 2rem (32px) | XXL vertical |
|
|
102
|
+
| `--slds-g-spacing-var-block-9` | 3.5rem (56px) | 2.5rem (40px) | XXXL vertical |
|
|
103
|
+
| `--slds-g-spacing-var-block-10` | 4rem (64px) | 3rem (48px) | Major vertical |
|
|
104
|
+
| `--slds-g-spacing-var-block-11` | 4.5rem (72px) | 3.5rem (56px) | Extra large |
|
|
105
|
+
| `--slds-g-spacing-var-block-12` | 5rem (80px) | 4rem (64px) | Maximum vertical |
|
|
106
|
+
|
|
107
|
+
**Example:**
|
|
108
|
+
|
|
109
|
+
```css
|
|
110
|
+
.list-item {
|
|
111
|
+
/* Vertical padding adapts to density */
|
|
112
|
+
padding-block: var(--slds-g-spacing-var-block-3); /* 12px comfy, 8px compact */
|
|
113
|
+
padding-inline: var(--slds-g-spacing-4); /* Fixed horizontal */
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### Horizontal Spacing (`--slds-g-spacing-var-inline-*`)
|
|
120
|
+
|
|
121
|
+
Controls left and right spacing. Use with `padding-inline` or `margin-inline` CSS properties.
|
|
122
|
+
|
|
123
|
+
| Hook | Comfy Value | Compact Value | Use For |
|
|
124
|
+
| -------------------------------- | -------------- | -------------- | ------------------- |
|
|
125
|
+
| `--slds-g-spacing-var-inline-1` | 0.25rem (4px) | 0.125rem (2px) | Minimal horizontal |
|
|
126
|
+
| `--slds-g-spacing-var-inline-2` | 0.5rem (8px) | 0.25rem (4px) | Tight horizontal |
|
|
127
|
+
| `--slds-g-spacing-var-inline-3` | 0.75rem (12px) | 0.5rem (8px) | Small horizontal |
|
|
128
|
+
| `--slds-g-spacing-var-inline-4` | 1rem (16px) | 0.75rem (12px) | Standard horizontal |
|
|
129
|
+
| `--slds-g-spacing-var-inline-5` | 1.5rem (24px) | 0.75rem (12px) | Generous horizontal |
|
|
130
|
+
| `--slds-g-spacing-var-inline-6` | 2rem (32px) | 1rem (16px) | Large horizontal |
|
|
131
|
+
| `--slds-g-spacing-var-inline-7` | 2.5rem (40px) | 1.5rem (24px) | XL horizontal |
|
|
132
|
+
| `--slds-g-spacing-var-inline-8` | 3rem (48px) | 2rem (32px) | XXL horizontal |
|
|
133
|
+
| `--slds-g-spacing-var-inline-9` | 3.5rem (56px) | 2.5rem (40px) | XXXL horizontal |
|
|
134
|
+
| `--slds-g-spacing-var-inline-10` | 4rem (64px) | 3rem (48px) | Major horizontal |
|
|
135
|
+
| `--slds-g-spacing-var-inline-11` | 4.5rem (72px) | 3.5rem (56px) | Extra large |
|
|
136
|
+
| `--slds-g-spacing-var-inline-12` | 5rem (80px) | 4rem (64px) | Maximum horizontal |
|
|
137
|
+
|
|
138
|
+
**Example:**
|
|
139
|
+
|
|
140
|
+
```css
|
|
141
|
+
.button {
|
|
142
|
+
/* Horizontal padding adapts, vertical doesn't */
|
|
143
|
+
padding-block: var(--slds-g-spacing-3); /* Fixed 12px */
|
|
144
|
+
padding-inline: var(--slds-g-spacing-var-inline-4); /* 16px comfy, 12px compact */
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Decision Tree: Which Spacing Hook to Use?
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
1. Does this element need to adapt to user density preference?
|
|
154
|
+
├─ NO → Use base spacing (--slds-g-spacing-*)
|
|
155
|
+
└─ YES → Continue to step 2
|
|
156
|
+
|
|
157
|
+
2. Should spacing be uniform on all sides?
|
|
158
|
+
├─ YES → Use all-sides var (--slds-g-spacing-var-*)
|
|
159
|
+
└─ NO → Continue to step 3
|
|
160
|
+
|
|
161
|
+
3. Is this primarily vertical spacing (top/bottom)?
|
|
162
|
+
├─ YES → Use block var (--slds-g-spacing-var-block-*)
|
|
163
|
+
└─ NO → Continue to step 4
|
|
164
|
+
|
|
165
|
+
4. Is this primarily horizontal spacing (left/right)?
|
|
166
|
+
├─ YES → Use inline var (--slds-g-spacing-var-inline-*)
|
|
167
|
+
└─ NO → Mix block + inline vars, or use all-sides
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Common Patterns for Agents
|
|
173
|
+
|
|
174
|
+
### Pattern 1: Button with Density-Aware Padding
|
|
175
|
+
|
|
176
|
+
```css
|
|
177
|
+
.button {
|
|
178
|
+
/* Horizontal padding adapts to density */
|
|
179
|
+
padding-inline: var(--slds-g-spacing-var-inline-4); /* 16px → 12px compact */
|
|
180
|
+
|
|
181
|
+
/* Vertical padding adapts to maintain target size */
|
|
182
|
+
padding-block: var(--slds-g-spacing-var-block-2); /* 8px → 4px compact */
|
|
183
|
+
|
|
184
|
+
/* Gap between icon and text (fixed) */
|
|
185
|
+
gap: var(--slds-g-spacing-2); /* Always 8px */
|
|
186
|
+
|
|
187
|
+
/* External margin (fixed) */
|
|
188
|
+
margin-right: var(--slds-g-spacing-3); /* Always 12px */
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Pattern 2: Card Layout with Mixed Spacing
|
|
193
|
+
|
|
194
|
+
```css
|
|
195
|
+
.card {
|
|
196
|
+
/* Internal padding adapts to density */
|
|
197
|
+
padding: var(--slds-g-spacing-var-4); /* 16px → 8px compact */
|
|
198
|
+
|
|
199
|
+
/* External margin stays fixed */
|
|
200
|
+
margin-bottom: var(--slds-g-spacing-4); /* Always 16px */
|
|
201
|
+
|
|
202
|
+
/* Border radius (not spacing - hard-coded) */
|
|
203
|
+
border-radius: 0.25rem;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.card-header {
|
|
207
|
+
/* Smaller padding inside card */
|
|
208
|
+
padding-block: var(--slds-g-spacing-var-block-3); /* 12px → 8px */
|
|
209
|
+
border-bottom: 1px solid var(--slds-g-color-palette-neutral-80);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.card-body {
|
|
213
|
+
/* Standard padding */
|
|
214
|
+
padding: var(--slds-g-spacing-var-4);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Pattern 3: Form with Adaptive Spacing
|
|
219
|
+
|
|
220
|
+
```css
|
|
221
|
+
.form-group {
|
|
222
|
+
/* Vertical spacing between form fields (fixed) */
|
|
223
|
+
margin-bottom: var(--slds-g-spacing-4); /* Always 16px */
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.input {
|
|
227
|
+
/* Input padding adapts to density */
|
|
228
|
+
padding: var(--slds-g-spacing-var-3); /* 12px → 4px compact */
|
|
229
|
+
|
|
230
|
+
/* Or use directional for asymmetric padding */
|
|
231
|
+
padding-block: var(--slds-g-spacing-var-block-2); /* 8px → 4px */
|
|
232
|
+
padding-inline: var(--slds-g-spacing-var-inline-3); /* 12px → 8px */
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.label {
|
|
236
|
+
/* Label margin (fixed) */
|
|
237
|
+
margin-bottom: var(--slds-g-spacing-2); /* Always 8px */
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Pattern 4: List with Density-Aware Items
|
|
242
|
+
|
|
243
|
+
```css
|
|
244
|
+
.list {
|
|
245
|
+
/* Container padding (fixed) */
|
|
246
|
+
padding: var(--slds-g-spacing-4); /* Always 16px */
|
|
247
|
+
|
|
248
|
+
/* Gap between items (fixed) */
|
|
249
|
+
gap: var(--slds-g-spacing-2); /* Always 8px */
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.list-item {
|
|
253
|
+
/* Item padding adapts vertically */
|
|
254
|
+
padding-block: var(--slds-g-spacing-var-block-3); /* 12px → 8px compact */
|
|
255
|
+
|
|
256
|
+
/* Item padding fixed horizontally */
|
|
257
|
+
padding-inline: var(--slds-g-spacing-4); /* Always 16px */
|
|
258
|
+
|
|
259
|
+
/* Border separation */
|
|
260
|
+
border-bottom: 1px solid var(--slds-g-color-palette-neutral-80);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.list-item:last-child {
|
|
264
|
+
border-bottom: none;
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Pattern 5: Page Layout Structure
|
|
269
|
+
|
|
270
|
+
```css
|
|
271
|
+
.page-container {
|
|
272
|
+
/* Large fixed padding for page structure */
|
|
273
|
+
padding: var(--slds-g-spacing-6); /* Always 32px */
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.section {
|
|
277
|
+
/* Section spacing (fixed) */
|
|
278
|
+
margin-bottom: var(--slds-g-spacing-7); /* Always 40px */
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.section-header {
|
|
282
|
+
/* Header padding adapts */
|
|
283
|
+
padding-block: var(--slds-g-spacing-var-block-4); /* 16px → 8px */
|
|
284
|
+
margin-bottom: var(--slds-g-spacing-4); /* Fixed 16px */
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.section-content {
|
|
288
|
+
/* Content padding (fixed for consistency) */
|
|
289
|
+
padding: var(--slds-g-spacing-5); /* Always 24px */
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Accessibility Considerations
|
|
296
|
+
|
|
297
|
+
### Target Size Requirements
|
|
298
|
+
|
|
299
|
+
Spacing is **the primary method** for achieving minimum interactive target sizes:
|
|
300
|
+
|
|
301
|
+
#### WCAG 2.2 Requirements:
|
|
302
|
+
|
|
303
|
+
- **Desktop/Pointer:** Minimum 24×24px (AA), 44×44px recommended (AAA)
|
|
304
|
+
- **Mobile/Touch:** Minimum 44×44pt/dp/px
|
|
305
|
+
- **Salesforce Default:** 44×44px for consistency across environments
|
|
306
|
+
|
|
307
|
+
#### Using Spacing for Target Sizes:
|
|
308
|
+
|
|
309
|
+
```css
|
|
310
|
+
/* ✅ COMPLIANT - Button achieves 44×44px target */
|
|
311
|
+
.button-small {
|
|
312
|
+
/* Text is ~14px, line-height ~20px */
|
|
313
|
+
padding-block: var(--slds-g-spacing-var-block-4); /* 16px top+bottom = 32px */
|
|
314
|
+
padding-inline: var(--slds-g-spacing-var-inline-4); /* 16px each side */
|
|
315
|
+
/* Total height: 20px text + 32px padding = 52px (compliant) */
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/* ⚠️ BORDERLINE - May fall below 44px in compact mode */
|
|
319
|
+
.button-compact {
|
|
320
|
+
padding-block: var(--slds-g-spacing-var-block-3); /* 12px → 8px compact */
|
|
321
|
+
/* Comfy: 20px + 24px = 44px ✅ */
|
|
322
|
+
/* Compact: 20px + 16px = 36px ❌ (non-compliant) */
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/* ✅ BETTER - Maintains compliance in both modes */
|
|
326
|
+
.button-adaptive {
|
|
327
|
+
/* Use larger var or fixed spacing for critical targets */
|
|
328
|
+
padding-block: var(--slds-g-spacing-4); /* Always 16px = 52px total ✅ */
|
|
329
|
+
padding-inline: var(--slds-g-spacing-var-inline-4); /* Can adapt */
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Spacing Exception
|
|
334
|
+
|
|
335
|
+
Interactive elements **smaller than 24×24px** are acceptable if:
|
|
336
|
+
|
|
337
|
+
- Sufficient spacing ensures a **24px diameter circle** around each target doesn't intersect another target
|
|
338
|
+
- This means minimum `--slds-g-spacing-6` (32px) between small targets
|
|
339
|
+
|
|
340
|
+
```css
|
|
341
|
+
/* ✅ ACCEPTABLE - Small icon buttons with spacing */
|
|
342
|
+
.icon-button-small {
|
|
343
|
+
width: 20px;
|
|
344
|
+
height: 20px;
|
|
345
|
+
margin: var(--slds-g-spacing-3); /* 12px = 24px total space around */
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Readability and Scannability
|
|
350
|
+
|
|
351
|
+
- **Consistent spacing** improves scanability for all users
|
|
352
|
+
- **Adequate spacing** between interactive elements supports users with motor impairments
|
|
353
|
+
- **Clear visual grouping** through spacing helps users with cognitive disabilities
|
|
354
|
+
- **Vertical rhythm** supports readability
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## Common Mistakes and Solutions
|
|
359
|
+
|
|
360
|
+
### Mistake 1: Using Named Hooks
|
|
361
|
+
|
|
362
|
+
```css
|
|
363
|
+
/* ❌ WRONG - These don't exist */
|
|
364
|
+
.element {
|
|
365
|
+
padding: var(--slds-g-spacing-small);
|
|
366
|
+
margin: var(--slds-g-spacing-medium);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* ✅ CORRECT - Use numbered hooks */
|
|
370
|
+
.element {
|
|
371
|
+
padding: var(--slds-g-spacing-3); /* 12px */
|
|
372
|
+
margin: var(--slds-g-spacing-4); /* 16px */
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Mistake 2: Using Spacing for Dimensions
|
|
377
|
+
|
|
378
|
+
```css
|
|
379
|
+
/* ❌ WRONG - Don't use spacing for width/height */
|
|
380
|
+
.box {
|
|
381
|
+
width: var(--slds-g-spacing-12);
|
|
382
|
+
height: var(--slds-g-spacing-10);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* ✅ CORRECT - Use sizing hooks or hard-code */
|
|
386
|
+
.box {
|
|
387
|
+
width: var(--slds-g-sizing-12); /* If sizing hooks available */
|
|
388
|
+
height: 5rem; /* Or hard-code with comment */
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Mistake 3: Mixing Density Types Inconsistently
|
|
393
|
+
|
|
394
|
+
```css
|
|
395
|
+
/* ⚠️ INCONSISTENT - Mixing strategies without reason */
|
|
396
|
+
.element {
|
|
397
|
+
padding-top: var(--slds-g-spacing-var-block-3);
|
|
398
|
+
padding-right: var(--slds-g-spacing-4);
|
|
399
|
+
padding-bottom: var(--slds-g-spacing-var-2);
|
|
400
|
+
padding-left: var(--slds-g-spacing-var-inline-4);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/* ✅ BETTER - Consistent approach */
|
|
404
|
+
.element {
|
|
405
|
+
padding-block: var(--slds-g-spacing-var-block-3);
|
|
406
|
+
padding-inline: var(--slds-g-spacing-var-inline-4);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/* ✅ OR - All fixed if density shouldn't change */
|
|
410
|
+
.element {
|
|
411
|
+
padding: var(--slds-g-spacing-3) var(--slds-g-spacing-4);
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### Mistake 4: Hard-Coding Pixel Values
|
|
416
|
+
|
|
417
|
+
```css
|
|
418
|
+
/* ❌ WRONG - Hard-coded values */
|
|
419
|
+
.element {
|
|
420
|
+
padding: 16px;
|
|
421
|
+
margin: 24px;
|
|
422
|
+
gap: 8px;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/* ✅ CORRECT - Use spacing hooks */
|
|
426
|
+
.element {
|
|
427
|
+
padding: var(--slds-g-spacing-4); /* 16px */
|
|
428
|
+
margin: var(--slds-g-spacing-5); /* 24px */
|
|
429
|
+
gap: var(--slds-g-spacing-2); /* 8px */
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Summary for Coding Agents
|
|
436
|
+
|
|
437
|
+
### Quick Selection Guide
|
|
438
|
+
|
|
439
|
+
**For fixed spacing that never changes:**
|
|
440
|
+
|
|
441
|
+
- Use `--slds-g-spacing-[1-12]`
|
|
442
|
+
- Common: `spacing-2` (8px), `spacing-4` (16px), `spacing-5` (24px)
|
|
443
|
+
|
|
444
|
+
**For interactive components that adapt to density:**
|
|
445
|
+
|
|
446
|
+
- Uniform padding: `--slds-g-spacing-var-[1-12]`
|
|
447
|
+
- Vertical only: `--slds-g-spacing-var-block-[1-12]`
|
|
448
|
+
- Horizontal only: `--slds-g-spacing-var-inline-[1-12]`
|
|
449
|
+
|
|
450
|
+
**Most Common Hooks:**
|
|
451
|
+
|
|
452
|
+
- `spacing-2` (8px) - Icon gaps, small margins
|
|
453
|
+
- `spacing-3` (12px) - Small padding, label margins
|
|
454
|
+
- `spacing-4` (16px) - Standard padding/margins
|
|
455
|
+
- `spacing-5` (24px) - Generous padding
|
|
456
|
+
- `spacing-6` (32px) - Large component spacing
|
|
457
|
+
|
|
458
|
+
### Search for Hooks
|
|
459
|
+
|
|
460
|
+
```javascript
|
|
461
|
+
// Find all spacing hooks
|
|
462
|
+
{
|
|
463
|
+
{
|
|
464
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
({ prefix: '--slds-g-spacing-' });
|
|
468
|
+
|
|
469
|
+
// Find density-aware hooks
|
|
470
|
+
{
|
|
471
|
+
{
|
|
472
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
({ search: 'spacing-var' });
|
|
476
|
+
|
|
477
|
+
// Check specific hook
|
|
478
|
+
{
|
|
479
|
+
{
|
|
480
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
({ hooks: ['--slds-g-spacing-4'] });
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Key Rules
|
|
487
|
+
|
|
488
|
+
1. ✅ Use numbered hooks (1-12), not named (small/medium/large)
|
|
489
|
+
2. ✅ Use density-aware hooks for interactive components
|
|
490
|
+
3. ✅ Use fixed spacing for layout structure
|
|
491
|
+
4. ✅ Maintain 44×44px minimum target sizes with padding
|
|
492
|
+
5. ❌ Never use spacing hooks for element dimensions (width/height)
|
|
493
|
+
6. ❌ Never hard-code pixel values when hooks exist
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
**References:**
|
|
498
|
+
|
|
499
|
+
- [SLDS Spacing and Sizing](https://www.lightningdesignsystem.com/2e1ef8501/p/03d6b0-spacing-and-sizing)
|
|
500
|
+
- [Complete Hooks Index](../metadata/hooks-index.json)
|
|
501
|
+
- [Guidance Overview](../guidance.md)
|