Expansion panel
An expansion panel hides a section behind a header, so people can open it when they need it.
Polling interval, timeouts, and other options most people never need to touch.
An expansion panel hides a section behind a header, so people can open it when they need it. It keeps a screen short and calm: the things most people need sit on the screen itself, and the rest waits in a panel.
Use an expansion panel for:
- Advanced options in a form
- The optional fields of a dialog
- A group of filters
Don't use an expansion panel for:
- What people need to complete the task. If someone has to open the panel every time, the content should not be in a panel.
- A set of rows that open something else. Use a list.
- Container: with
outlined, a border and rounded corners around the whole panel - Header: the row people select to open or close the panel
- Leading icon: optional, an icon at the start of the header
- Title: the header text
- Secondary text: optional, a short line below the title
- Chevron: points down when closed, and turns up when open. At the end of the header, or at the start with
left-chevron. - Header icons: optional, actions at the end of the header
- Content: the section that opens and closes
The header says what is inside. Keep it short: Advanced settings, Areas, Network. A secondary line below it can give a short summary, like the current value or why someone would open it.
IP address, DNS, and proxy settings.
IP address, DNS, and proxy settings.
An outlined panel gets a border and rounded corners. The frontend uses it when the panel sits in a form or a dialog, next to other fields, so it reads as one block. The expandable section of a form and the card editors do this. Without the outline, the panel blends into its surroundings, which works in a list of panels, like the filter panes and the card picker.
The content of the panel.
The content of the panel.
By default, the chevron sits at the end of the header. It can move to the start. The filter panes on the configuration pages use this, with a count of active filters and a button to clear them in the header.
Filter by area.
A panel can be open from the start.
Settings and history, media, and the share folder.
Without the chevron, people can no longer open or close the panel. Open from the start, it is a section that looks like a panel but always stays open.
- Closed: only the header shows. The content is not rendered at all.
- Opening and closing: selecting the header opens or closes the panel. The content slides open or closed in 300ms, and the chevron turns in 150ms.
- Focus: while the header has focus, it gets the input fill as background. With keyboard focus, the chevron also gets a round neutral fill.
- Always open: the header can't be selected or focused.
| Property | Value | Token |
|---|---|---|
| Header minimum height | 48px | None |
| Header padding | 0 top and bottom, 8px left and right | --expansion-panel-summary-padding |
| Content padding | 0 top and bottom, 8px left and right | --expansion-panel-content-padding |
| Header font weight | 500 | --ha-font-weight-medium |
| Title color | Primary text color | --primary-text-color |
| Secondary text size | 12px | --ha-font-size-s |
| Secondary text color | Secondary text color | --secondary-text-color |
| Space between chevron or leading icon and title | 8px | None |
| Chevron size | 24px | None |
| Border, outlined | 1px solid | --outline-color |
| Corner radius, outlined | 12px | --ha-border-radius-lg, through --ha-card-border-radius |
| Header background on focus | Input fill | --input-fill-color |
| Chevron background on keyboard focus | Round neutral fill | --ha-color-fill-neutral-normal-active |
| Open and close animation | 300ms, cubic-bezier(0.4, 0, 0.2, 1) |
None |
| Chevron rotation | 180 degrees in 150ms, cubic-bezier(0.4, 0, 0.2, 1) |
None |
- Follow what the frontend does: an outlined panel in a form or a dialog, next to other fields, and no outline in a list of panels, like the filter panes.
| Key | Action |
|---|---|
| Tab | Moves focus to the header. A panel that is always open is skipped. |
| Enter or Space | Opens or closes the panel. |
While the header has focus, it gets the input fill as background. With keyboard focus, the chevron also gets a round neutral fill.
The header is at least 48px high, and as wide as the panel.
The header is announced as a button that is expanded or collapsed. The open content is announced as a region, named after the header.
- The header has the role
button, witharia-expandedset totrueorfalse. - The content has the role
region, and is named by the header througharia-labelledby. - While the panel is closed, the content has
aria-hidden="true", and is not rendered. - The chevron is decorative and hidden from screen readers.
- List: rows that open something else
- Form: the
expandableschema type shows an expansion panel - Dialog: where panels hold optional fields
The element is <ha-expansion-panel>. The content goes in the default slot.
<ha-expansion-panel outlined header="Advanced settings" secondary="Optional">
<p>...</p>
</ha-expansion-panel>The content only renders while the panel is open. Keep that in mind if something inside needs to exist before it is opened.
header: the header text.secondary: a short line of text below the header.expanded: opens the panel. Reflected, and updated when people open or close the panel.outlined: adds a border and rounded corners.left-chevron: puts the chevron at the start of the header.no-collapse: removes the chevron, and the panel can no longer be opened or closed by people. Combine it withexpandedfor a section that looks like a panel but always stays open.
- Default: the content.
header: replaces the header text, and the secondary text, with your own content.secondary: replaces the secondary text.leading-icon: an icon at the start of the header.icons: actions at the end of the header, like an icon button.event: content between the header and the chevron.
expanded-will-change: fires just before the panel opens or closes. Thedetailhas the newexpandedvalue.expanded-changed: fires after the panel opened or closed. Thedetailhas the newexpandedvalue.
--expansion-panel-summary-padding: padding of the header. Defaults to0 8px.--expansion-panel-content-padding: padding of the content. Defaults to0 8px.--ha-card-border-radius: the corner radius of an outlined panel. Defaults tovar(--ha-border-radius-lg).
The summary part targets the header, for anything the custom properties don't cover.