Loading...
Loading...
Migrate Lightning Web Components from SLDS 1 to SLDS 2 by running the SLDS linter and fixing violations. Use this skill whenever users mention SLDS 2, SLDS uplift, linter violations, LWC token migration, class overrides, hardcoded CSS values that need SLDS hook replacement, or styling hook selection. Covers all styling hook categories — color, spacing, sizing, typography, borders, radius, and shadows. Also use when users mention no-hardcoded-values, no-slds-class-overrides, lwc-to-slds-hooks, no-deprecated-tokens-slds1, or ask about SLDS component migration — even if they don't explicitly say "uplift" or "migration".
npx skill4agent add forcedotcom/afv-library uplifting-components-to-slds2| Category | Hook Prefix | What It Replaces |
|---|---|---|
| Color | | Hardcoded colors, |
| Spacing | | Hardcoded margins, padding, gaps |
| Sizing | | Hardcoded widths, heights, dimensions |
| Typography | | Hardcoded font sizes, weights, line heights |
| Border/Radius | | Hardcoded border-radius, border-width |
| Shadow | | Hardcoded box-shadow values |
.html.cmp1. Run SLDS linter with auto-fix -> Handles simple violations automatically
2. Review linter output -> Identify remaining manual fixes needed
3. Fix by violation type -> Use per-rule reference guides
4. Choose the right hook -> Context-first, inspect HTML before deciding
5. Validate -> Re-run linter and confirm zero errorsnpx @salesforce-ux/slds-linter@latest lint --fix ..html.cmpcomponentName.css
15:3 warning Overriding slds-button isn't supported. To differentiate SLDS and
custom classes, create a CSS class in your namespace.
Examples: myapp-input, myapp-button. slds/no-slds-class-overrides
23:5 error The '--lwc-colorBackground' design token is deprecated. Replace it with
the SLDS 2 styling hook and set the fallback to '--lwc-colorBackground'.
1. --slds-g-color-surface-2
2. --slds-g-color-surface-container-2 slds/lwc-token-to-slds-hook
30:8 warning Consider replacing the #ffffff static value with an SLDS 2 styling hook
that has a similar value:
1. --slds-g-color-surface-1
2. --slds-g-color-surface-container-1
3. --slds-g-color-on-accent-1
4. --slds-g-color-on-accent-2
5. --slds-g-color-on-accent-3 slds/no-hardcoded-values-slds2
31:15 error Consider removing t(fontSizeMedium) or replacing it with
var(--slds-g-font-size-base, var(--lwc-fontSizeMedium, 0.8125rem)).
Set the fallback to t(fontSizeMedium). For more info, see
Styling Hooks on lightningdesignsystem.com. slds/no-deprecated-tokens-slds1100%auto0inheritnone| Violation Rule | Quick Summary | Reference |
|---|---|---|
| Replace hardcoded values with SLDS hook + original as fallback | rule-no-hardcoded-values.md |
| Replace | rule-lwc-token-to-slds-hook.md |
| Create component-prefixed class, add to markup alongside SLDS class | rule-no-slds-class-overrides.md |
| Replace legacy | rule-no-deprecated-tokens-slds1.md |
var(--slds-g-hook, originalValue)originalValue.html.cmp.slds-*{componentName}-{sldsElementPart}/* Before */ .slds-button { border-radius: 8px; }
/* After */ .myComponent-button { border-radius: 8px; }<!-- Markup: both classes --> <button class="slds-button myComponent-button">Click</button>1. npx @salesforce-ux/slds-linter@latest lint .
2. Review errors -> fix by type (Step 3)
3. Re-run linter
4. Repeat until output shows: 0 errors.slds-*var(--lwc-*)spacing-mediumfont-weight-boldrgba()color-mix()/* Before */
border-color: rgba(186, 5, 23, 0.7);
/* After — use oklab color space for perceptual consistency */
border-color: color-mix(in oklab, var(--slds-g-color-palette-red-40, rgb(181,54,45)), transparent 30%);(100 - X)%color-mixtransparent 30%transparent 50%rgb()rgba()color-mixt('calc(...)')calc()/* Before — Aura t() with calc */
height: t('calc(' + lineHeightButton + ' + 2px)');
/* After — if calc is still needed */
height: calc(var(--lwc-lineHeightButton) + 2px);
/* After — if calc was unnecessary, simplify */
height: var(--lwc-lineHeightButton);calc()--lwc-*/* Before */
padding: calc(var(--lwc-spacingMedium) + 4px);
/* After */
padding: calc(var(--slds-g-spacing-4, var(--lwc-spacingMedium)) + 4px);calc()100%50%200px1.5auto0inheritnoneflex: 1-1spacing-mediumfont-weight-boldradius-large| Issue | Solution |
|---|---|
| Linter suggests 2+ color hook options | Inspect HTML context to determine element's semantic role — see color-hooks-decision-guide.md |
| Visual appearance changed after migration | Verify fallback values match originals; check surface vs container family |
| No hook available for hardcoded value | Leave unchanged; do not invent custom hook names |
Linter says "Remove the static value" for | Leave unchanged — these are layout values. Removing them breaks rendering. |
| CSS class naming errors | Use exact camelCase component name: |
| Spacing/sizing doesn't match | Check value-to-hook mapping in non-color-hooks-decision-guide.md; verify spacing vs sizing usage |
Named hook not working (e.g., | Named hooks don't exist — use numbered scale: |
| Component looks different in compact density | Use density-aware hooks ( |
--lwc-*t()token()