@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,906 @@
|
|
|
1
|
+
# SLDS Styling Hooks: Guidance for Coding Agents
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Salesforce Lightning Design System (SLDS) styling hooks are CSS custom properties that provide a theme-aware, maintainable styling system. When generating or optimizing SLDS components, **always use styling hooks instead of hard-coded values** to ensure components adapt automatically to:
|
|
6
|
+
|
|
7
|
+
- Brand themes and customizations
|
|
8
|
+
- Light/dark mode switches
|
|
9
|
+
- Density settings (compact, comfy, spacious)
|
|
10
|
+
- Accessibility requirements
|
|
11
|
+
- Future design system updates
|
|
12
|
+
|
|
13
|
+
**Critical Rule:** Reference styling hooks using `var()` — never reassign their values. Salesforce controls these values and can change them at any time.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Styling Hook Hierarchy
|
|
18
|
+
|
|
19
|
+
SLDS styling hooks follow a three-tier naming convention:
|
|
20
|
+
|
|
21
|
+
1. **Global Semantic** (`--slds-g-*`): System-wide hooks for universal use across all components
|
|
22
|
+
2. **Shared** (`--slds-s-*`): Private/internal hooks — **DO NOT USE** (reserved for Salesforce)
|
|
23
|
+
3. **Component-Specific** (`--slds-c-*`): Hooks scoped to individual component types for fine-tuning
|
|
24
|
+
|
|
25
|
+
**Always use global hooks (`--slds-g-*`) unless component-specific hooks exist for your use case.**
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Core Categories
|
|
30
|
+
|
|
31
|
+
### 1. Color Hooks (`--slds-g-color-*`)
|
|
32
|
+
|
|
33
|
+
SLDS provides a comprehensive color system with ~375 hooks organized into three tiers:
|
|
34
|
+
|
|
35
|
+
#### **Tier 1: Semantic UI Colors (PREFERRED)**
|
|
36
|
+
|
|
37
|
+
Purpose-driven colors that automatically adapt to themes and modes:
|
|
38
|
+
|
|
39
|
+
- **Surface** (`surface-*`): Page backgrounds, panels, modal overlays
|
|
40
|
+
- **Container** (`container-*`): Buttons, cards, tabs, input fields
|
|
41
|
+
- **Accent** (`accent-*`): Brand emphasis and selection states
|
|
42
|
+
- Use for: primary actions, selected items, brand highlights
|
|
43
|
+
- Hooks: `accent-1/2/3`, `accent-container-1/2/3`, `border-accent-1/2/3`, `on-accent-1/2/3`
|
|
44
|
+
- Numbered variants represent state progression: 1 = default, 2 = hover, 3 = active
|
|
45
|
+
- **Border** (`border-*`): Component borders, dividers, separators
|
|
46
|
+
- **Feedback** (`feedback-*`): Alerts, notifications, validation states
|
|
47
|
+
- Types: `error`, `warning`, `success`, `info`, `discovery`
|
|
48
|
+
- **On-Colors** (`on-*`): Text and icons on colored backgrounds
|
|
49
|
+
- **Always pair with corresponding container colors for accessibility**
|
|
50
|
+
|
|
51
|
+
#### **Tier 2: System Colors**
|
|
52
|
+
|
|
53
|
+
Accessible, system-wide colors for edge cases where semantic colors don't apply:
|
|
54
|
+
|
|
55
|
+
- Base colors for neutrals, brand, and feedback states
|
|
56
|
+
- Use when semantic UI colors don't match your use case
|
|
57
|
+
|
|
58
|
+
#### **Tier 3: Palette Colors (Use Sparingly)**
|
|
59
|
+
|
|
60
|
+
Raw color values organized on a 0-100 scale for data visualization and custom scenarios:
|
|
61
|
+
|
|
62
|
+
- **Palettes:** `neutral`, `brand`, `red`, `pink`, `orange`, `yellow`, `green`, `teal`, `cloud-blue`, `blue`, `indigo`, `purple`, `violet`
|
|
63
|
+
- **Scale:** 0 (darkest) to 100 (lightest) in 5-point increments
|
|
64
|
+
- **Accessibility Built-In:** 50-point separation = WCAG AA text contrast (4.5:1), 40-point = UI element contrast (3:1)
|
|
65
|
+
- **When to Use:** Data visualization, custom charts, situations undefined by semantic system
|
|
66
|
+
- **Example:** `--slds-g-color-palette-blue-50`
|
|
67
|
+
|
|
68
|
+
**How to use palette colors:**
|
|
69
|
+
|
|
70
|
+
```css
|
|
71
|
+
/* Text on light background - use low numbers (dark colors) */
|
|
72
|
+
color: var(--slds-g-color-palette-neutral-10); /* Very dark gray text */
|
|
73
|
+
background: var(--slds-g-color-palette-neutral-95); /* Very light gray background */
|
|
74
|
+
/* 85-point separation = excellent contrast */
|
|
75
|
+
|
|
76
|
+
/* Border on white - use mid-range */
|
|
77
|
+
border: 1px solid var(--slds-g-color-palette-neutral-60);
|
|
78
|
+
/* 40-point separation from neutral-100 (white) = compliant */
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Color Density Rule:** Maintain 85% neutral, 5% accent, 10% expressive colors for proper visual hierarchy.
|
|
82
|
+
|
|
83
|
+
> **💡 For comprehensive color system guidance:** Use `{{GUIDE_SLDS_STYLING_TOOL}}({ topic: "colors" })` to get detailed documentation on the three-tier color system, palette families, accessibility rules, decision trees, and usage patterns.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### 2. Spacing Hooks (`--slds-g-spacing-*`)
|
|
88
|
+
|
|
89
|
+
SLDS uses a numbered scale (NOT named like "small/medium/large"):
|
|
90
|
+
|
|
91
|
+
| Hook Name | Value | Pixels | Legacy Equivalent |
|
|
92
|
+
| --------------------- | ------- | ------ | ----------------- |
|
|
93
|
+
| `--slds-g-spacing-1` | 0.25rem | 4px | xx-small |
|
|
94
|
+
| `--slds-g-spacing-2` | 0.5rem | 8px | x-small |
|
|
95
|
+
| `--slds-g-spacing-3` | 0.75rem | 12px | small |
|
|
96
|
+
| `--slds-g-spacing-4` | 1rem | 16px | medium |
|
|
97
|
+
| `--slds-g-spacing-5` | 1.5rem | 24px | large |
|
|
98
|
+
| `--slds-g-spacing-6` | 2rem | 32px | x-large |
|
|
99
|
+
| `--slds-g-spacing-7` | 2.5rem | 40px | xx-large |
|
|
100
|
+
| `--slds-g-spacing-8` | 3rem | 48px | xxx-large |
|
|
101
|
+
| `--slds-g-spacing-9` | 3.5rem | 56px | - |
|
|
102
|
+
| `--slds-g-spacing-10` | 4rem | 64px | - |
|
|
103
|
+
| `--slds-g-spacing-11` | 4.5rem | 72px | - |
|
|
104
|
+
| `--slds-g-spacing-12` | 5rem | 80px | - |
|
|
105
|
+
|
|
106
|
+
**Usage:**
|
|
107
|
+
|
|
108
|
+
```css
|
|
109
|
+
/* Use numbered hooks - NOT named ones */
|
|
110
|
+
margin: var(--slds-g-spacing-4); /* ✅ Correct */
|
|
111
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4); /* ✅ Correct */
|
|
112
|
+
gap: var(--slds-g-spacing-3); /* ✅ Correct */
|
|
113
|
+
|
|
114
|
+
/* DON'T use named hooks - they don't exist */
|
|
115
|
+
margin: var(--slds-g-spacing-medium); /* ❌ Wrong - hook doesn't exist */
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Principle:** Use spacing hooks to maintain consistent whitespace and rhythm across your component.
|
|
119
|
+
|
|
120
|
+
> **💡 For comprehensive spacing system guidance:** Use `{{GUIDE_SLDS_STYLING_TOOL}}({ topic: "spacing" })` to get detailed documentation on the spacing scale, density-aware hooks, directional variants, accessibility requirements, and usage patterns.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### 3. Typography Hooks (`--slds-g-font-*`)
|
|
125
|
+
|
|
126
|
+
#### Font Families
|
|
127
|
+
|
|
128
|
+
- `--slds-g-font-family` - Default font family
|
|
129
|
+
- `--slds-g-font-family-base` - Base font family (same as above)
|
|
130
|
+
- `--slds-g-font-family-monospace` - For code snippets
|
|
131
|
+
|
|
132
|
+
#### Font Weights (Numbered 1-7)
|
|
133
|
+
|
|
134
|
+
| Hook Name | Typical Value | Common Name |
|
|
135
|
+
| ------------------------ | ------------- | ----------- |
|
|
136
|
+
| `--slds-g-font-weight-1` | 300 | Light |
|
|
137
|
+
| `--slds-g-font-weight-2` | 300 | Light |
|
|
138
|
+
| `--slds-g-font-weight-3` | 400 | Regular |
|
|
139
|
+
| `--slds-g-font-weight-4` | 400 | Regular |
|
|
140
|
+
| `--slds-g-font-weight-5` | 500 | Medium |
|
|
141
|
+
| `--slds-g-font-weight-6` | 600 | Semi-Bold |
|
|
142
|
+
| `--slds-g-font-weight-7` | 700 | Bold |
|
|
143
|
+
|
|
144
|
+
**Usage:**
|
|
145
|
+
|
|
146
|
+
```css
|
|
147
|
+
/* Use numbered hooks */
|
|
148
|
+
font-weight: var(--slds-g-font-weight-7); /* Bold */
|
|
149
|
+
font-weight: var(--slds-g-font-weight-5); /* Medium */
|
|
150
|
+
|
|
151
|
+
/* DON'T use named hooks - they don't exist */
|
|
152
|
+
font-weight: var(--slds-g-font-weight-bold); /* ❌ Wrong */
|
|
153
|
+
font-weight: var(--slds-g-font-weight-medium); /* ❌ Wrong */
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Line Heights (Numbered 1-6)
|
|
157
|
+
|
|
158
|
+
- `--slds-g-font-lineheight-1` through `--slds-g-font-lineheight-6`
|
|
159
|
+
|
|
160
|
+
#### Font Sizes
|
|
161
|
+
|
|
162
|
+
Only one font size hook exists:
|
|
163
|
+
|
|
164
|
+
- `--slds-g-font-size-base` - Base font size for body text
|
|
165
|
+
|
|
166
|
+
For other font sizes, use rem values directly (e.g., `1.5rem`, `0.875rem`, `0.75rem`).
|
|
167
|
+
|
|
168
|
+
**Principle:** Use typography hooks to ensure text renders consistently and scales properly across density settings.
|
|
169
|
+
|
|
170
|
+
> **💡 For comprehensive typography system guidance:** Use `{{GUIDE_SLDS_STYLING_TOOL}}({ topic: "typography" })` to get detailed documentation on numbered weights, line heights, font families, typography hierarchy patterns, and accessibility requirements.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### 4. Other Styling Hooks
|
|
175
|
+
|
|
176
|
+
- **Sizing** (`--slds-g-sizing-*`): Component dimensions, icon sizes, border widths
|
|
177
|
+
|
|
178
|
+
> **💡 For comprehensive sizing guidance:** Use `{{GUIDE_SLDS_STYLING_TOOL}}({ topic: "sizing" })` to get detailed documentation on element dimensions, border widths, typography widths, and 8-point grid alignment.
|
|
179
|
+
|
|
180
|
+
- **Shadow** (`--slds-g-shadow-*`): Elevation and depth effects
|
|
181
|
+
|
|
182
|
+
> **💡 For comprehensive shadow guidance:** Use `{{GUIDE_SLDS_STYLING_TOOL}}({ topic: "shadows" })` to get detailed documentation on elevation levels, focus states, directional shadows, and inverse shadows.
|
|
183
|
+
|
|
184
|
+
- **Radius** (`--slds-g-radius-*`): Border radius values for rounded corners
|
|
185
|
+
> **💡 For comprehensive border radius guidance:** Use `{{GUIDE_SLDS_STYLING_TOOL}}({ topic: "borders" })` to get detailed documentation on progressive rounding, circle vs pill shapes, and component-specific usage.
|
|
186
|
+
|
|
187
|
+
Use `{{EXPLORE_SLDS_STYLING_TOOL}}` to search for specific hooks in these categories as needed.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Usage Patterns for Coding Agents
|
|
192
|
+
|
|
193
|
+
### Pattern 1: Interactive Component States (Accent Colors)
|
|
194
|
+
|
|
195
|
+
For components with hover/active states, use numbered accent variants:
|
|
196
|
+
|
|
197
|
+
```css
|
|
198
|
+
.button {
|
|
199
|
+
background: var(--slds-g-color-accent-container-1);
|
|
200
|
+
color: var(--slds-g-color-on-accent-1);
|
|
201
|
+
border: 1px solid var(--slds-g-color-border-accent-1);
|
|
202
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4);
|
|
203
|
+
border-radius: var(--slds-g-radius-border-1);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.button:hover {
|
|
207
|
+
background: var(--slds-g-color-accent-container-2);
|
|
208
|
+
color: var(--slds-g-color-on-accent-2);
|
|
209
|
+
border-color: var(--slds-g-color-border-accent-2);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.button:active {
|
|
213
|
+
background: var(--slds-g-color-accent-container-3);
|
|
214
|
+
color: var(--slds-g-color-on-accent-3);
|
|
215
|
+
border-color: var(--slds-g-color-border-accent-3);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
### Pattern 2: Semantic Surfaces
|
|
222
|
+
|
|
223
|
+
Use semantic surface and container hooks for backgrounds:
|
|
224
|
+
|
|
225
|
+
```css
|
|
226
|
+
.card {
|
|
227
|
+
background: var(--slds-g-color-surface-container-1);
|
|
228
|
+
color: var(--slds-g-color-on-surface-1);
|
|
229
|
+
padding: var(--slds-g-spacing-4);
|
|
230
|
+
border: 1px solid var(--slds-g-color-border-1);
|
|
231
|
+
border-radius: var(--slds-g-radius-border-1);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### Pattern 3: Feedback States
|
|
238
|
+
|
|
239
|
+
Use semantic feedback hooks for alerts and notifications:
|
|
240
|
+
|
|
241
|
+
```css
|
|
242
|
+
.alert-error {
|
|
243
|
+
background: var(--slds-g-color-error-container-1);
|
|
244
|
+
color: var(--slds-g-color-on-error-1);
|
|
245
|
+
border-left: 4px solid var(--slds-g-color-error-1);
|
|
246
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4);
|
|
247
|
+
border-radius: var(--slds-g-radius-border-1);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.alert-success {
|
|
251
|
+
background: var(--slds-g-color-success-container-1);
|
|
252
|
+
color: var(--slds-g-color-on-success-1);
|
|
253
|
+
border-left: 4px solid var(--slds-g-color-success-1);
|
|
254
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.alert-warning {
|
|
258
|
+
background: var(--slds-g-color-warning-container-1);
|
|
259
|
+
color: var(--slds-g-color-on-warning-1);
|
|
260
|
+
border-left: 4px solid var(--slds-g-color-warning-1);
|
|
261
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4);
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
### Pattern 4: Data Visualization with Palette Colors
|
|
268
|
+
|
|
269
|
+
Use palette colors for charts and data viz:
|
|
270
|
+
|
|
271
|
+
```css
|
|
272
|
+
/* Custom chart colors - using palette for data differentiation */
|
|
273
|
+
.chart-series-1 {
|
|
274
|
+
background: var(--slds-g-color-palette-blue-50);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.chart-series-2 {
|
|
278
|
+
background: var(--slds-g-color-palette-green-50);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.chart-series-3 {
|
|
282
|
+
background: var(--slds-g-color-palette-purple-50);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.chart-series-4 {
|
|
286
|
+
background: var(--slds-g-color-palette-orange-50);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/* Verified: 50-point separation from neutral-100 background = WCAG AA compliant */
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### Pattern 5: Typography Hierarchy
|
|
295
|
+
|
|
296
|
+
Use typography hooks for consistent type styling:
|
|
297
|
+
|
|
298
|
+
```css
|
|
299
|
+
.heading {
|
|
300
|
+
font-family: var(--slds-g-font-family-base);
|
|
301
|
+
font-size: 1.5rem; /* Use rem values - no numbered font-size hooks exist */
|
|
302
|
+
font-weight: var(--slds-g-font-weight-7);
|
|
303
|
+
line-height: var(--slds-g-font-lineheight-2);
|
|
304
|
+
color: var(--slds-g-color-on-surface-3); /* Highest emphasis */
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.body-text {
|
|
308
|
+
font-family: var(--slds-g-font-family-base);
|
|
309
|
+
font-size: var(--slds-g-font-size-base);
|
|
310
|
+
font-weight: var(--slds-g-font-weight-4);
|
|
311
|
+
line-height: var(--slds-g-font-lineheight-3);
|
|
312
|
+
color: var(--slds-g-color-on-surface-2); /* Standard text */
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.caption {
|
|
316
|
+
font-family: var(--slds-g-font-family-base);
|
|
317
|
+
font-size: 0.75rem; /* Use rem values - no numbered font-size hooks exist */
|
|
318
|
+
font-weight: var(--slds-g-font-weight-4);
|
|
319
|
+
color: var(--slds-g-color-on-surface-1); /* De-emphasized */
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Decision Tree for Coding Agents
|
|
326
|
+
|
|
327
|
+
When styling a component, follow this hierarchy:
|
|
328
|
+
|
|
329
|
+
### Step 1: Check for Component-Specific Hooks
|
|
330
|
+
|
|
331
|
+
Search for `--slds-c-[component-name]-*` hooks first (highest specificity):
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
{
|
|
335
|
+
{
|
|
336
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
({ prefix: '--slds-c-button-' });
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Step 2: Use Semantic UI Colors (Preferred)
|
|
343
|
+
|
|
344
|
+
For colors, prefer semantic hooks:
|
|
345
|
+
|
|
346
|
+
- **Surface/Container**: `surface-1/2/3`, `surface-container-1/2/3`, `on-surface-1/2/3`
|
|
347
|
+
- **Accent**: `accent-1/2/3`, `accent-container-1/2/3`, `border-accent-1/2/3`, `on-accent-1/2/3`
|
|
348
|
+
- **Feedback**: `error-1`, `success-1`, `warning-1`, `info-1` with their container and on-color variants
|
|
349
|
+
- **Border**: `border-1/2`, `border-accent-*`, `border-error-*`, `border-success-*`
|
|
350
|
+
|
|
351
|
+
### Step 3: Use System Colors When Needed
|
|
352
|
+
|
|
353
|
+
For edge cases where semantic UI doesn't fit, use system colors:
|
|
354
|
+
|
|
355
|
+
```javascript
|
|
356
|
+
{
|
|
357
|
+
{
|
|
358
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
({ search: 'system' });
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Step 4: Use Palette Colors for Data Viz
|
|
365
|
+
|
|
366
|
+
Only for data visualization or undefined scenarios:
|
|
367
|
+
|
|
368
|
+
```javascript
|
|
369
|
+
{
|
|
370
|
+
{
|
|
371
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
({ prefix: '--slds-g-color-palette-' });
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
- Ensure 50-point separation for text (4.5:1 contrast)
|
|
378
|
+
- Ensure 40-point separation for UI elements (3:1 contrast)
|
|
379
|
+
|
|
380
|
+
### Step 5: Use Numbered Spacing & Typography
|
|
381
|
+
|
|
382
|
+
Always use numbered hooks where available:
|
|
383
|
+
|
|
384
|
+
```css
|
|
385
|
+
padding: var(--slds-g-spacing-4);
|
|
386
|
+
font-weight: var(--slds-g-font-weight-5);
|
|
387
|
+
font-size: var(--slds-g-font-size-base); /* Or use rem values */
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## How to Get More Information
|
|
393
|
+
|
|
394
|
+
> **Note:** Contextual tool references are embedded throughout this document. Look for 💡 callouts in each category section (Colors, Spacing, Typography, etc.) for quick access to category-specific guidance.
|
|
395
|
+
|
|
396
|
+
### Using the `{{EXPLORE_SLDS_STYLING_TOOL}}` Tool
|
|
397
|
+
|
|
398
|
+
To find specific styling hooks or explore categories:
|
|
399
|
+
|
|
400
|
+
```javascript
|
|
401
|
+
// Search for all accent color hooks
|
|
402
|
+
{
|
|
403
|
+
{
|
|
404
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
({ search: 'accent' });
|
|
408
|
+
|
|
409
|
+
// Find all spacing hooks
|
|
410
|
+
{
|
|
411
|
+
{
|
|
412
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
({ prefix: '--slds-g-spacing-' });
|
|
416
|
+
|
|
417
|
+
// Look up specific hooks by name
|
|
418
|
+
{
|
|
419
|
+
{
|
|
420
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
({ hooks: ['--slds-g-color-accent-1', '--slds-g-spacing-4'] });
|
|
424
|
+
|
|
425
|
+
// Filter by category
|
|
426
|
+
{
|
|
427
|
+
{
|
|
428
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
({ category: 'color' });
|
|
432
|
+
|
|
433
|
+
// Get detailed information
|
|
434
|
+
{
|
|
435
|
+
{
|
|
436
|
+
EXPLORE_SLDS_STYLING_TOOL;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
({ search: 'palette', detail_level: 'full' });
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
**Common Search Patterns:**
|
|
443
|
+
|
|
444
|
+
- Spacing values: `prefix: "--slds-g-spacing-"`
|
|
445
|
+
- Accent colors: `search: "accent"`
|
|
446
|
+
- Palette colors: `prefix: "--slds-g-color-palette-"`
|
|
447
|
+
- Typography: `prefix: "--slds-g-font-"`
|
|
448
|
+
- Shadows: `prefix: "--slds-g-shadow-"`
|
|
449
|
+
- Sizing: `prefix: "--slds-g-sizing-"`
|
|
450
|
+
|
|
451
|
+
### Tool Output
|
|
452
|
+
|
|
453
|
+
The tool returns:
|
|
454
|
+
|
|
455
|
+
- **Hook name** - The full CSS custom property name
|
|
456
|
+
- **Value** - Current value (may change with themes)
|
|
457
|
+
- **Category** - Color, spacing, font, sizing, etc.
|
|
458
|
+
- **Usage guidance** - When and how to use the hook
|
|
459
|
+
- **Related hooks** - Complementary hooks to consider
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
## Critical Rules for Agents
|
|
464
|
+
|
|
465
|
+
### ✅ DO:
|
|
466
|
+
|
|
467
|
+
- Reference hooks with `var()`: `color: var(--slds-g-color-accent-1);`
|
|
468
|
+
- Use numbered spacing: `spacing-4` not `spacing-medium`
|
|
469
|
+
- Use numbered font weights: `font-weight-5` not `font-weight-medium`
|
|
470
|
+
- Use `font-size-base` or rem values for font sizes (no numbered font-size hooks exist)
|
|
471
|
+
- Prefer semantic UI colors over system colors and palette colors
|
|
472
|
+
- Pair container colors with on-colors for text/icons (e.g., `surface-container-1` with `on-surface-1/2/3`)
|
|
473
|
+
- Follow the 50-point rule for text contrast, 40-point rule for UI elements
|
|
474
|
+
- Use numbered variants (1/2/3) for state progression where available
|
|
475
|
+
- Use `{{EXPLORE_SLDS_STYLING_TOOL}}` to verify hook names
|
|
476
|
+
|
|
477
|
+
### ❌ DON'T:
|
|
478
|
+
|
|
479
|
+
- Reassign hook values: `--slds-g-color-accent-1: #ff0000;` ❌
|
|
480
|
+
- Use private hooks (`--_slds-*` or `--slds-s-*`)
|
|
481
|
+
- Use `@layer` syntax (reserved for Salesforce)
|
|
482
|
+
- Use named spacing hooks (`spacing-small`, `spacing-medium`) - they don't exist
|
|
483
|
+
- Use named font hooks (`font-weight-medium`, `font-weight-bold`) - they don't exist
|
|
484
|
+
- Mix palette levels without checking contrast (maintain 40-50 point separation)
|
|
485
|
+
- Hard-code values when hooks exist
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## Quick Reference: Common Patterns
|
|
490
|
+
|
|
491
|
+
### Button Component
|
|
492
|
+
|
|
493
|
+
```css
|
|
494
|
+
.myCustomButton {
|
|
495
|
+
/* Colors */
|
|
496
|
+
background: var(--slds-g-color-accent-container-1);
|
|
497
|
+
color: var(--slds-g-color-on-accent-1);
|
|
498
|
+
border: 1px solid var(--slds-g-color-border-accent-1);
|
|
499
|
+
|
|
500
|
+
/* Spacing */
|
|
501
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4);
|
|
502
|
+
margin-bottom: var(--slds-g-spacing-3);
|
|
503
|
+
|
|
504
|
+
/* Typography */
|
|
505
|
+
font-family: var(--slds-g-font-family-base);
|
|
506
|
+
font-size: var(--slds-g-font-size-base);
|
|
507
|
+
font-weight: var(--slds-g-font-weight-5);
|
|
508
|
+
line-height: var(--slds-g-font-lineheight-3);
|
|
509
|
+
|
|
510
|
+
/* Borders */
|
|
511
|
+
border-radius: var(--slds-g-radius-border-1);
|
|
512
|
+
|
|
513
|
+
/* States */
|
|
514
|
+
transition: all 0.2s ease;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.myCustomButton:hover {
|
|
518
|
+
background: var(--slds-g-color-accent-container-2);
|
|
519
|
+
color: var(--slds-g-color-on-accent-2);
|
|
520
|
+
border-color: var(--slds-g-color-border-accent-2);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.myCustomButton:active {
|
|
524
|
+
background: var(--slds-g-color-accent-container-3);
|
|
525
|
+
color: var(--slds-g-color-on-accent-3);
|
|
526
|
+
border-color: var(--slds-g-color-border-accent-3);
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
### Card Component
|
|
533
|
+
|
|
534
|
+
```css
|
|
535
|
+
.slds-card {
|
|
536
|
+
/* Surface Container */
|
|
537
|
+
background: var(--slds-g-color-surface-container-1);
|
|
538
|
+
color: var(--slds-g-color-on-surface-2);
|
|
539
|
+
|
|
540
|
+
/* Spacing */
|
|
541
|
+
padding: var(--slds-g-spacing-4);
|
|
542
|
+
margin-bottom: var(--slds-g-spacing-4);
|
|
543
|
+
|
|
544
|
+
/* Borders & Elevation */
|
|
545
|
+
border: 1px solid var(--slds-g-color-border-1);
|
|
546
|
+
border-radius: var(--slds-g-radius-border-1);
|
|
547
|
+
box-shadow: var(--slds-g-shadow-1);
|
|
548
|
+
|
|
549
|
+
/* Typography */
|
|
550
|
+
font-family: var(--slds-g-font-family-base);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.slds-card-title {
|
|
554
|
+
font-size: 1.125rem; /* 18px - use rem values */
|
|
555
|
+
font-weight: var(--slds-g-font-weight-7);
|
|
556
|
+
line-height: var(--slds-g-font-lineheight-2);
|
|
557
|
+
color: var(--slds-g-color-on-surface-3); /* High emphasis */
|
|
558
|
+
margin-bottom: var(--slds-g-spacing-2);
|
|
559
|
+
}
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
### Input Field
|
|
565
|
+
|
|
566
|
+
```css
|
|
567
|
+
.slds-input {
|
|
568
|
+
/* Background & Text */
|
|
569
|
+
background: var(--slds-g-color-surface-container-1);
|
|
570
|
+
color: var(--slds-g-color-on-surface-2);
|
|
571
|
+
|
|
572
|
+
/* Border */
|
|
573
|
+
border: 1px solid var(--slds-g-color-border-1);
|
|
574
|
+
border-radius: var(--slds-g-radius-border-1);
|
|
575
|
+
|
|
576
|
+
/* Spacing */
|
|
577
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-3);
|
|
578
|
+
|
|
579
|
+
/* Typography */
|
|
580
|
+
font-family: var(--slds-g-font-family-base);
|
|
581
|
+
font-size: var(--slds-g-font-size-base);
|
|
582
|
+
font-weight: var(--slds-g-font-weight-4);
|
|
583
|
+
line-height: var(--slds-g-font-lineheight-3);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.slds-input:focus {
|
|
587
|
+
/* Focus state using accent colors */
|
|
588
|
+
border-color: var(--slds-g-color-accent-1);
|
|
589
|
+
outline: none;
|
|
590
|
+
box-shadow: 0 0 0 2px var(--slds-g-color-accent-container-1);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.slds-input:disabled {
|
|
594
|
+
background: var(--slds-g-color-disabled-container-1);
|
|
595
|
+
color: var(--slds-g-color-on-disabled-1);
|
|
596
|
+
cursor: not-allowed;
|
|
597
|
+
}
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
---
|
|
601
|
+
|
|
602
|
+
### Alert/Notification
|
|
603
|
+
|
|
604
|
+
```css
|
|
605
|
+
.slds-alert-error {
|
|
606
|
+
background: var(--slds-g-color-error-container-1);
|
|
607
|
+
color: var(--slds-g-color-on-error-1);
|
|
608
|
+
border-left: 4px solid var(--slds-g-color-error-1);
|
|
609
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4);
|
|
610
|
+
border-radius: var(--slds-g-radius-border-1);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
.slds-alert-success {
|
|
614
|
+
background: var(--slds-g-color-success-container-1);
|
|
615
|
+
color: var(--slds-g-color-on-success-1);
|
|
616
|
+
border-left: 4px solid var(--slds-g-color-success-1);
|
|
617
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4);
|
|
618
|
+
}
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
---
|
|
622
|
+
|
|
623
|
+
## Migration Patterns: Converting Hard-Coded CSS to Hooks
|
|
624
|
+
|
|
625
|
+
### Converting Legacy CSS to SLDS Hooks
|
|
626
|
+
|
|
627
|
+
**Before: Hard-Coded Values**
|
|
628
|
+
|
|
629
|
+
```css
|
|
630
|
+
.old-button {
|
|
631
|
+
background: #0176d3;
|
|
632
|
+
color: #ffffff;
|
|
633
|
+
border: 1px solid #0176d3;
|
|
634
|
+
padding: 8px 16px;
|
|
635
|
+
border-radius: 4px;
|
|
636
|
+
font-weight: 500;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
.old-button:hover {
|
|
640
|
+
background: #014486;
|
|
641
|
+
}
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
**After: SLDS Hooks**
|
|
645
|
+
|
|
646
|
+
```css
|
|
647
|
+
.new-button {
|
|
648
|
+
/* Replace hex colors with semantic hooks */
|
|
649
|
+
background: var(--slds-g-color-accent-container-1);
|
|
650
|
+
color: var(--slds-g-color-on-accent-1);
|
|
651
|
+
border: 1px solid var(--slds-g-color-border-accent-1);
|
|
652
|
+
|
|
653
|
+
/* Replace px values with spacing hooks */
|
|
654
|
+
padding: var(--slds-g-spacing-2) var(--slds-g-spacing-4);
|
|
655
|
+
|
|
656
|
+
/* Replace px with radius hooks */
|
|
657
|
+
border-radius: var(--slds-g-radius-border-1);
|
|
658
|
+
|
|
659
|
+
/* Replace numeric weight with hook */
|
|
660
|
+
font-weight: var(--slds-g-font-weight-5);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
.new-button:hover {
|
|
664
|
+
background: var(--slds-g-color-accent-container-2);
|
|
665
|
+
color: var(--slds-g-color-on-accent-2);
|
|
666
|
+
border-color: var(--slds-g-color-border-accent-2);
|
|
667
|
+
}
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### Migration Steps:
|
|
671
|
+
|
|
672
|
+
1. **Replace colors** → Semantic hooks (accent, surface-container, error, success) or system colors
|
|
673
|
+
2. **Replace spacing** → Numbered spacing hooks (spacing-2, spacing-4)
|
|
674
|
+
3. **Replace typography** → Font hooks (font-weight-5, font-size-base or rem)
|
|
675
|
+
4. **Replace borders** → Border hooks (radius-border-1, border-1)
|
|
676
|
+
5. **Replace shadows** → Shadow hooks (shadow-1, shadow-2)
|
|
677
|
+
6. **Add state transitions** → Use numbered variants (1/2/3 for default/hover/active)
|
|
678
|
+
|
|
679
|
+
---
|
|
680
|
+
|
|
681
|
+
## Handling Edge Cases
|
|
682
|
+
|
|
683
|
+
### When to Use Palette Colors
|
|
684
|
+
|
|
685
|
+
Some scenarios require palette colors instead of semantic hooks:
|
|
686
|
+
|
|
687
|
+
#### 1. Data Visualization
|
|
688
|
+
|
|
689
|
+
Use palette colors for charts and data differentiation:
|
|
690
|
+
|
|
691
|
+
```css
|
|
692
|
+
/* Custom chart colors - palette allows precise color selection */
|
|
693
|
+
.chart-series-1 {
|
|
694
|
+
background: var(--slds-g-color-palette-blue-50);
|
|
695
|
+
}
|
|
696
|
+
.chart-series-2 {
|
|
697
|
+
background: var(--slds-g-color-palette-green-50);
|
|
698
|
+
}
|
|
699
|
+
.chart-series-3 {
|
|
700
|
+
background: var(--slds-g-color-palette-purple-50);
|
|
701
|
+
}
|
|
702
|
+
.chart-series-4 {
|
|
703
|
+
background: var(--slds-g-color-palette-orange-50);
|
|
704
|
+
}
|
|
705
|
+
.chart-series-5 {
|
|
706
|
+
background: var(--slds-g-color-palette-teal-50);
|
|
707
|
+
}
|
|
708
|
+
/* 50-point separation from neutral-100 background = WCAG AA compliant */
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
#### 2. Custom Gradients
|
|
712
|
+
|
|
713
|
+
Complex gradients benefit from palette precision:
|
|
714
|
+
|
|
715
|
+
```css
|
|
716
|
+
.gradient-background {
|
|
717
|
+
background: linear-gradient(
|
|
718
|
+
135deg,
|
|
719
|
+
var(--slds-g-color-palette-blue-40) 0%,
|
|
720
|
+
var(--slds-g-color-palette-purple-60) 100%
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
#### 3. Third-Party Library Integration
|
|
726
|
+
|
|
727
|
+
When external libraries require specific values, document the reason:
|
|
728
|
+
|
|
729
|
+
```css
|
|
730
|
+
/* Leaflet map requires specific z-index - library requirement */
|
|
731
|
+
.map-container {
|
|
732
|
+
z-index: 400;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/* Date picker overlay - library-specific styling */
|
|
736
|
+
.datepicker-overlay {
|
|
737
|
+
background: var(--slds-g-color-overlay-backdrop);
|
|
738
|
+
backdrop-filter: blur(4px);
|
|
739
|
+
}
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
**Rule:** Use semantic hooks first, palette colors for specific needs, and document any edge cases.
|
|
743
|
+
|
|
744
|
+
---
|
|
745
|
+
|
|
746
|
+
## Accessibility Compliance
|
|
747
|
+
|
|
748
|
+
SLDS styling hooks are designed with accessibility built-in:
|
|
749
|
+
|
|
750
|
+
### Color Contrast Rules
|
|
751
|
+
|
|
752
|
+
#### Text on Backgrounds (50-point separation)
|
|
753
|
+
|
|
754
|
+
```css
|
|
755
|
+
/* ✅ COMPLIANT - 50+ point separation */
|
|
756
|
+
.text-example-1 {
|
|
757
|
+
background: var(--slds-g-color-palette-neutral-95); /* Light */
|
|
758
|
+
color: var(--slds-g-color-palette-neutral-10); /* Dark */
|
|
759
|
+
/* 85-point separation = excellent contrast (>4.5:1) */
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.text-example-2 {
|
|
763
|
+
background: var(--slds-g-color-palette-blue-30); /* Dark */
|
|
764
|
+
color: var(--slds-g-color-palette-blue-85); /* Light */
|
|
765
|
+
/* 55-point separation = compliant (>4.5:1) */
|
|
766
|
+
}
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
#### UI Elements (40-point separation)
|
|
770
|
+
|
|
771
|
+
```css
|
|
772
|
+
/* ✅ COMPLIANT - 40+ point separation */
|
|
773
|
+
.border-example {
|
|
774
|
+
background: var(--slds-g-color-palette-neutral-100); /* White */
|
|
775
|
+
border: 1px solid var(--slds-g-color-palette-neutral-60); /* Mid gray */
|
|
776
|
+
/* 40-point separation = compliant for UI elements (>3:1) */
|
|
777
|
+
}
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
### Automatic Compliance with Semantic Colors
|
|
781
|
+
|
|
782
|
+
When using semantic accent colors, SLDS ensures contrast automatically:
|
|
783
|
+
|
|
784
|
+
```css
|
|
785
|
+
/* ✅ ALWAYS COMPLIANT when using matching pairs */
|
|
786
|
+
.accent-button {
|
|
787
|
+
background: var(--slds-g-color-accent-container-1);
|
|
788
|
+
color: var(--slds-g-color-on-accent-1); /* Pre-validated pairing */
|
|
789
|
+
}
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
### Testing Checklist
|
|
793
|
+
|
|
794
|
+
- ✅ Verify components work in both light and dark modes
|
|
795
|
+
- ✅ Test with high contrast settings enabled
|
|
796
|
+
- ✅ Ensure keyboard focus states use accent colors with proper contrast
|
|
797
|
+
- ✅ Validate color-only indicators have non-color alternatives (icons, text)
|
|
798
|
+
|
|
799
|
+
---
|
|
800
|
+
|
|
801
|
+
## Validation Checklist for Generated Code
|
|
802
|
+
|
|
803
|
+
Before finalizing generated CSS, verify:
|
|
804
|
+
|
|
805
|
+
### Hook Usage
|
|
806
|
+
|
|
807
|
+
- [ ] Semantic UI colors used where appropriate (surface-container, accent, error, success)
|
|
808
|
+
- [ ] All spacing hooks use numbered format (spacing-1 to spacing-12)
|
|
809
|
+
- [ ] All font hooks use numbered format (font-weight-1 to font-weight-7)
|
|
810
|
+
- [ ] Font sizes use `font-size-base` or rem values (no numbered font-size hooks exist)
|
|
811
|
+
- [ ] Palette colors follow point separation rules (50 for text, 40 for UI)
|
|
812
|
+
- [ ] No private hooks used (`--_slds-*`, `--slds-s-*`)
|
|
813
|
+
- [ ] No `@layer` syntax
|
|
814
|
+
- [ ] No reassignment of hook values
|
|
815
|
+
|
|
816
|
+
### Accessibility
|
|
817
|
+
|
|
818
|
+
- [ ] Text contrast verified (50-point separation or 4.5:1)
|
|
819
|
+
- [ ] UI element contrast verified (40-point separation or 3:1)
|
|
820
|
+
- [ ] Container colors paired with on-\* colors
|
|
821
|
+
- [ ] Focus states visible and use accent colors
|
|
822
|
+
|
|
823
|
+
### Code Quality
|
|
824
|
+
|
|
825
|
+
- [ ] State transitions defined (hover/active/focus/disabled)
|
|
826
|
+
- [ ] 85-5-10 color density maintained
|
|
827
|
+
- [ ] Semantic hooks preferred over palette colors
|
|
828
|
+
- [ ] Hook names verified with `{{EXPLORE_SLDS_STYLING_TOOL}}` if unsure
|
|
829
|
+
|
|
830
|
+
---
|
|
831
|
+
|
|
832
|
+
## Troubleshooting for Agents
|
|
833
|
+
|
|
834
|
+
### Problem: Component doesn't match SLDS visual style
|
|
835
|
+
|
|
836
|
+
**Solution:** Check hook usage:
|
|
837
|
+
|
|
838
|
+
- Replace `#0176d3` → `var(--slds-g-color-accent-1)`
|
|
839
|
+
- Replace `16px` → `var(--slds-g-spacing-4)`
|
|
840
|
+
- Replace `500` → `var(--slds-g-font-weight-5)`
|
|
841
|
+
|
|
842
|
+
### Problem: Hook name not working
|
|
843
|
+
|
|
844
|
+
**Solution:** Verify naming convention:
|
|
845
|
+
|
|
846
|
+
- Use numbered spacing: `spacing-4` NOT `spacing-medium`
|
|
847
|
+
- Use numbered fonts: `font-weight-5` NOT `font-weight-medium`
|
|
848
|
+
- Use `{{EXPLORE_SLDS_STYLING_TOOL}}` to verify exact hook name
|
|
849
|
+
|
|
850
|
+
### Problem: Colors have poor contrast
|
|
851
|
+
|
|
852
|
+
**Solution:**
|
|
853
|
+
|
|
854
|
+
- Use semantic hooks with paired on-colors
|
|
855
|
+
- For palette: 50-point separation for text, 40-point for UI elements
|
|
856
|
+
- Ensure accent containers paired with on-accent colors
|
|
857
|
+
|
|
858
|
+
### Problem: Spacing inconsistent
|
|
859
|
+
|
|
860
|
+
**Solution:**
|
|
861
|
+
|
|
862
|
+
- Use numbered spacing hooks: `spacing-2`, `spacing-4`
|
|
863
|
+
- Check spacing scale: 8px=spacing-2, 16px=spacing-4, 24px=spacing-5
|
|
864
|
+
|
|
865
|
+
### Problem: Font weight not applying
|
|
866
|
+
|
|
867
|
+
**Solution:**
|
|
868
|
+
|
|
869
|
+
- Use numbered hooks: `font-weight-5`, `font-weight-7`
|
|
870
|
+
- Common values: Regular=weight-4, Medium=weight-5, Bold=weight-7
|
|
871
|
+
|
|
872
|
+
---
|
|
873
|
+
|
|
874
|
+
## Summary for Coding Agents
|
|
875
|
+
|
|
876
|
+
When generating or optimizing SLDS components:
|
|
877
|
+
|
|
878
|
+
1. **Use semantic hooks first** — Prefer semantic UI colors (surface-container, accent, error, success) over system/palette
|
|
879
|
+
2. **Use numbered hooks** — spacing-4, font-weight-5 (NOT named like "medium")
|
|
880
|
+
3. **Font sizes** — Use `font-size-base` or rem values (no numbered font-size hooks exist)
|
|
881
|
+
4. **Follow the three-tier color system** — Semantic UI → System Colors → Expressive Palette
|
|
882
|
+
5. **Use numbered variants for states** — Progression (1/2/3 for default/hover/active where available)
|
|
883
|
+
6. **Follow contrast rules** — 50-point for text, 40-point for UI elements
|
|
884
|
+
7. **Pair containers with on-colors** — Use `on-surface-*`, `on-accent-*`, `on-error-*` for text/icons
|
|
885
|
+
8. **Use {{EXPLORE_SLDS_STYLING_TOOL}}** — Search for specific hooks by name, prefix, or category
|
|
886
|
+
9. **Test accessibility** — Verify contrast ratios and keyboard navigation
|
|
887
|
+
|
|
888
|
+
**The goal:** Build theme-aware, accessible components that adapt automatically to brand customizations, light/dark modes, and density settings.
|
|
889
|
+
|
|
890
|
+
---
|
|
891
|
+
|
|
892
|
+
**Document Version:** 3.0
|
|
893
|
+
**Last Updated:** November 2025
|
|
894
|
+
**SLDS Version:** 2.27+
|
|
895
|
+
**Total Global Hooks:** 473 (`--slds-g-*`)
|
|
896
|
+
|
|
897
|
+
**Major Categories:**
|
|
898
|
+
|
|
899
|
+
- Color hooks: ~375 (semantic, system, palette)
|
|
900
|
+
- Typography hooks: 61 (families, weights, sizes, line heights)
|
|
901
|
+
- Spacing hooks: 48 (numbered 1-12 + density variants)
|
|
902
|
+
- Shadow hooks: 39
|
|
903
|
+
- Sizing hooks: 32
|
|
904
|
+
- Radius hooks: 12
|
|
905
|
+
|
|
906
|
+
**Tool Reference:** Use `{{EXPLORE_SLDS_STYLING_TOOL}}` to search all hooks by name, prefix, or category
|