Action bar
Action bar is a floating, bottom-centered toolbar shown while one or more
rows of a
The table mounts one directly onto document.body whenever it has at
least one selected row and tears it down once the selection clears (a
plain, non-anchored position: fixed overlay needs no anchor-scoped portal
trick), but it's a fully standalone element too, usable on its own for a
custom selection UI built without a table at all, exactly like the demo
below.
Dependencies
The action bar below is repositioned within this preview box for the demo only (position: absolute instead of its own default fixed), since in real usage it's always centered at the bottom of the viewport, not a container.
When to use
Used automatically by
Install & usage
npm install @eunomia/elements
import "@eunomia/elements/table-action-bar.js";
<eun-table-action-bar id="bar"></eun-table-action-bar>
<script type="module">
const bar = document.querySelector("#bar");
bar.selectedCount = 3;
bar.totalCount = 8;
bar.actions = [
{ key: "archive", label: "Archive", variant: "critical", icon: "archive" },
];
bar.onSelectAll = () => {
/* select/deselect every row in your own list */
};
bar.onClose = () => {
/* clear your own selection */
};
bar.addEventListener("euntableaction", (event) => {
if (event.key === "archive") {
archiveSelected();
}
});
</script>
Properties
Action bar <eun-table-action-bar>
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
| selected-count | number | 0 | The number of currently selected rows |
| total-count | number | 0 | The total number of selectable rows, used for the select-all accessible label |
| toolbar-aria-label | string | 'Selection actions' | The accessible label for the toolbar itself |
| selected-label | string | 'selected' | Text shown after the count in the badge |
| select-all-label | string | 'Select all' | The label of the select-all button while not every row is selected |
| deselect-all-label | string | 'Deselect all' | The label of the select-all button once every row is selected |
| close-aria-label | string | 'Clear selection' | The accessible label for the close button |
Import the exact TypeScript type behind any property above, see
Properties
JS-only — no matching HTML attribute, set these from a script or a template binding.
| Name | Type | Default | Description |
|---|---|---|---|
| actions | Array<EunomiaTableAction> | [] | The custom actions rendered in the center region |
| onSelectAll | () => void | undefined | — | Called when the select-all/deselect-all button is clicked. Set by the owning `eun-table` (or a standalone consumer of this element). |
| onClose | () => void | undefined | — | Called when the close button is clicked. Set by the owning `eun-table` (or a standalone consumer of this element). |
Slots
| Name | Description |
|---|---|
| (default) | Extra content rendered in the center region, after the actions-driven buttons and dropdowns. An escape hatch for markup actions can't express, such as a custom control or a status message |
Events
| Name | Type | Description |
|---|---|---|
| euntableaction | TableActionEvent | Fired when a custom action is activated |
Every event above follows the same naming convention, covered in
CSS custom properties
| Name | Description |
|---|---|
| --table-action-bar-offset-bottom | Sets the distance from the bottom of the viewport |
| --table-action-bar-background | Sets the background color |
| --table-action-bar-border-color | Sets the border color |
| --table-action-bar-shadow | Sets the box shadow |
| --table-action-bar-z-index | Sets the stacking order, 100 by default |
| --table-action-bar-border-radius | Sets the corner radius of the action bar |
CSS shadow parts
| Name | Description |
|---|---|
| bar | The bar's own surface box, carrying its padding, background, and border. Exposed for effects the bar's CSS custom properties don't cover |
Plain button actions
The default shape: one or more eun-button actions, variant: "danger"
rendering critical/transparent instead of the default flat style.
bar.actions = [
{ key: "duplicate", label: "Duplicate", icon: "content_copy" },
{ key: "delete", label: "Delete", variant: "critical", icon: "delete" },
];
A dropdown action
Any actions entry with a dropdown array renders as a
eun-dropdown-button instead of a plain button, and euntableaction still
fires, carrying the chosen option's key as optionKey.
bar.actions = [
{
key: "export",
label: "Export",
icon: "file_download",
dropdown: [
{ key: "csv", label: "Export as CSV" },
{ key: "pdf", label: "Export as PDF" },
],
},
];
bar.addEventListener("euntableaction", (event) => {
if (event.key === "export") {
exportSelection(event.optionKey); // "csv" | "pdf"
}
});
Customized
Every visual piece is a --table-action-bar-* custom property, so restyle
it to match a brand accent instead of the neutral default.
<eun-table-action-bar
style="
--table-action-bar-background: var(--eun-color-primary-500, #3d6fff);
--table-action-bar-border-color: var(--eun-color-primary-500, #3d6fff);
--table-action-bar-shadow: var(--eun-shadow-l, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
color: var(--eun-color-on-primary-500, #ffffff);
"
></eun-table-action-bar>
Extra slotted content
actions covers a button or a dropdown, always, so for anything else in
the center region (a status message, a plain link, a custom control), the
default slot renders it right after them, as plain markup.
<eun-table-action-bar>
<eun-link href="/activity">View activity</eun-link>
</eun-table-action-bar>
role="toolbar", with aria-label from toolbarAriaLabel (default
"Selection actions"). The select-all button's accessible label includes
the total row count and reflects whether it currently reads "Select all"
or "Deselect all", while the close button's accessible label comes from
closeAriaLabel (default "Clear selection").
The count badge (visually "N selected") carries its own label, which
flips eun-badge from its default aria-hidden (purely decorative) to
role="status" (a live region), so the count is both exposed to
assistive tech and automatically re-announced every time it changes
(a row is added to or removed from the selection), not just readable once
on first encounter.
Portaled directly onto document.body, outside eun-table's own DOM
subtree entirely: the same technique this library's tooltips/dropdown
menus use to always render above everything else, regardless of any
overflow/transform on an ancestor.