Продвинутая Lovelace-карточка для Home Assistant
7 body modes • Grid layout • Header layouts • Badges • Footer • Lazy loading • Visual editor
Universal Card это гибкая карточка для Home Assistant, которая умеет быть:
- обычной expandable карточкой
- modal или fullscreen overlay
- tabs-контейнером
- carousel-контейнером
- subview launcher
- компактной header-only карточкой
В карточке есть:
- grid layout с
colspanиrowspan - header presets и badges
- footer с действиями
- visibility и section visibility
- root actions и swipe gestures
- themes,
theme_tokens,state_styles,custom_css - встроенный visual editor
Основные страницы:
- Feature Map
- Configuration
- Examples Gallery
- YAML Block Reference
- Field Matrix
- Grid Layout
- Footer
- Visibility
- Actions And Gestures
- Recipes by Use Case
- Modal Layout
- Body Modes Layout
- Header Layout
- Badges
- Theming Guide
- Loading Strategy
- Editor
- Release Notes
GitHub Pages:
- Откройте HACS → Frontend
- Нажмите + и найдите Universal Card
- Установите карточку
- Дополнительные lazy-бандлы подхватятся автоматически из HACS-каталога установки
- Обновите страницу Home Assistant
- Скачайте последний релиз из GitHub Releases
- Скопируйте
universal-card.jsи папкуlazy/в/config/www/universal-card/ - Добавьте resource в Lovelace:
url: /local/universal-card/universal-card.js
type: module- Обновите страницу Home Assistant
type: custom:universal-card
title: Example
body:
cards:
- type: markdown
content: Hellotype: custom:universal-card
title: Living Room
subtitle: Lights and comfort
icon: mdi:sofa
entity: input_boolean.kitchen_light
theme: glass
body:
cards:
- type: entities
entities:
- entity: input_boolean.kitchen_light
- entity: sensor.demo_temperature
- entity: sensor.demo_humiditytype: custom:universal-card
title: Security Controls
body_mode: modal
icon: mdi:shield-home
modal:
width: auto
max_width: 72rem
max_height: 85vh
loading_strategy: lazy
body:
cards:
- type: entities
entities:
- entity: input_boolean.security_armed
- entity: sensor.security_statustype: custom:universal-card
title: Climate Tabs
body_mode: tabs
tabs:
- label: Climate
icon: mdi:home-thermometer
cards:
- type: entities
entities:
- entity: sensor.demo_temperature
- entity: sensor.demo_humidity
- label: Security
icon: mdi:shield-lock
cards:
- type: entities
entities:
- entity: input_boolean.security_armed
- entity: sensor.security_statustype: custom:universal-card
title: Kitchen
subtitle: Lights and scenes
header:
layout:
variant: stacked
badges_position: below_content
badges:
- type: state
entity: input_boolean.kitchen_light
icon: mdi:lightbulb
label: Main
color_rules:
- operator: ==
value: 'on'
color: gold
- operator: ==
value: 'off'
color: gray
body:
cards:
- type: entities
entities:
- entity: input_boolean.kitchen_lightСамые полезные стартовые точки:
- Basic expandable card
- Modal detail card
- Fullscreen media card
- Tabs card
- Badge status row
- Conditional UI
- Theme override card
- Stable wall panel
- Security dashboard recipe
- Mobile dashboard recipe
Что открывать в зависимости от задачи:
- нужен старт и структура: Configuration
- нужен копируемый пример: Examples Gallery
- нужен быстрый lookup по полям: Field Matrix
- нужен полный блочный reference: YAML Block Reference
- нужен layout guide: Grid Layout, Header Layout, Footer
- нужны body modes: Modal Layout, Body Modes Layout
- нужны rules/actions: Badges, Visibility, Actions And Gestures
- нужен styling guide: Theming Guide, Custom CSS Recipes, Selector Catalog
- нужен editor coverage: Editor
- 7 body modes:
expand,modal,fullscreen,tabs,carousel,subview,none - grid layout с
colspanиrowspan - configurable header layouts и badges
- footer slots и action rows
- visibility, section visibility, context menu и swipe
- themes,
theme_tokens,state_styles,custom_css - visual editor для основных сценариев
Да, custom_css поддерживается.
Практический маршрут:
- сначала
theme - потом
theme_tokens - потом
state_styles custom_cssтолько для точечных override
Для новых override-сценариев лучше опираться на стабильные data-uc-* hooks из Selector Catalog.
Подробнее:
Editor лучше всего покрывает:
- shell fields
- header layout
- modal/fullscreen/tabs/carousel/subview settings
- badge
visibilityиcolor_rules visibilityиsection_visibilityswipetheme_tokensstate_styles
YAML остаётся лучшим вариантом для:
- сложных
grid.columnsстрок - advanced
custom_css - крупных action payloads
- badge
tap_actionиicon_tap_action
Подробнее: Editor
- обновите страницу Home Assistant
- очистите браузерный cache
- проверьте путь к resource
Откройте консоль браузера и выполните:
enableUniversalCardDebug()Выключить:
disableUniversalCardDebug()Нет, для большинства карточек editor достаточно. YAML нужен в основном для сложных layout и styling сценариев.
Да. Внутри body.cards, tabs, grid cells, modal и fullscreen можно использовать вложенные Lovelace cards.
Да. Для этого есть custom_css, но лучше сначала попробовать theme и theme_tokens.
MIT. См. LICENSE.
Issues и Pull Requests приветствуются. Если меняете user-facing поведение, синхронизируйте код, examples и docs вместе.
