/modern-html:modern-html-css-architecturefrom modern-html
Cascade layers (@layer), @scope at-rule, native CSS nesting for stylesheet structure, specificity, component scoping, replacing BEM/CSS-Modules. Use when: new design system, migrating off Sass mixins, organizing token layers, specificity battles, scoping component CSS sans build step. Skip: single-file demo or prototype, architecture overhead not worth it.
Ships in modern-html. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
@layer (甲, 2024-09 Widely)層序定先,內中 specificity 自然。
@layer reset, tokens, base, layout, components, utilities, overrides;
@layer reset { *, *::before, *::after { box-sizing: border-box; } }
@layer tokens { :root { --brand: oklch(60% 0.18 250); } }
@layer base { body { font-family: system-ui; } }
@layer components { .button { ... } }
@layer utilities { .mt-4 { margin-top: 1rem; } }
要點:
.button.button--primary 勝 .button 同層。!important 反序:層內外皆。層名可前後聲明:
@layer reset, tokens; /* 序定 */
@layer reset { ... } /* 後填 */
@scope (乙, 2025-12 Firefox 146)替 BEM / CSS Modules 多用例。
獨立形:
@scope (.card) {
:scope { padding: 1rem; }
h3 { margin: 0 0 .5rem; }
a { color: var(--brand); }
}
加 limit(後代但不過 limit):
@scope (.card) to (.card__nested) {
h3 { ... } /* 不及嵌套 .card__nested 內 */
}
嵌入 stylesheet:
<style>
@scope { :scope { ... } }
</style>
注:@scope 限樣式於 root 後代,非 isolation。仍受 cascade。
.card {
padding: 1rem;
& > h2 { margin: 0; }
&:hover { box-shadow: ... }
& a { color: var(--brand); &:hover { text-decoration: underline; } }
@media (min-width: 40rem) { & { padding: 2rem; } }
}
律:
&:& a、&.active、& > .child。a 等價 & a(規範 2024 修正後)。@media 內須 & { ... } 包當前 selector 規則。@layer components {
@scope (.card) to (.card__nested) {
:scope { padding: 1rem; border-radius: .75rem; container-type: inline-size; }
h3 { margin: 0 0 .5rem; }
a {
color: var(--brand);
&:hover { text-decoration: underline; }
}
@container (min-width: 24rem) {
:scope { padding: 1.5rem; }
}
}
}
| Sass | Native |
|---|---|
| nesting | native nesting |
@use modules | @layer 分區 |
BEM __elem | @scope |
lighten() darken() | color-mix(in oklch, var(--c), white 20%) |
| variables | --custom-property |
| mixins | 無 — 仍須 Sass / PostCSS / Lightning CSS |
@extend | :is(.a, .b) { ... } 多用例 |
@layer 改層內 specificity(不改)。@scope 用於 isolation(仍 cascade)。!important 解決 layer order(反序,更糟)。examples/layers.cssexamples/scope.cssexamples/nesting.cssmodern-html:baseline-decision-protocol — 前置 Tier A/B/C 閘;先判可用層,再取此技各特性。modern-html:theming-and-color — 色彩 / 主題層依此架構落位,配對取用。What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
10 skills in this plugin
/modern-html-accessibility-primitivesNative a11y primitives — focus-visible, focus-within, inert, prefers-reduced-motion, prefers-color-scheme, prefers-contrast, forced-colors, accessibility-tree for dialog/popover/anchor-positioning, ARIA labeling. Use when: focus styles, keyboard nav, animating UI, picking colors, modal/popover content, auditing component a11y. Skip: backend code, non-rendered content./modern-html-baseline-decision-protocolBaseline-tier decision tree for HTML/CSS/DOM Tier A Widely-9mo auto-adopt, Tier B Newly prompt, Tier C Limited avoid sans fallback. Use when: writing CSS/HTML, picking UI pattern, replacing JS lib, choosing layout/animation primitive, before popover/dialog/container-queries/anchor-positioning/view-transitions/scroll-driven-animations/color-mix/oklch/:has(). Skip: non-UI code./modern-html-js-replacement-patternsnpx claudepluginhub standardbeagle/standardbeagle-tools --plugin modern-html