forcedotcom/sf-skills / skills/design-systems-slds-apply
design-systems-slds-apply
UnverifiedApply 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".
references/utilities/dark-mode.md
View on GitHub---
id: slds.guidance.utilities.dark-mode
title: Dark Mode Utilities
description: SLDS color scheme utility classes for controlling light, dark, and system color preferences
summary: "Utilities for controlling color scheme preferences. Forces light mode, dark mode, or respects system preference."
artifact_type: reference
domain: utilities
topic: dark-mode
content_format: structured
complexity: intermediate
audience: [implementer]
tasks: [implement]
refs:
- slds.guidance.utilities
- slds.guidance.overview.utilities
- slds.guidance.hooks.color
- slds.guidance.utilities.themes
tags: [utilities, dark-mode, color-scheme, theme]
keywords: [slds-color-scheme, dark mode, light mode, system preference]
---
# Dark Mode - Color Scheme Control
Utilities for controlling browser color scheme preferences. Uses CSS `color-scheme` property.
## Core Classes
| Class | Purpose |
|-------|---------|
| `slds-color-scheme--light` | Forces light mode only |
| `slds-color-scheme--dark` | Forces dark mode only |
| `slds-color-scheme--system` | Respects system preference |
## Common Patterns
```html
<!-- Force light mode on entire application -->
<body class="slds-color-scheme--light">
<!-- All content renders in light mode -->
</body>
<!-- Force dark mode on specific component -->
<div class="slds-card slds-color-scheme--dark">
<!-- Card content renders in dark mode -->
</div>
<!-- System preference for modal -->
<div class="slds-modal slds-color-scheme--system">
<!-- Modal adapts to user's OS preference -->
</div>
<!-- Mixed mode layout -->
<div class="slds-page">
<nav class="slds-color-scheme--dark">
<!-- Navigation always dark -->
</nav>
<main class="slds-color-scheme--system">
<!-- Content follows system preference -->
</main>
</div>
<!-- Override system preference locally -->
<body class="slds-color-scheme--system">
<div class="slds-box slds-color-scheme--light">
<!-- Box always light even if system is dark -->
</div>
</body>
```
## Implementation Details
### How It Works
- Uses CSS `color-scheme` property
- Applies to element and descendants
- When on `<body>`, affects entire document via `:has()` selector
- Browser automatically adjusts form controls, scrollbars, and system colors
### Property Values
| Class | CSS Property | Effect |
|-------|--------------|--------|
| `slds-color-scheme--light` | `color-scheme: only light` | Forces light colors |
| `slds-color-scheme--dark` | `color-scheme: only dark` | Forces dark colors |
| `slds-color-scheme--system` | `color-scheme: light dark` | Allows both schemes |
## Best Practices
✅ Apply `slds-color-scheme--system` to `<body>` for app-wide system preference support
✅ Use `slds-color-scheme--dark` for navigation bars and headers
✅ Use `slds-color-scheme--light` for data-heavy tables and forms
✅ Test both light and dark modes for all components
✅ Use modern double-dash syntax (`--`) for new implementations
❌ Don't use deprecated underscore syntax (`_`) in new code
❌ Don't mix color scheme classes on the same element
❌ Don't assume dark mode without testing contrast ratios
❌ Don't override user system preference without clear UI controls
## Deprecated Classes
The following BEM-style classes are deprecated. Use double-dash syntax instead:
| Deprecated | Use Instead |
|------------|-------------|
| `slds-color-scheme_light` | `slds-color-scheme--light` |
| `slds-color-scheme_dark` | `slds-color-scheme--dark` |
| `slds-color-scheme_system` | `slds-color-scheme--system` |Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |