Styling
March 31, 2026 · View on GitHub
Prefer design tokens and custom CSS properties over hardcoded values (colors, spacing, font sizes, etc.). This keeps styles consistent across themes and modes.
Rules
- Root elements must not have outer margins — spacing is managed by parent components
- No descendant combinators (
.a .bwith a space) — breaks CSS scoping because it applies to all.class-belements at unlimited depth - Wrap animations in the
with-motionmixin to ensure motion can be toggled on and off - Use logical properties only — no
left/right/top/bottom/width/heightin CSS. Useinline-start/inline-end/block-start/block-end/inline-size/block-sizeinstead. Required for RTL support.
References:
- Mappings for sizing
- Mappings for margins, borders, and padding
- Mappings for floating and positioning
RTL Support
For cases that need direction-aware logic beyond CSS logical properties:
- In SCSS, use the
with-directionmixin - In TypeScript,
@cloudscape-design/component-toolkit/internalprovides direction detection and logical geometry helpers that replace physical DOM properties