Skip to content
design-systems-slds-apply logo

Applying SLDS

design-systems-slds-apply

Apply SLDS-compliant UI using the correct blueprints, styling hooks, utility classes, and icons. Use when building any UI that needs SLDS, choosing between Lightning Base Components and SLDS Blueprints, applying styling hooks for theming, using utility classes for layout and spacing, or selecting icons. Triggers include "build a modal", "create a form", "data table", "SLDS styling", "style with hooks", "add an icon".

forcedotcom/sf-skills5.8Kinstalls1.1Kstars

SKILL.md

Full skill instructions

Applying SLDS

The Salesforce Lightning Design System (SLDS) is a CSS framework with thousands of artifacts. This skill teaches agents how to find and correctly use them.

Version: This skill targets SLDS v2. Legacy --lwc-* tokens and slds-*--modifier syntax are deprecated.

Audit scope: The companion design-systems-slds-validate skill analyzer only scans .css, .html, and .js files. Use it directly for LWC and similar HTML/​CSS/​JS components; treat it as a partial signal for JSX/​TSX or other framework-specific template formats and supplement with manual review.

What is SLDS?

ArtifactCountDescription
Lightning Base Components~70Pre-built LWC components (LWC only)
SLDS Blueprints85CSS/​HTML patterns for any framework
Styling Hooks523CSS custom properties (--slds-g-*) for theming
Utility Classes1,147Rapid styling classes for spacing, layout, visibility
Icons1,732SVG icons across 5 categories

Scope

This skill covers:

  • Which blueprint to use for a given UI pattern
  • How to style with hooks (color, spacing, typography, shadows, borders)
  • Which utility classes to use for layout, spacing, visibility
  • Which icon to use and from which category
  • SLDS naming conventions, class structure, hook syntax

This skill includes basic accessibility reminders (icon alt text, focus outlines, color-not-sole-indicator) in the validation checklists. Full WCAG compliance requires a dedicated accessibility review.

This skill does NOT cover (use companion skills):

  • Design decisions -- visual hierarchy, composition, interaction patterns
  • LWC mechanics -- component structure, @wire, @api, lifecycle, events (not yet available)
  • Full accessibility -- WCAG conformance, ARIA patterns, keyboard navigation, focus management, contrast ratios (not yet available)

Component Selection Hierarchy

Always follow this order:

1. Lightning Base Components (LWC only)    ← Check first
2. SLDS Blueprints (any framework)         ← Use exact SLDS classes
3. Custom with Styling Hooks               ← Use var(--slds-g-*)
4. Custom CSS (last resort)                ← Still use hooks for values

If building in LWC, check for an LBC first: Lightning Component Library

If no LBC exists (or not using LWC), select an SLDS Blueprint. See references/​component-selection.md.


Core Rules

Do

  • Follow the selection hierarchy: LBC > Blueprint > Hooks > Custom CSS
  • Use var(--slds-g-*, fallback) for all themeable values
  • Create custom classes (my-*, c-*) instead of overriding .slds-*
  • Verify every hook, class, and utility exists before using it — run the search scripts; never assume an artifact exists based on naming patterns (see Verify Before You Use)
  • Pair surface colors with on-surface colors for text
  • Provide alternative-text on every <lightning-icon>

Don't

  • Hard-code colors, spacing, or typography values
  • Override .slds-* classes directly
  • Use deprecated --lwc-* tokens as primary values
  • Use --slds-s-* (shared) hooks -- they are private/​internal
  • Reassign hook values -- only reference them with var()
  • Use color alone to convey meaning
  • Invent hook names by interpolating patterns from other families (see Naming Traps below)

Hook Naming Traps

SLDS hook families do NOT all follow the same naming pattern. Agents frequently invent hooks that don't exist by assuming {prefix}-{number} works universally. Always verify a hook exists via the bundled search-hooks.cjs script or assets/​hooks-index.json before using it.

Trap 1: Font size hooks are NOT numbered

Wrong (does not exist)CorrectNotes
--slds-g-font-size-3--slds-g-font-scale-1Font sizes use font-scale-*, not font-size-*
--slds-g-font-size-4--slds-g-font-scale-2Only --slds-g-font-size-base exists (base size)
--slds-g-font-size-8--slds-g-font-scale-6Scale goes: neg-4 through 10

Rule: For font sizes, use --slds-g-font-size-base (the one base size) or --slds-g-font-scale-* (the numbered scale). Never --slds-g-font-size-N.

Trap 2: Color hooks always require a number

Wrong (does not exist)CorrectNotes
--slds-g-color-on-surface--slds-g-color-on-surface-2All color hooks need a number
--slds-g-color-on-accent--slds-g-color-on-accent-1Pick 1/​2/​3 by emphasis level
--slds-g-color-surface--slds-g-color-surface-1No unnumbered base form

Rule: Every --slds-g-color-* hook ends in a number. Pick by emphasis: -1 (low), -2 (medium), -3 (high).

Trap 3: Not all values have hook equivalents

Some CSS values (e.g., min-width: 7rem for label alignment) have no SLDS hook. This is acceptable:

.c-field-label {
  /​* No SLDS hook exists for this width; intentional custom value */
  min-width: 7rem;
}

Rule: When no hook exists, use the value directly with a comment explaining it's intentional. Prefer SLDS grid utilities (slds-size_*) as alternatives to hardcoded widths where possible.


Verify Before You Use

Rule: Never include an SLDS hook, utility class, blueprint class, or icon in generated code without first confirming it exists in the metadata. Guessing based on naming patterns is the primary source of invented artifacts.

Run the appropriate search command before emitting any SLDS artifact:

ArtifactVerification commandSource of truth
Styling hook (--slds-g-*)node scripts/​search-hooks.cjs --prefix "<hook-name>"assets/​hooks-index.json
Utility class (slds-*)node scripts/​search-utilities.cjs --search "<class-name>"assets/​utilities-index.json
Blueprint / CSS classnode scripts/​search-blueprints.cjs --search "<pattern>" then read the YAMLassets/​blueprints/​components/​*.yaml
Iconnode scripts/​search-icons.cjs --query "<description>"assets/​icon-metadata.json

If the search returns no match: do not use the artifact. Find an alternative from the search results or build custom with verified hooks.


Naming Conventions

Use a consistent prefix for custom classes to avoid collision with SLDS:

PatternUse CaseExample
my-*General custom stylingmy-card-header
c-*LWC component-specificc-accountList-row
[namespace]-*Package/​app namespaceacme-dashboard-widget

Avoid: generic names (container, wrapper), SLDS-like names (custom-slds-button), BEM on SLDS classes (slds-card__custom-header).

Custom hook namespacing:

:root {
  --my-app-primary: var(--slds-g-color-accent-1);
  --my-app-card-padding: var(--slds-g-spacing-4);
}

Knowledge Map

This skill bundles comprehensive SLDS knowledge. Read files as needed -- don't read everything upfront.

Decision Guides (start here for each task)

FileRead when
references/​component-selection.mdChoosing a component or blueprint
references/​styling-decision-guide.mdApplying colors, spacing, typography, shadows
references/​icons-decision-guide.mdSelecting or implementing an icon
references/​utilities-quick-ref.mdUsing utility classes for layout/​spacing

Search Scripts (find specific artifacts)

ScriptWhat it searchesExample
scripts/​search-blueprints.cjs85 blueprint YAMLs--search "dialog"
scripts/​search-hooks.cjs523 styling hooks--prefix "--slds-g-color-accent-"
scripts/​search-icons.cjs1,732 icons with synonyms--query "save button"
scripts/​search-utilities.cjs1,147 utility classes--category "grid"

Deep-Dive Guidance (read for detailed rules)

FolderContentIndex
references/​overviews/Foundational concepts (color, spacing, typography, etc.)references/​README.md
references/​styling-hooks/Hook categories with detailed usagereferences/​README.md
references/​utilities/27 utility class categoriesreferences/​README.md
references/​slds-development-guide.mdFull SLDS development guide--

Raw Metadata (structured data for lookup)

Do not read metadata JSON files directly — they are too large for agent context (hooks-index.json is 6,000+ lines; icon-metadata.json is 38,000+ lines). Use the search scripts above to query them.

FileContentLines
assets/​blueprints/​components/​*.yaml85 blueprint specs (classes, variants, a11y, HTML)~50-200 each
assets/​hooks-index.json523 hooks with values and CSS properties~6,300
assets/​icon-metadata.json1,732 icons with synonyms for search~38,500
assets/​utilities-index.json1,147 utility classes with CSS rules~6,900

Authoring Workflow

Phase 1: Understand the Need

Identify:

  • What UI pattern is needed? (form, table, modal, card, etc.)
  • What framework? (LWC, React, Vue, Angular, vanilla)
  • What data will it display?
  • What states does it need? (loading, empty, error, success)

Phase 2: Select the Artifact

  1. If LWC: Check the Lightning Component Library for an LBC
  2. Search blueprints: node scripts/​search-blueprints.cjs --search "<pattern>"
  3. Read the blueprint YAML: assets/​blueprints/​components/<name>.yaml for exact classes, modifiers, states, and accessibility requirements
  4. No match? Build custom with hooks (see Phase 3)

Details: references/​component-selection.md

Phase 3: Apply Styling

  1. Read: references/​styling-decision-guide.md
  2. Colors: Classify role (surface, accent, feedback, border) then pick hook
  3. Spacing: Use utility classes (slds-p-*, slds-m-*) or hooks (--slds-g-spacing-*)
  4. Layout: Use grid utilities (slds-grid, slds-col, slds-size_*)
  5. Custom CSS: Use var(--slds-g-*, fallback), custom class prefixes only

Phase 4: Add Icons

  1. Read: references/​icons-decision-guide.md
  2. Search: node scripts/​search-icons.cjs --query "<description>"
  3. In LWC: Use <lightning-icon> with alternative-text
  4. In non-LWC: Use SVG with slds-icon classes and slds-assistive-text

Phase 5: Validate (Mandatory — Do Not Skip)

Step 1: Run the SLDS linter. This is required. Zero violations is the target.

npx @salesforce-ux/​slds-linter@latest lint <component-path>

The linter catches hardcoded values, class overrides, and deprecated tokens. Fix all violations before proceeding. Do not rationalize violations as acceptable.

Step 2: Verify no invented hooks. Confirm every --slds-g-* hook in the output exists in assets/​hooks-index.json. Cross-reference against the T051 check in checklists.md.

Step 3: Run through checklists.md for the checks the linter cannot automate:

  • All var(--slds-g-*) have fallback values (T002)
  • Surface/​accent/​feedback color hooks are properly paired (T010–T013)
  • Spacing uses hooks or utility classes — no magic px values (T020–T021)
  • Font sizes use --slds-g-font-scale-*, not --slds-g-font-size-N (T031)
  • All icons have accessibility text (A004)
  • Custom classes use my-* or c-* prefix (Q010)

Step 4 (optional): Run the full quality audit using the design-systems-slds-validate skill for a scored report before code review or deployment. Use it directly for LWC / HTML-CSS-JS components; for JSX/​TSX outputs, treat the result as partial coverage only. Target a B grade (≥80) or higher before marking work complete.


Quick Reference

Common Hook Patterns

/​* Surface + text pairing (always use numbered variants) */
background: var(--slds-g-color-surface-1, #ffffff);
color: var(--slds-g-color-on-surface-2, #181818);

/​* Standard padding */
padding: var(--slds-g-spacing-4, 1rem);

/​* Card-like container */
border-radius: var(--slds-g-radius-border-2, 0.25rem);
box-shadow: var(--slds-g-shadow-1, 0 2px 4px rgba(0,0,0,0.1));

/​* Accent for primary actions */
background: var(--slds-g-color-accent-1, #0176d3);
color: var(--slds-g-color-on-accent-1, #ffffff);

/​* Typography -- use font-scale-*, NOT font-size-* (only font-size-base exists) */
font-size: var(--slds-g-font-scale-2, 0.875rem);

Common Utility Patterns

<!-- Responsive grid -->
<div class="slds-grid slds-wrap slds-gutters">
  <div class="slds-col slds-size_1-of-1 slds-medium-size_1-of-2">...</​div>
</​div>

<!-- Spacing -->
<div class="slds-p-around_medium slds-m-bottom_small">...</​div>

<!-- Truncation -->
<p class="slds-truncate" title="Full text here">Full text here</​p>

Examples

See examples.md for worked examples demonstrating the full workflow from intent to SLDS artifact selection.

Validation

See checklists.md for validation checklists aligned with the design-systems-slds-validate skill.

Resources

More skills from forcedotcom

platform-apex-logs-debug logo
forcedotcom/sf-skills

platform-apex-logs-debug

Salesforce debug log analysis and troubleshooting with 100-point scoring. TRIGGER when: user analyzes debug logs, hits governor limits, reads stack traces, or touches .log files from Salesforce orgs. DO NOT TRIGGER when: running Apex tests (use platform-apex-test-run), generating or fixing Apex code (use platform-apex-generate), or Agentforce session tracing (use agentforce-observe).

1.1K 6.4K
View
platform-soql-query logo
forcedotcom/sf-skills

platform-soql-query

SOQL query generation, optimization, and analysis with 100-point scoring. Use this skill when the user needs SOQL/SOSL authoring or optimization: natural-language-to-query generation, relationship queries, aggregates, query-plan analysis, and performance or safety improvements for Salesforce queries. TRIGGER when: user writes, optimizes, or debugs SOQL/SOSL queries, touches .soql files, or asks about relationship queries, aggregates, or query performance. DO NOT TRIGGER when: bulk data operations (use platform-data-manage), Apex DML logic (use platform-apex-generate), or report/dashboard queries.

1.1K 6.3K
View
platform-metadata-deploy logo
forcedotcom/sf-skills

platform-metadata-deploy

Salesforce DevOps automation using sf CLI v2. TRIGGER when: user deploys metadata, creates/manages scratch orgs or sandboxes, sets up CI/CD pipelines, or troubleshoots deployment errors with sf project deploy. DO NOT TRIGGER when: writing Apex code (use platform-apex-generate), building LWC components (use experience-lwc-generate), creating metadata definitions (use platform-custom-object-generate or platform-custom-field-generate), or querying org data (use platform-data-manage).

1.1K 6.3K
View
platform-metadata-retrieve logo
forcedotcom/sf-skills

platform-metadata-retrieve

ALWAYS USE THIS SKILL to retrieve metadata from an org to your local project using the sf project retrieve start command. Supports multiple retrieval modes: retrieve all remote changes, retrieve by source directory, retrieve by metadata type with wildcards, retrieve by manifest (package.xml), or retrieve by package name. Use when the user asks to retrieve, pull, sync, or download metadata, Apex classes, custom objects, or org changes. Supports source format (default) or metadata format (ZIP). DO NOT TRIGGER for deploying metadata (use platform-metadata-deploy skill), listing metadata, or generating package.xml. NEVER use MCP tools - always use this skill and the Bash tool with sf project retrieve start.

1.1K 6.3K
View
platform-custom-field-generate logo
forcedotcom/sf-skills

platform-custom-field-generate

Use this skill when users need to create, generate, or validate Salesforce Custom Field metadata. Trigger when users mention custom fields, field types, Roll-up Summary fields, Master-Detail relationships, Lookup relationships, formula fields, picklists, dependent (controlling) picklists, referencing a value set from a field, or scoping/limiting picklist values for a specific record type. Also use when users encounter field deployment errors, especially around Roll-up Summary format, Master-Detail constraints, formula issues, or a record type that won't deploy without a business process. Use this skill for custom field metadata work, field generation, and field troubleshooting. DO NOT TRIGGER for creating or customizing the value set itself — defining a new GlobalValueSet, or modifying a StandardValueSet catalog like Industry or Lead Source — use platform-value-set-generate instead; this skill covers the field that references a value set, not the value set definition.

1.1K 6.2K
View

Generates correct, deployable Salesforce permission set metadata (PermissionSet XML) with object, field, user, and app permissions. Use this skill when creating or editing permission set metadata, object permissions, field-level security (FLS), tab visibility, or deploying permission sets.

1.1K 6.1K
View
dx-code-analyzer-run logo
forcedotcom/sf-skills

dx-code-analyzer-run

Run Salesforce Code Analyzer to scan code for security, performance, best practice, and code style violations. Supports all engines (PMD, ESLint, CPD, RetireJS, Flow, SFGE, ApexGuru), targets (files, folders, git diff), categories, and severities. Also handles post-scan exploration: filtering results by engine/severity/category/file, and explaining what rules mean. TRIGGER when: user says 'scan my code', 'check security issues', 'run PMD/ESLint', 'find duplicates', 'analyze Flows', 'check vulnerable libraries', 'AppExchange review', 'lint my LWC', 'static analysis', 'code quality', 'show security violations', 'what is this rule', 'explain ApexCRUDViolation', 'filter results', or mentions engines/file types (.cls, .trigger, .js, .flow-meta.xml). Use this skill for scanning, exploring results, and listing rules. DO NOT TRIGGER when: user asks only about installation/configuration (use dx-code-analyzer-configure), or wants to create a custom rule (use dx-code-analyzer-custom-rule-create).

1.1K 6.1K
View
automation-flow-generate logo
forcedotcom/sf-skills

automation-flow-generate

Generate Salesforce Flows using the MCP tool execute_metadata_action. Use when the user asks to create, build, or generate a flow — including Screen, Autolaunched, Record-Triggered (before/after-save), Scheduled. Also trigger for flow-like requests such as "when a record is created", "trigger daily at", "send an email when", "update the field when", "automate", "workflow", or "flow XML/metadata". This is the only skill for Salesforce Flow generation.

1.1K 6K
View
platform-custom-object-generate logo
forcedotcom/sf-skills

platform-custom-object-generate

Use this skill when users need to create, generate, or validate Salesforce Custom Object metadata. Trigger when users mention custom objects, creating objects, object metadata, .object files, sharing models, name fields, or validation rules on objects. Also use when users say things like "create a custom object", "generate object metadata", "set up an object for...", or when they're troubleshooting object deployment errors especially around sharing models and Master-Detail relationships. Always use this skill for any custom object metadata work, including enriching and keeping the object's description current whenever its fields or validation rules change. Do NOT use this skill for non-Custom-Object metadata (Apex, Flows, LWC, Permission Sets, Custom Metadata Types) or for standard Salesforce objects.

1.1K 6K
View
platform-data-manage logo
forcedotcom/sf-skills

platform-data-manage

Salesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use platform-soql-query), Apex test execution (use platform-apex-test-run), or metadata deployment (use platform-metadata-deploy).

1.1K 5.9K
View
experience-lwc-generate logo
forcedotcom/sf-skills

experience-lwc-generate

Lightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use platform-apex-generate), Aura components, or Visualforce.

1.1K 5.9K
View

REQUIRED companion for Salesforce metadata generation — load this schema/API-context skill in the SAME turn as ANY metadata generation skill; if you load a generator, you ALSO load this. Use it whenever you create, generate, add, edit, or author metadata or a *-meta.xml file: custom object, custom field, formula field, picklist, lookup, master-detail, validation rule, permission set, profile, custom tab, lightning record page, flexipage, list view, custom application, flow, layout, record type, sharing rules, report, and 604 Metadata API types. It provides the authoritative schema, fields, field properties, required flags, allowed enum values, and XML structure so generated *-meta.xml deploys cleanly — skipping it causes hallucinated element names and deploy failures. Trigger on *-meta.xml, metadata schema, api context, 'Salesforce metadata', or 'sfdx project'. DO NOT use for SOQL, DML, runtime sObject access, or Tooling API records.

1.1K 5.8K
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View