update-component-styles
GitHub指导如何按 SCSS 到 Lit CSS 工作流更新组件样式,包括文件定位、使用主题变量、文档化及构建验证。
Trigger Scenarios
Install
npx skills add IgniteUI/igniteui-webcomponents --skill update-component-styles -g -y
SKILL.md
Frontmatter
{
"name": "update-component-styles",
"description": "Update component styling following the SCSS to Lit CSS workflow with proper theme support"
}
Update Component Styles
Changes component styles through the SCSS → Lit CSS build and the igniteui-theming schemas.
The directory layout and rules are in
Styles and Theming.
Related: create-new-component for a new theme scaffold.
Where a Change Goes
| Change | File |
|---|---|
| Layout, sizing, structure | [component].base.scss |
| Styling that reads theme variables | shared/[component].common.scss |
| One theme is structurally different | shared/[component].[theme].scss |
| A color or elevation for one theme | light/ or dark/[component].[theme].scss |
| A new variable for every theme | light/[component].shared.scss |
Steps
1. Edit the SCSS
Use 4-space indentation and load-path specifiers (@use 'styles/utilities' as *), not
relative paths into src/styles. Read theme values with var-get():
// shared/[component].common.scss
@use 'styles/utilities' as *;
@use '../light/themes' as *;
$theme: $material;
[part~='base'] {
background: var-get($theme, 'background');
color: var-get($theme, 'text-color');
}
// dark/[component].bootstrap.scss: emit only the difference from the light base
@use 'styles/utilities' as *;
@use 'themes' as *;
@use '../light/themes' as light;
$theme: $bootstrap;
:host {
@include css-vars-from-theme(diff(light.$base, $theme));
}
- Do not hardcode colors or sizes. Use
var-get(),color(),contrast-color(),sizable()and--ig-size. - Match parts with
[part~='name'].partMapemits a space-separated list. - Keep specificity low. Document the custom properties that consumers can set, and prefix
internal ones with
--_. - Key composite-anchor selectors off
data-role/data-haspopup, notrole/aria-*(see ARIA across shadow boundaries). var-get()resolves only keys that are in the schema. For a new key, add it toigniteui-theming, or declare a local variable inshared/[component].common.scss.
2. Document new parts or custom properties
/**
* @csspart base - The main container.
* @cssproperty --component-padding - The internal padding.
*/
Run npm run cem && npm run build:meta. Parts and custom properties are public API, so also
add a row to ### CSS Shadow parts or ### CSS custom properties in spec.md, add a TOC entry
for a new section, and add a row to ## Revision history. A visual change that adds no part or
property does not change the spec, unless it contradicts documented behavior.
3. Transpile and verify
npm run build:styles
npm run lint:styles
npm run storybook
npm run storybook and npm run test:watch also rebuild the styles when you save. Check all
four themes in light and dark mode.
[!IMPORTANT] The generated
.css.tsfiles are gitignored. Do not edit or commit them. The build compiles only*.{base,common,shared,material,bootstrap,indigo,fluent}.scss. Give helper partials a_prefix and@usethem.
Validation Checklist
- Only
.scssfiles are in the diff - Load-path specifiers. Values come from the theming functions.
-
[part~='…']selectors - Dark files emit only
diff(light.$base, $theme) - New parts and custom properties are in the JSDoc and in
spec.md -
build:stylesandlint:stylespass. All themes checked. - CHANGELOG updated if the change is user-visible
Common Pitfalls
| Symptom | Cause / Fix |
|---|---|
| Change does not show | build:styles did not run, or the filename is outside the glob |
| Change is gone after a build | A .css.ts file was edited. Edit the .scss. |
| Applies in one theme only | It is in a theme file, not in shared/[component].common.scss |
| Part selector stopped matching | [part='x'] with a multi-name partMap |
var-get() emits nothing |
The key is not in the schema |
| Dark looks like light | diff(light.$base, …) is missing, or an entry is missing in themes.ts |
| Consumers cannot override | Specificity is too high, or the element is not a part |
Reference Examples
src/components/badge/themes/: a complete, compact scaffoldsrc/components/input/themes/: many parts, material notch,data-roleselectorssrc/components/rating/spec.md: parts and custom properties documented together
Version History
- 7.4.1 Current 2026-09-28 12:53


