跳到正文
cccskills
免费在 GitHub 公开

blazor-css-isolation

Load when editing Blazor `.razor.css`, scoped selectors, `::deep`, BEM class names, RTL/logical CSS properties, or styling nested MudBlazor components; not for global design tokens or non-Blazor CSS.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(5)

  • SKILL.md4.1 KB
  • resources/bem-with-isolation.md414 B
  • resources/debugging-scoped-css.md1.1 KB
  • resources/deep-selector-patterns.md564 B
  • resources/mudblazor-styling.md5.8 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

ABOUTME: CSS isolation + BEM rules for Blazor components. ABOUTME: Read referenced resources before applying.

Blazor CSS Isolation with BEM Methodology

Project-Agnostic CSS Isolation Patterns for Blazor

Placeholders use {Placeholder} syntax - see docs/internal/TEMPLATE_GLOSSARY.md.

Non‑Inferable Rules (Must Follow)

  • .razor.css file must match component name (colocated).
  • Prefer BEM naming even though isolation prevents collisions.
  • Style child components in their own CSS; use wrapper pattern before ::deep.
  • ::deep only for third‑party internals (fragile).
  • Ensure {Project}.styles.css is referenced in host.
  • MudBlazor styling: Always wrap MudBlazor components in a <div> with a BEM class before using ::deep selectors.
  • Customization priority: component params → Class + utility classes → MudTheme → CSS variables → wrapper components → ::deep (last resort).
  • Anti-pattern: Never use global CSS to override MudBlazor base classes without scoping. Never use !important in isolated CSS.

Global CSS Architecture (@layer)

Global styles use @layer cascade ordering via css/layers.css:

@layer reset, base, tokens, mudblazor-overrides, components, utilities;

Each layer file is imported with @import url("file.css") layer(name). The layer order determines cascade priority — later layers win over earlier ones regardless of specificity. Files:

LayerFileContents
resetreset.cssUniversal margin/padding reset, link/list reset
basebase.csshtml/body defaults, scroll-lock
tokenstokens.css3-tier design tokens (primitives → semantic → component)
mudblazor-overridesmudblazor-overrides.cssApproved .mud-* exceptions with justification comments
componentscomponents.css.isl-card, footer, .isl-button-pill, .isl-popover-menu, .isl-form-*
utilitiesutilities.css.isl-typo-*, .sr-only, a11y media queries

CSS Nesting (Native)

Use native CSS nesting with & in .razor.css files:

  • Nest: pseudo-classes (:hover, :focus), pseudo-elements (::before), modifiers (&.block--modifier), media/container queries
  • Cannot concatenate BEM: &__element does NOT work in native CSS (Sass-only). Keep BEM element selectors flat.
  • Max depth: 3 levels. Cross-cutting media queries affecting 5+ selectors stay flat at file bottom.
/* CORRECT */
.my-card {
    border: 1px solid var(--isl-color-border);
    &:hover { transform: translateY(-2px); }
    &.my-card--featured { border-color: var(--mud-palette-primary); }
    @media (max-width: 48em) { padding: var(--isl-space-3); }
}

/* WRONG — BEM concatenation doesn't work in native CSS */
.my-card { &__title { font-weight: 600; } }

Container Queries

Use container-type: inline-size on layout wrappers, then @container queries inside child selectors for component-level responsive adaptation:

.event-list__main { container-type: inline-size; }
::deep .event-grid { @container (max-width: 599.98px) { /* single column */ } }
  • Prefer unnamed containers (anonymous) unless disambiguation is needed.
  • Use container queries instead of viewport media queries for component layouts.
  • Keep viewport media queries for truly page-level concerns (navigation, footer).

Resources (Read Before Applying)

Related Documentation

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Load for Blazor/MudBlazor UI changes involving forms, dialogs, focus, keyboard navigation, landmarks, ARIA, color contrast, RTL-safe styling, or WCAG 2.2 AA tests; not for backend-only changes.

中文简介正在准备中。当前显示原文说明。

islamu-ngo/Event82026年10月19日 更新

Load when a task asks to research, verify, compare, or look up framework/package behavior, release notes, standards, RFCs, CVEs, or unfamiliar APIs; use repository evidence first, then official docs, and not for codebase navigation alone.

中文简介正在准备中。当前显示原文说明。

islamu-ngo/Event82026年10月19日 更新

aspire

免费

Load for Aspire AppHost work: start/stop/wait resources, inspect dashboard/logs/traces, add integrations/resources, rebuild a service, run isolated worktrees, or diagnose Aspire orchestration; not for plain dotnet apps, container-only deployments, or cloud deployment.

中文简介正在准备中。当前显示原文说明。

islamu-ngo/Event82026年10月19日 更新

Load for authentication or authorization changes involving BFF cookies/tokens, JWT validation, claims/user ID extraction, policies, handler access checks, impersonation, or 401/403 bugs; not for UI affordance gating alone.

中文简介正在准备中。当前显示原文说明。

islamu-ngo/Event82026年10月19日 更新

Load for Blazor BFF server work involving YARP proxy routes, cookie sessions, access-token forwarding/refresh, downstream API calls, BFF handlers, or browser-to-API auth failures; not for client component rendering or API JWT validation alone.

中文简介正在准备中。当前显示原文说明。

islamu-ngo/Event82026年10月19日 更新

Load for Blazor/MudBlazor component or page changes involving render modes, dialogs, parameters/events, HAL-gated actions, generated API clients or generated record consumption, theming, or component tests; add accessibility or CSS-isolation only when touched.

中文简介正在准备中。当前显示原文说明。

islamu-ngo/Event82026年10月19日 更新

查看 islamu-ngo 的全部技能

报告此技能的问题