styling

Customize UI5 Web Components using CSS Shadow Parts, states, and variables.

1.8k|284|Updated Jan 24, 2019
One-click install
npx skills add https://github.com/UI5/webcomponents --skill styling-ui5
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: styling
Source: https://github.com/UI5/webcomponents/tree/main/skills/styling
Command: npx skills add https://github.com/UI5/webcomponents --skill styling-ui5

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the challenge of customizing the appearance of UI5 Web Components, which use Shadow DOM for encapsulation, by providing clear methods for style modification.

Core Features & Use Cases

  • Tag-Level Styling: Apply styles directly to component tags for simple adjustments like sizing.
  • CSS Shadow Parts: Target specific internal elements exposed by components for detailed styling.
  • CSS Custom States: Style components based on their internal conditions using :state() pseudo-class.
  • CSS Variable Overrides: Modify theming variables (--sap*) for broad or targeted style changes.
  • addCustomCSS API: Inject custom CSS directly into the Shadow DOM as a last resort.
  • Use Case: You need to change the background color of all ui5-button components to a specific shade of blue and ensure they have a minimum width.

Quick Start

Use tag-level styling to set the width and background color of ui5-input elements.

Frequently Asked Questions about styling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I customize UI5 Web Components when Shadow DOM prevents standard CSS overrides?

Customize UI5 Web Components by leveraging Shadow DOM穿透 techniques like CSS Shadow Parts, CSS Custom States, CSS variables, and tag-level styling to bypass encapsulation restrictions. These methods allow targeted visual modifications without breaking component internals.

What is the best way to change the background color of all ui5-button components?

Change the background color of all ui5-button components by overriding `--sap*` CSS variables for broad theming adjustments, or apply tag-level styling for simple, direct visual modifications like setting specific brand colors and minimum widths.

Can I style specific internal elements of a UI5 Web Component using CSS?

Style specific internal elements of a UI5 Web Component by targeting exposed CSS Shadow Parts. This allows detailed styling of internal DOM structures while maintaining the encapsulation provided by the Shadow DOM.

Do I need to understand CSS specificity to apply state-based visual feedback in enterprise web applications?

Understanding CSS specificity is required to apply state-based visual feedback effectively. Use the `:state()` pseudo-class with CSS Custom States to style components based on their internal conditions within enterprise web applications.

When should I use the addCustomCSS API to inject styles into the Shadow DOM?

Use the `addCustomCSS` API to inject custom CSS directly into the Shadow DOM only as a last resort. It handles edge cases where standard CSS variables, tag-level styling, or Shadow Parts cannot achieve the required layout adjustments.