Expanding Action
<zn-expanding-action>
ZnExpandingAction
Expanding actions are icon buttons that reveal content in a dropdown panel or inline, optionally loaded from a URL.
Labels
2 labels were added since your last visit
<zn-expanding-action icon="new_label" count="2"> <div style="padding: 15px; min-width: 250px;"> <h4>Labels</h4> <p>2 labels were added since your last visit</p> </div> </zn-expanding-action>
Examples
Drop Method
Use the method="drop" to display content in a dropdown panel when the icon is clicked.
Notifications
You have 3 new messages
2 tasks are due today
<zn-expanding-action icon="notifications" method="drop"> <div style="padding: 15px; min-width: 250px;"> <h4>Notifications</h4> <p>You have 3 new messages</p> <p>2 tasks are due today</p> </div> </zn-expanding-action>
Fill Method
Use the method="fill" to display content inline, expanding horizontally.
This content expands inline when clicked
<zn-expanding-action icon="add" method="fill"> <div style="padding: 10px;"> <p>This content expands inline when clicked</p> </div> </zn-expanding-action>
With Notification Count
Display a notification badge using the count attribute.
Inbox
You have 5 unread messages
<zn-expanding-action icon="mail" method="drop" count="5"> <div style="padding: 15px; min-width: 250px;"> <h4>Inbox</h4> <p>You have 5 unread messages</p> </div> </zn-expanding-action>
With Custom Color
Set the icon color using the color attribute.
Warnings
2 items require your attention
<zn-expanding-action icon="warning" method="drop" color="warning" count="2"> <div style="padding: 15px; min-width: 250px;"> <h4>Warnings</h4> <p>2 items require your attention</p> </div> </zn-expanding-action>
Count and Color from the Server
Set context-uri to have the action send a HEAD request to that URL when it first
renders. An x-kubex-count response header sets the notification count, and an
x-kubex-color header sets the icon color. Both headers are optional.
<zn-expanding-action icon="mail" method="drop" context-uri="/inbox/summary"> … </zn-expanding-action>
Panels Loaded from a URL
Give an element inside the action an action-uri to load a panel from that URL. On hover intent
or click, the action adds a panel showing “Loading …” and emits zn-new-element on
document with the panel as detail.element; the host app listens for it and loads
the URL into the panel. Add no-prefetch to create the panel only on click.
When the loaded content renders inside an app-content element, a
<meta name="count"> or <meta name="color"> in it updates the count or
icon color.
These docs have no host listener, so this example is not live.
<zn-expanding-action icon="edit_note" method="drop" no-prefetch> <zn-button action-uri="/notes/recent">Recent notes</zn-button> <zn-button action-uri="/notes/pinned">Pinned notes</zn-button> </zn-expanding-action>
Custom Width
Control the dropdown width using the basis attribute (for drop method).
Wide Panel
This panel is wider than the default 300px
<zn-expanding-action icon="menu" method="drop" basis="400"> <div style="padding: 15px;"> <h4>Wide Panel</h4> <p>This panel is wider than the default 300px</p> </div> </zn-expanding-action>
Custom Max Height
Limit the content height using the max-height attribute.
Scrollable Content
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
<zn-expanding-action icon="list" method="drop" max-height="200"> <div style="padding: 15px;"> <h4>Scrollable Content</h4> <p>Item 1</p> <p>Item 2</p> <p>Item 3</p> <p>Item 4</p> <p>Item 5</p> <p>Item 6</p> <p>Item 7</p> <p>Item 8</p> </div> </zn-expanding-action>
Multiple Expanding Actions
Use multiple expanding actions together.
Notifications
3 new updates
Messages
7 unread messages
Settings
Configure your preferences
<div style="display: flex; gap: 10px;"> <zn-expanding-action icon="notifications" method="drop" count="3"> <div style="padding: 15px; min-width: 250px;"> <h4>Notifications</h4> <p>3 new updates</p> </div> </zn-expanding-action> <zn-expanding-action icon="mail" method="drop" count="7"> <div style="padding: 15px; min-width: 250px;"> <h4>Messages</h4> <p>7 unread messages</p> </div> </zn-expanding-action> <zn-expanding-action icon="settings" method="drop"> <div style="padding: 15px; min-width: 200px;"> <h4>Settings</h4> <p>Configure your preferences</p> </div> </zn-expanding-action> </div>
In Action Bar
Use expanding actions within an action bar for navigation.
Notes
2 draft notes
Alerts
5 new notifications
<zn-action-bar> <zn-dropdown distance="5" slot="menu"> <zn-button slot="trigger" color="transparent" icon-position="right" icon="arrow_drop_down"> Dashboard </zn-button> <zn-menu> <zn-menu-item>Overview</zn-menu-item> <zn-menu-item>Analytics</zn-menu-item> </zn-menu> </zn-dropdown> <zn-expanding-action icon="edit_note" method="drop" count="2" slot="actions"> <div style="padding: 15px; min-width: 250px;"> <h4>Notes</h4> <p>2 draft notes</p> </div> </zn-expanding-action> <zn-expanding-action icon="notifications" method="drop" count="5" slot="actions"> <div style="padding: 15px; min-width: 250px;"> <h4>Alerts</h4> <p>5 new notifications</p> </div> </zn-expanding-action> </zn-action-bar>
With Form Content
Include form elements within the expanding action.
Quick Add
<zn-expanding-action icon="add_circle" method="drop" basis="350"> <div style="padding: 15px;"> <h4>Quick Add</h4> <form class="form-spacing"> <zn-input label="Title" required></zn-input> <zn-textarea label="Description"></zn-textarea> <zn-button type="submit" color="success">Add</zn-button> </form> </div> </zn-expanding-action>
Nested in Defined Label
Combine with other components like defined-label.
<zn-expanding-action icon="label" method="fill" basis="400"> <zn-defined-label allow-custom predefined-labels="[{"name":"priority","options":["low","medium","high"]},{"name":"status","options":["open","closed"]}]"> </zn-defined-label> </zn-expanding-action>
User Profile Menu
A practical example for a user profile dropdown.
John Doe
john@example.com
<zn-expanding-action icon="account_circle" method="drop" basis="250"> <div style="padding: 15px;"> <h4>John Doe</h4> <p style="color: var(--zn-color-neutral-500); margin: 0;">john@example.com</p> <hr style="margin: 10px 0;"> <zn-button text color="transparent" style="width: 100%; justify-content: flex-start;">Profile</zn-button> <zn-button text color="transparent" style="width: 100%; justify-content: flex-start;">Settings</zn-button> <zn-button text color="transparent" style="width: 100%; justify-content: flex-start;">Logout</zn-button> </div> </zn-expanding-action>
Slots
| Name | Description |
|---|---|
| (default) | The default slot. |