ui5/webcomponents

styling

How to customize and style UI5 Web Components. Covers CSS shadow parts, CSS custom states, CSS variables, and tag-level styling. Use when the user asks about changing component appearance, colors, spacing, theming, or overriding styles.

First seen Mar 15, 2026

Installation

$ npx skills add ui5/webcomponents --skill styling

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from ui5/webcomponents.

npx skills add ui5/webcomponents

Browse all from ui5/webcomponents

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 1.8K
License LICENSES
Default branch main
Open issues 181
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 4,407 B
  • docs SUMMARY.md 251 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 209 installs

SKILL.md

Styling UI5 Web Components

UI5 Web Components use Shadow DOM for encapsulation. Styles are isolated — external CSS won't leak in, but customization requires specific techniques. There are five approaches, ordered from most recommended to least.

1. Styles on Tag Level

Some components (Title, Label, Tag, Button, Input, and others) are designed so that styles set directly on the custom element take effect.

ui5-input {
  width: 150px;
  color: yellow;
  background: purple;
}

This works for simpler components. For complex components with deep DOM structures, tag-level styling has no effect on internal elements.

Best practice: Always use tag-level styling for sizing properties (margin, padding, width, height) to avoid design inconsistencies.

2. CSS Shadow Parts

For complex components, specific internal elements are exposed as CSS shadow parts.

ui5-card-header::part(status) {
  color: red;
}

Important: Available shadow parts are listed in each component's API reference under the "Overview" section. Only documented parts are stable — do not rely on undocumented internal structure.

3. CSS Custom States

Components can expose custom states via the CSS custom state pseudo-class, allowing you to style based on internal component conditions.

ui5-toolbar-item:state(overflowed) {
  flex-direction: column;
}

Important: Available custom states are listed in each component's API reference under the "Overview" section.

4. Overriding CSS Variables

UI5 Web Components use SAP CSS variables (--sap*) for theming. You can override these on a per-component or per-scope basis.

ui5-button {
  --sapButton_TextColor: purple;
}

All global SAP CSS variables are defined in @sap-theming/theming-base-content. Overriding them changes the appearance of any component that uses them.

Best practice: For broad theme changes, prefer using the UI Theme Designer to ensure consistency. Use direct CSS variable overrides only for targeted, scoped customizations.

5. Custom CSS via addCustomCSS (Last Resort)

If none of the above work, custom CSS can be injected directly into a component's shadow DOM using the addCustomCSS API. It targets internal DOM structure that may change between versions. Only use it when CSS variables, tag-level styles, and shadow parts cannot achieve the desired result.

Before writing custom CSS:

  1. Find the component's template and existing styles in node_modules
  2. Optionally, inspect the component's shadow DOM in DevTools to understand the internal structure
  3. Target the minimal set of selectors needed

Custom CSS must be registered before any instances of the component are created:

import { addCustomCSS } from "@ui5/webcomponents-base/dist/Theming.js";

addCustomCSS("ui5-select", `
  .ui5-select-root {
    background-color: red;
  }
`);

The first argument is the component's tag name, the second is a CSS string that gets injected into every instance's shadow DOM.

What NOT to Do

  • Don't pierce shadow DOM with deprecated >>> or /deep/ selectors — they don't work.
  • Don't rely on internal DOM structure — it can change between versions. Only use documented shadow parts.
  • Don't use !important on SAP variables — scope your overrides instead.
  • Don't override raw colors when a SAP CSS variable exists — use the variable to maintain theme consistency.

Quick Decision Guide

Goal Technique
Change width, margin, padding Tag-level styles
Restyle a specific internal element ::part(name)
Style based on component state :state(name)
Change colors/fonts globally Override --sap* CSS variables
Full theme customization UI Theme Designer
Override internal shadow DOM styles addCustomCSS (last resort)