Agent Skillshome-assistant/frontend › ha-frontend-styling

ha-frontend-styling

GitHub

Home Assistant 前端样式开发指南,涵盖 CSS 自定义属性、间距令牌、响应式布局、RTL 支持及视图过渡动画。指导组件样式隔离、无障碍访问及交互状态处理。

.agents/skills/ha-frontend-styling/SKILL.md home-assistant/frontend

Trigger Scenarios

编辑 Home Assistant 前端 CSS 或样式文件 调整组件布局、主题集成或响应式设计 实现视图过渡动画或移动端适配

Install

npx skills add home-assistant/frontend --skill ha-frontend-styling -g -y
More Options

Non-standard path

npx skills add https://github.com/home-assistant/frontend/tree/dev/.agents/skills/ha-frontend-styling -g -y

Use without installing

npx skills use home-assistant/frontend@ha-frontend-styling

指定 Agent (Claude Code)

npx skills add home-assistant/frontend --skill ha-frontend-styling -a claude-code -g -y

安装 repo 全部 skill

npx skills add home-assistant/frontend --all -g -y

预览 repo 内 skill

npx skills add home-assistant/frontend --list

SKILL.md

Frontmatter
{
    "name": "ha-frontend-styling",
    "description": "Home Assistant frontend styling, theming, spacing, responsive layout, RTL, and View Transitions guidance. Use when editing CSS, layout, motion, or visual component structure."
}

HA Frontend Styling

Use this skill when editing CSS, layout, visual hierarchy, theme integration, responsive behavior, RTL support, or view transitions.

Theme And Layout Basics

  • Use Home Assistant CSS custom properties instead of hardcoded colors.
  • Use --ha-space-* spacing tokens instead of hardcoded spacing where possible.
  • Keep components mobile-first and enhance for desktop.
  • Keep layouts RTL-safe. Prefer logical properties when they fit.
  • Prefer ha-* components and current Web Awesome wrappers.
  • Avoid adding new legacy Material Web Components (mwc-*).
  • Scope styles to the component. Do not rely on global styles for component internals.

Spacing tokens are defined in src/resources/theme/core.globals.ts. The scale runs from --ha-space-1 at 4px through --ha-space-20 at 80px in 4px increments. Common values are --ha-space-2 at 8px, --ha-space-4 at 16px, and --ha-space-8 at 32px.

static get styles() {
  return css`
    :host {
      padding: var(--ha-space-4);
      color: var(--primary-text-color);
      background-color: var(--card-background-color);
    }

    .content {
      gap: var(--ha-space-2);
    }

    @media (max-width: 600px) {
      :host {
        padding: var(--ha-space-2);
      }
    }
  `;
}

Interaction States

  • Make touch targets large enough for mobile.
  • Provide clear hover, active, focus, disabled, loading, error, and unavailable states.
  • Preserve keyboard navigation and visible focus indicators.
  • Maintain WCAG AA contrast for text and essential UI affordances.

View Transitions

Use the View Transitions API only for meaningful continuity between DOM states.

Core resources:

  • Utility wrapper: src/common/util/view-transition.ts, withViewTransition().
  • Launch-screen fade example: src/util/launch-screen.ts.
  • Animation keyframes: src/resources/theme/animations.globals.ts.
  • Animation duration tokens: src/resources/theme/core.globals.ts.

Implementation rules:

  • Use withViewTransition() for fallback behavior.
  • Keep transitions simple. Subtle fades and crossfades usually work best.
  • Use --ha-animation-duration-fast, --ha-animation-duration-normal, or --ha-animation-duration-slow for timing.
  • Ensure each view-transition-name is unique at any given time.
  • Remember only one view transition can run at a time.
  • View transitions operate at document level and do not work inside Shadow DOM style isolation. For web components, set view-transition-name on :host or use document-level transitions.
  • The root gets view-transition-name: root by default. Target ::view-transition-group(root) to customize the default page transition.

Review Checklist

  • Styling uses theme variables and spacing tokens where practical.
  • Layout is mobile-first and RTL-safe.
  • Component styles are scoped.
  • Interactive states are clear and accessible.
  • Motion is subtle, tokenized, and respects reduced-motion behavior through existing globals.

Version History

  • 3c7560a Current 2026-08-20 08:57

Same Skill Collection

.agents/skills/ha-frontend-components/SKILL.md
.agents/skills/ha-frontend-contexts/SKILL.md
.agents/skills/ha-frontend-demo/SKILL.md
.agents/skills/ha-frontend-events/SKILL.md
.agents/skills/ha-frontend-gallery/SKILL.md
.agents/skills/ha-frontend-lit/SKILL.md
.agents/skills/ha-frontend-review/SKILL.md
.agents/skills/ha-frontend-testing/SKILL.md
.agents/skills/ha-frontend-types/SKILL.md
.agents/skills/ha-frontend-user-facing-text/SKILL.md

Metadata

Files
0
Version
3c7560a
Hash
2d355025
Indexed
2026-08-20 08:57

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-26 00:59
浙ICP备14020137号-1 $방문자$