Skip to content

forcedotcom/sf-skills / skills/design-systems-slds2-migrate

design-systems-slds2-migrate

Verified

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".

references/rule-no-slds-class-overrides.md

View on GitHub
# Rule: No SLDS Class Overrides

**Rule ID:** `slds/no-slds-class-overrides`
**Severity:** Warning
**Scope:** Detects CSS selectors that directly target `.slds-*` classes.

---

## What the Linter Does

The linter detects CSS classes that directly override SLDS classes and reports them as **warnings**. It does **not** auto-fix — all changes require manual work in both CSS and HTML.

```text
  1:1  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
```

**Manual steps required:**
1. Rename `.slds-*` selectors in CSS to `{componentName}-{sldsElementPart}`
2. Add the new component class to markup (`.html` for LWC, `.cmp` for Aura) **alongside** the original SLDS class
3. Never remove the original SLDS class from markup

---

## Naming Convention

**Format:** `{componentName}-{sldsElementPart}` (camelCase component name)

| SLDS Class | Component: `userProfile` | Result |
|---|---|---|
| `.slds-button` | `userProfile` | `userProfile-button` |
| `.slds-card` | `userProfile` | `userProfile-card` |
| `.slds-modal__content` | `userProfile` | `userProfile-modal__content` |
| `.slds-button_brand` | `userProfile` | `userProfile-button_brand` |

---

## Common Patterns

### Pattern 1: Simple Selector

```css
/* Before CSS */
.slds-button { border-radius: 8px; }

/* After CSS */
.myComponent-button { border-radius: 8px; }
```

```html
<!-- After HTML (manual) -->
<button class="slds-button myComponent-button">Click</button>
```

### Pattern 2: Descendant Selector

```css
/* Before CSS */
.slds-card .slds-button { margin-top: 1rem; }

/* After CSS */
.myComponent-card .myComponent-button { margin-top: 1rem; }
```

```html
<!-- After HTML (manual) — each SLDS class gets a component class -->
<div class="slds-card myComponent-card">
  <button class="slds-button myComponent-button">Click</button>
</div>
```

### Pattern 3: Multi-Class Selector

```css
/* Before CSS */
.slds-card.slds-p-around_medium { border: 1px solid blue; }

/* After CSS */
.myComponent-card.myComponent-p-around_medium { border: 1px solid blue; }
```

```html
<!-- After HTML (manual) -->
<div class="slds-card slds-p-around_medium myComponent-card myComponent-p-around_medium">
```

---

## Core Rules

1. **Never remove SLDS classes** from markup (`.html` or `.cmp`) — only ADD component classes alongside them
2. **One-to-one mapping** — each SLDS class in a CSS selector gets exactly one component class
3. **CamelCase component name** — `sampleComponent-button`, not `sample-component-button`
4. **Preserve SLDS element names** — `.slds-button` becomes `componentName-button` (strip `slds-` prefix, keep the rest)

---

## Interaction with Other Rules

If the overridden CSS properties include hardcoded colors, you must also apply `rule-no-hardcoded-values.md` to those properties:

```css
/* Before */
.slds-icon-action-check { background: #4bca81; }

/* After — both rules applied */
.myComponent-icon-action-check { background: var(--slds-g-color-success-base-70, #4bca81); }
```

---

---

## Validation Checklist

**CSS:**
- [ ] All `.slds-*` overrides reported by the linter are addressed
- [ ] Component name is camelCase
- [ ] SLDS element names preserved after prefix

**Markup (`.html` for LWC, `.cmp` for Aura):**
- [ ] Original SLDS classes preserved
- [ ] Component classes added alongside SLDS classes
- [ ] Every element in CSS selector chain updated in markup
- [ ] One component class per SLDS class
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall