Eunomia v1.0.0-beta.2
AllAngularReactNext.jsJavaScriptVue
EunomiaSalmonForestVioletOceanGoldFireCustom…
🇬🇧 English🇫🇷 Français

Action bar

Action bar is a floating, bottom-centered toolbar shown while one or more rows of a table are selected, made up of a count badge, a "select/deselect all" toggle, any number of custom actions, and a close button that clears the selection.

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

eun-badge · shows the selected count eun-button · renders the select-all/close controls and every plain action eun-dropdown-button · renders an action once it sets its own dropdown eun-divider · separates the three regions eun-icon · renders the action/select-all/close icons
Overview API Examples Accessibility

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 table once it's set to be selectable and at least one row is checked. See Table: Selection and the floating action bar. Use it directly, on its own, only when building a custom selection UI outside a table (a card grid with checkboxes, say) that wants the exact same bulk-action chrome.

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

NameTypeDefaultDescription
selected-countnumber0The number of currently selected rows
total-countnumber0The total number of selectable rows, used for the select-all accessible label
toolbar-aria-labelstring'Selection actions'The accessible label for the toolbar itself
selected-labelstring'selected'Text shown after the count in the badge
select-all-labelstring'Select all'The label of the select-all button while not every row is selected
deselect-all-labelstring'Deselect all'The label of the select-all button once every row is selected
close-aria-labelstring'Clear selection'The accessible label for the close button

Import the exact TypeScript type behind any property above, see Types.

Properties

JS-only — no matching HTML attribute, set these from a script or a template binding.

NameTypeDefaultDescription
actionsArray<EunomiaTableAction>[]The custom actions rendered in the center region
onSelectAll() => void | undefinedCalled when the select-all/deselect-all button is clicked. Set by the owning `eun-table` (or a standalone consumer of this element).
onClose() => void | undefinedCalled when the close button is clicked. Set by the owning `eun-table` (or a standalone consumer of this element).

Slots

NameDescription
(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

NameTypeDescription
euntableactionTableActionEventFired when a custom action is activated

Every event above follows the same naming convention, covered in Events.

CSS custom properties

NameDescription
--table-action-bar-offset-bottomSets the distance from the bottom of the viewport
--table-action-bar-backgroundSets the background color
--table-action-bar-border-colorSets the border color
--table-action-bar-shadowSets the box shadow
--table-action-bar-z-indexSets the stacking order, 100 by default
--table-action-bar-border-radiusSets the corner radius of the action bar

CSS shadow parts

NameDescription
barThe 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.

View activity
<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.