Presentation
Learn how to add tabs, tooltips, labels, modal dialogs, empty states and tables to your web pages.
Simple Tabs
View codeHide code
<div role="tablist" class="tabs bb">
<a role="tab" aria-selected="true" class="tab-item active" title="First Tab" href="/first-tab">
<span>First Tab</span>
</a>
<a role="tab" aria-selected="false" class="tab-item" title="Second Tab" href="/second-tab">
<span>Second Tab</span>
</a>
</div>By default, tabs don’t have a line at the bottom. You can add a .bb class to the .tabs to add it.
Tabs with Icons
View codeHide code
<div role="tablist" class="tabs bb">
<a role="tab" aria-selected="true" class="tab-item active" title="Sent" href="/sent">
<svg class="icon" aria-hidden="true" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M2.016 21v-6.984l15-2.016-15-2.016V3l21 9z">
</path>
</svg>
<span>Sent</span>
</a>
<a role="tab" aria-selected="false" class="tab-item" title="Rejected" href="/rejected">
<svg class="icon" aria-hidden="true" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M12 20c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-18C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm3 5.59-3 3-3-3L7.59 9l3 3-3 3L9 16.41l3-3 3 3L16.41 15l-3-3 3-3L15 7.59z">
</path>
</svg>
<span>Rejected</span>
</a>
</div>Full-Width Tabs
View codeHide code
<div role="tablist" class="tabs bb">
<a role="tab" aria-selected="true" class="tab-item active mr-0 flex-grow" title="First Tab" href="/first-tab">
<span>First Tab</span>
</a>
<a role="tab" aria-selected="false" class="tab-item mr-0 flex-grow" title="Second Tab" href="/second-tab">
<span>Second Tab</span>
</a>
<a role="tab" aria-selected="false" class="tab-item mr-0 flex-grow" title="Third Tab" href="/third-tab">
<span>Third Tab</span>
</a>
</div>You can add a .flex-grow class to each tab to make it grow horizontally. Also, remove spacing between tabs by adding .mr-0 to each tab.
Secondary Tabs
Secondary tabs switch between views inside a section, below the page tabs or above a list. They are small buttons in a row with a 4px gap: the selected tab is .btn.sm.secondary with .text-base on its text, the others are .btn.sm.borderless.
View codeHide code
<div role="tablist" class="d-flex flex-wrap gap-4">
<button type="button" role="tab" aria-selected="true" class="btn sm secondary"><span class="text-base">Templates</span></button>
<button type="button" role="tab" aria-selected="false" tabindex="-1" class="btn sm borderless"><span>Components</span></button>
<button type="button" role="tab" aria-selected="false" tabindex="-1" class="btn sm borderless"><span>Assets</span></button>
</div>Secondary Tabs with Icons
A secondary tab can have an icon before or after the text. Use any icon from the icon set.
View codeHide code
<button type="button" role="tab" aria-selected="true" class="btn sm secondary">
<svg class="icon" aria-hidden="true"><use href="#common-shield-check"/></svg>
<span class="text-base">Approved</span>
</button>
<button type="button" role="tab" aria-selected="false" tabindex="-1" class="btn sm borderless">
<span>More</span>
<svg class="icon" aria-hidden="true"><use href="#internal-arrow-drop-down"/></svg>
</button>Tooltips
A tooltip is a short dark label that appears on hover and keyboard focus. Use it to name icon-only buttons and to show keyboard shortcuts. Don't put anything people must read or click in a tooltip: it's hidden on touch screens.
Add data-tooltip with the text to any button or link. The script in the JS tab creates the tooltip, places it on top (or below when there's no room) and keeps it on the screen. Set another side with data-tooltip-position (bottom, left or right), and add a shortcut with data-tooltip-keys. The tooltip is a popover, so it also shows above modal dialogs.
The tooltip repeats the button's name, so keep the button's own label for screen readers (a hidden <span> on icon-only buttons). Tooltips wrap after 250px. The script listens on the whole page, so it also works for buttons your script adds later, and it reads data-tooltip each time, so you can change the text (e.g. from “Cancel” to “Remove”).
Positions
View codeHide code
<div class="d-flex flex-wrap gap-12">
<button type="button" class="btn md secondary" data-tooltip="Tooltip on top"><span>Top</span></button>
<button type="button" class="btn md secondary" data-tooltip="Tooltip below" data-tooltip-position="bottom"><span>Bottom</span></button>
<button type="button" class="btn md secondary" data-tooltip="Tooltip on the left" data-tooltip-position="left"><span>Left</span></button>
<button type="button" class="btn md secondary" data-tooltip="Tooltip on the right" data-tooltip-position="right"><span>Right</span></button>
</div>
.tooltip {
position: fixed;
inset: auto; /* the script sets left and top */
z-index: 1000;
margin: 0;
border: 0;
overflow: visible;
pointer-events: none;
display: flex;
align-items: center;
gap: 8px;
max-width: 250px;
min-height: 36px;
padding: 8px 12px;
border-radius: var(--border-radius-base);
background: var(--tooltip-color);
color: hsl(0 0% 100%);
font-size: var(--text-md);
line-height: 20px;
text-shadow: var(--text-shadow);
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.15);
}
.tooltip kbd {
border-bottom: 0;
background: hsl(0 0% 100% / 0.15);
color: inherit;
text-shadow: none;
}
// Tooltips: [data-tooltip] shows a tooltip on hover and on keyboard focus.
// data-tooltip-position sets the side: top (default), bottom, left or right.
// data-tooltip-keys adds a keyboard shortcut, e.g. data-tooltip-keys="⌘ K".
// The listeners are on the document, so buttons added later (and changed texts) work too.
(() => {
let tip = null;
let current = null;
const gap = 8;
const hide = () => {
tip?.remove();
tip = null;
current = null;
};
const place = (el) => {
const r = el.getBoundingClientRect();
const t = tip.getBoundingClientRect();
const position = el.dataset.tooltipPosition || "top";
let left, top;
if (position === "left" || position === "right") {
left = position === "left" ? r.left - t.width - gap : r.right + gap;
top = r.top + r.height / 2 - t.height / 2;
} else {
left = r.left + r.width / 2 - t.width / 2;
const above = r.top - t.height - gap;
top = position === "bottom" || above < gap ? r.bottom + gap : above;
}
left = Math.min(Math.max(gap, left), innerWidth - t.width - gap);
tip.style.left = left + "px";
tip.style.top = top + "px";
};
const show = (el) => {
hide();
current = el;
tip = document.createElement("div");
tip.className = "tooltip";
tip.setAttribute("role", "tooltip");
// A popover sits in the top layer, so the tooltip also shows above modal dialogs.
tip.popover = "manual";
tip.append(el.dataset.tooltip);
const keys = (el.dataset.tooltipKeys || "").split(" ").filter(Boolean);
if (keys.length) {
const group = document.createElement("span");
group.className = "d-flex gap-4";
keys.forEach((key) => {
const kbd = document.createElement("kbd");
kbd.textContent = key;
group.append(kbd);
});
tip.append(group);
}
document.body.append(tip);
tip.showPopover();
place(el);
};
const target = (e) => e.target.closest?.("[data-tooltip]");
document.addEventListener("mouseover", (e) => {
const el = target(e);
if (el && el !== current) show(el);
});
document.addEventListener("mouseout", (e) => {
if (current && !current.contains(e.relatedTarget)) hide();
});
document.addEventListener("focusin", (e) => {
const el = target(e);
if (el && el.matches(":focus-visible")) show(el);
});
document.addEventListener("focusout", hide);
document.addEventListener("click", hide, true);
document.addEventListener("keydown", (e) => {
if (e.key === "Escape") hide();
});
addEventListener("scroll", hide, true);
})();
Keyboard Shortcuts and Long Text
View codeHide code
<div class="d-flex flex-wrap gap-12">
<button type="button" class="btn md borderless" data-tooltip="Chatty AI" data-tooltip-keys="⌘ K"><span class="visually-hidden">Chatty AI</span><svg class="icon" aria-hidden="true"><use href="#common-chatbot"/></svg></button>
<button type="button" class="btn md borderless" data-tooltip="Tooltip example with a lot of text that doesn't fit on one line."><span class="visually-hidden">More information</span><svg class="icon" aria-hidden="true"><use href="#common-info-outline"/></svg></button>
</div>
.tooltip {
position: fixed;
inset: auto; /* the script sets left and top */
z-index: 1000;
margin: 0;
border: 0;
overflow: visible;
pointer-events: none;
display: flex;
align-items: center;
gap: 8px;
max-width: 250px;
min-height: 36px;
padding: 8px 12px;
border-radius: var(--border-radius-base);
background: var(--tooltip-color);
color: hsl(0 0% 100%);
font-size: var(--text-md);
line-height: 20px;
text-shadow: var(--text-shadow);
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.15);
}
.tooltip kbd {
border-bottom: 0;
background: hsl(0 0% 100% / 0.15);
color: inherit;
text-shadow: none;
}
// Tooltips: [data-tooltip] shows a tooltip on hover and on keyboard focus.
// data-tooltip-position sets the side: top (default), bottom, left or right.
// data-tooltip-keys adds a keyboard shortcut, e.g. data-tooltip-keys="⌘ K".
// The listeners are on the document, so buttons added later (and changed texts) work too.
(() => {
let tip = null;
let current = null;
const gap = 8;
const hide = () => {
tip?.remove();
tip = null;
current = null;
};
const place = (el) => {
const r = el.getBoundingClientRect();
const t = tip.getBoundingClientRect();
const position = el.dataset.tooltipPosition || "top";
let left, top;
if (position === "left" || position === "right") {
left = position === "left" ? r.left - t.width - gap : r.right + gap;
top = r.top + r.height / 2 - t.height / 2;
} else {
left = r.left + r.width / 2 - t.width / 2;
const above = r.top - t.height - gap;
top = position === "bottom" || above < gap ? r.bottom + gap : above;
}
left = Math.min(Math.max(gap, left), innerWidth - t.width - gap);
tip.style.left = left + "px";
tip.style.top = top + "px";
};
const show = (el) => {
hide();
current = el;
tip = document.createElement("div");
tip.className = "tooltip";
tip.setAttribute("role", "tooltip");
// A popover sits in the top layer, so the tooltip also shows above modal dialogs.
tip.popover = "manual";
tip.append(el.dataset.tooltip);
const keys = (el.dataset.tooltipKeys || "").split(" ").filter(Boolean);
if (keys.length) {
const group = document.createElement("span");
group.className = "d-flex gap-4";
keys.forEach((key) => {
const kbd = document.createElement("kbd");
kbd.textContent = key;
group.append(kbd);
});
tip.append(group);
}
document.body.append(tip);
tip.showPopover();
place(el);
};
const target = (e) => e.target.closest?.("[data-tooltip]");
document.addEventListener("mouseover", (e) => {
const el = target(e);
if (el && el !== current) show(el);
});
document.addEventListener("mouseout", (e) => {
if (current && !current.contains(e.relatedTarget)) hide();
});
document.addEventListener("focusin", (e) => {
const el = target(e);
if (el && el.matches(":focus-visible")) show(el);
});
document.addEventListener("focusout", hide);
document.addEventListener("click", hide, true);
document.addEventListener("keydown", (e) => {
if (e.key === "Escape") hide();
});
addEventListener("scroll", hide, true);
})();
Labels
Use labels to show a set of selected items, such as roles, filters or any values picked from a long list. Labels use the theme's label colors (--label-bg-color and --label-text-color), so they follow the tenant theme and dark mode.
Add a remove button when people can take the value off, e.g. a selected role or an applied filter. Give it a hidden label with the value and a “Remove” tooltip (data-tooltip, see Tooltips), and remove the label in your script.
Don't use labels to show a current status or other information: use status labels instead.
View codeHide code
<div class="d-flex flex-wrap gap-8">
<span class="label">First Year Student</span>
<span class="label">First Year Student<button type="button" class="label-remove" data-tooltip="Remove"><span class="visually-hidden">Remove First Year Student</span><svg class="icon" aria-hidden="true"><use href="#internal-close"/></svg></button></span>
</div>
.label {
display: inline-flex;
align-items: center;
height: 28px;
padding: 0 8px;
border-radius: var(--border-radius-base);
background: var(--label-bg-color);
color: var(--label-text-color);
font-size: var(--text-sm);
line-height: 16px;
white-space: nowrap;
}
.label:has(.label-remove) {
padding-right: 0;
}
.label-remove {
display: inline-flex;
padding: 6px;
border: 0;
border-radius: var(--border-radius-base);
background: none;
color: inherit;
cursor: pointer;
}
.label-remove:focus {
outline: none;
}
.label-remove:focus-visible {
box-shadow: 0 0 0 2px var(--focus-outline-color); /* same as .btn.borderless */
}
.label-remove .icon {
width: 16px;
height: 16px;
opacity: 0.6;
}
.label-remove:hover .icon {
opacity: 1;
}
Modal Dialogs
A modal dialog appears on top of the page and blocks it until people close it. Use it for a short task or a confirmation, not for long forms or content people need to compare with the page.
Build it with a native <dialog> and the .custom-dialog class (white card, large rounded corners, shadow and an open animation). showModal() traps focus inside the dialog and closes it on Esc. Put the content in a <form method="dialog">: its submit buttons close the dialog, and the value of the button that closed it is in dialog.returnValue. Add formnovalidate to Close and Cancel, so they work while required fields are empty.
The dialog is 500px wide by default; use style="width: 650px;" or 800px for more content. It never gets wider than the screen minus 16px on each side. Don't center it with transform: its open animation uses it, and the browser centers a modal dialog already.
The dialog never gets taller than the screen minus 16px at the top and bottom. When the content doesn't fit, only the middle scrolls, and the title and the buttons stay in view. For this, the <form> is .d-flex.flex-column.minh-0 and the middle is .scroll-y.minh-0. Its pt-4 and pb-8 leave room for the focus outline of the first and last field, which the scrolling area would cut off. Add the scroll fade script to fade the edges of the middle where content is cut off.
The title is .h2, with the close button in the top right corner; give it a “Close” tooltip (data-tooltip, see Tooltips). The actions go in the bottom right: Cancel (.secondary) first, then the main action (.primary, or .danger when it deletes or can't be undone).
.custom-dialog, but not the native <dialog> element or its backdrop. Add the code from the CSS tab to your page.
Form
Required fields are checked when people press Save; Close and Cancel skip the check.
View codeHide code
<button type="button" class="btn md secondary" data-dialog-open="dialog-edit"><span>Open Dialog</span></button>
<dialog id="dialog-edit" class="custom-dialog" aria-labelledby="dialog-edit-title">
<form method="dialog" class="d-flex flex-column minh-0">
<div class="d-flex align-items-start gap-8 pt-8 pr-8 pl-24 pb-12">
<h2 id="dialog-edit-title" class="h2 flex-grow mt-16">Add Topic</h2>
<button type="submit" value="close" class="btn md borderless" formnovalidate data-tooltip="Close"><span class="visually-hidden">Close</span><svg class="icon" aria-hidden="true"><use href="#internal-close"/></svg></button>
</div>
<div class="scroll-y minh-0 px-24 pt-4 pb-8">
<div class="d-flex flex-column gap-24">
<div>
<label for="topic-name" class="form-label required">Topic name</label>
<input type="text" id="topic-name" class="form-control w-100" autofocus placeholder="E.g. "Withdrawal", "Financial Aid Issues", or "Mental Health"" required>
</div>
<div>
<label for="topic-description" class="form-label required">Topic description</label>
<textarea id="topic-description" class="form-control w-100" rows="4" placeholder="E.g. "Students who seem to be considering dropping out, withdrawing, or taking a leave of absence." Be specific — this description helps the AI identify matching conversations." required></textarea>
</div>
<div class="toggle-container d-flex align-items-center">
<label class="toggle mr-12"><input type="checkbox" id="topic-notify" aria-describedby="topic-notify-help"><span class="toggle-btn"></span></label>
<div class="d-flex flex-column justify-content-center">
<label for="topic-notify">Notify roles</label>
<p class="text-md text-quiet" id="topic-notify-help">Notify selected roles by email when this topic is matched.</p>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-end gap-12 px-24 pt-16 pb-24">
<button type="submit" value="cancel" class="btn md secondary" formnovalidate><span>Cancel</span></button>
<button type="submit" value="save" class="btn md primary"><span>Save</span></button>
</div>
</form>
</dialog>
/* Native <dialog> with the .custom-dialog card style */
dialog.custom-dialog {
width: 500px; /* 500px by default; 650px or 800px for more content */
max-width: calc(100% - 32px);
max-height: calc(100dvh - 32px);
padding: 0;
border: 0;
overflow: auto;
}
/* Column layout, so the middle of the dialog scrolls between the title and the buttons */
dialog.custom-dialog[open] {
display: flex;
flex-direction: column;
}
/* The Pathify stylesheet sets dialog { display: block }, which shows closed dialogs */
dialog.custom-dialog:not([open]) {
display: none;
}
dialog.custom-dialog::backdrop {
background: var(--modal-overlay-color);
}
// Modal dialogs: [data-dialog-open="id"] opens the <dialog> with showModal(), which traps focus
// and closes on Esc. Buttons in its <form method="dialog"> close it; so does a click on the backdrop.
document.querySelectorAll("[data-dialog-open]").forEach((button) => {
const dialog = document.getElementById(button.dataset.dialogOpen);
button.addEventListener("click", () => dialog.showModal());
});
document.querySelectorAll("dialog.custom-dialog").forEach((dialog) => {
dialog.addEventListener("click", (e) => {
if (e.target === dialog) dialog.close();
});
});
Destructive
Ask a question in the title, say what happens in the text, and name the action on the button (“Yes, Expire”, not “OK”).
View codeHide code
<button type="button" class="btn md secondary" data-dialog-open="dialog-destructive"><span>Open Dialog</span></button>
<dialog id="dialog-destructive" class="custom-dialog" aria-labelledby="dialog-destructive-title">
<form method="dialog" class="d-flex flex-column minh-0">
<div class="d-flex align-items-start gap-8 pt-8 pr-8 pl-24 pb-12">
<h2 id="dialog-destructive-title" class="h2 flex-grow mt-16">Expire Announcement?</h2>
<button type="submit" value="close" class="btn md borderless" formnovalidate data-tooltip="Close"><span class="visually-hidden">Close</span><svg class="icon" aria-hidden="true"><use href="#internal-close"/></svg></button>
</div>
<div class="scroll-y minh-0 px-24 pt-4 pb-8">
<p>This can't be undone. Are you sure? You will still be able to view the expired announcement in this list.</p>
</div>
<div class="d-flex justify-content-end gap-12 px-24 pt-16 pb-24">
<button type="submit" value="cancel" class="btn md secondary" formnovalidate><span>Cancel</span></button>
<button type="submit" value="expire" class="btn md danger"><span>Yes, Expire</span></button>
</div>
</form>
</dialog>
/* Native <dialog> with the .custom-dialog card style */
dialog.custom-dialog {
width: 500px; /* 500px by default; 650px or 800px for more content */
max-width: calc(100% - 32px);
max-height: calc(100dvh - 32px);
padding: 0;
border: 0;
overflow: auto;
}
/* Column layout, so the middle of the dialog scrolls between the title and the buttons */
dialog.custom-dialog[open] {
display: flex;
flex-direction: column;
}
/* The Pathify stylesheet sets dialog { display: block }, which shows closed dialogs */
dialog.custom-dialog:not([open]) {
display: none;
}
dialog.custom-dialog::backdrop {
background: var(--modal-overlay-color);
}
// Modal dialogs: [data-dialog-open="id"] opens the <dialog> with showModal(), which traps focus
// and closes on Esc. Buttons in its <form method="dialog"> close it; so does a click on the backdrop.
document.querySelectorAll("[data-dialog-open]").forEach((button) => {
const dialog = document.getElementById(button.dataset.dialogOpen);
button.addEventListener("click", () => dialog.showModal());
});
document.querySelectorAll("dialog.custom-dialog").forEach((dialog) => {
dialog.addEventListener("click", (e) => {
if (e.target === dialog) dialog.close();
});
});
Empty State
An empty state fills a list, table or card that has no content yet, so the space doesn't look broken. Say what's missing in the title and why in the text, and add a button when people can add the first item.
Center everything in a column with .d-flex.flex-column.align-items-center.gap-12.pa-40.text-center. The icon is 80px (.size-80) in the muted color (.text-muted); the title (.h3) and text use the quiet text color (.text-quiet on the container). The button is optional; use a second, .secondary one only if there are two equally common ways to start.
No Posts
There are no posts in this group yet.
View codeHide code
<div class="d-flex flex-column align-items-center gap-12 pa-40 text-center text-quiet">
<svg class="icon size-80 text-muted" aria-hidden="true"><use href="#common-posts"/></svg>
<div class="pb-8">
<h3 class="h3 mb-4">No Posts</h3>
<p>There are no posts in this group yet.</p>
</div>
<button type="button" class="btn md primary"><svg class="icon" aria-hidden="true"><use href="#internal-add"/></svg><span>New Post</span></button>
</div>Tables
Use table.table for rows of data. It sets 14px text, 16px cell padding with 24px at the row ends, and a border under each row. Add .table-hoverable to highlight the row under the pointer. Cells with a checkbox or buttons get .has-component (8px vertical padding), so those rows aren't taller than text rows.
Wrap the table in .table-responsive.pos-rel: on narrow screens it scrolls sideways instead of squeezing the columns, and pos-rel keeps elements positioned inside the table (such as menus) from escaping the scroll area on phones. Use .text-nowrap on dates and short values that shouldn't break.
Table with Bulk Actions
A checkbox at the start of each row selects it; the one in the header selects all rows. While rows are selected, a bar above the table shows how many and the actions for them. The script in the JS tab updates the count, highlights selected rows with .bg-n1, and hides the bar when nothing is selected. Each checkbox and icon-only button has a hidden label with the row name.
2 Selected
| Name | Created | Status | Actions | |
|---|---|---|---|---|
| Lorem Ipsum | Sep 12, 2020 at 2:44 PM | Rejected | ||
| Dolor Sit Amet | Oct 5, 2021 at 11:20 AM | Approved | ||
| Consectetur Adipiscing | Nov 14, 2022 at 9:15 AM | Approved | ||
| Elit Sed Do | Jan 3, 2023 at 4:50 PM | Scheduled | ||
| Eiusmod Tempor | Feb 20, 2021 at 8:30 AM | Approved |
View codeHide code
<div class="ba rounded-double overflow-hidden bg-white" data-bulk-table>
<div class="d-flex align-items-center gap-12 px-24 py-8" data-bulk-bar>
<p class="text-md text-bold" aria-live="polite" data-bulk-count>2 Selected</p>
<span class="bl" style="height: 20px;" aria-hidden="true"></span>
<div class="d-flex flex-wrap gap-8">
<button type="button" class="btn sm secondary"><svg class="icon" aria-hidden="true"><use href="#internal-delete"/></svg><span>Delete</span></button>
<button type="button" class="btn sm secondary btn-dropdown" aria-haspopup="menu" aria-expanded="false"><span>Bulk Actions</span><svg class="icon" aria-hidden="true"><use href="#internal-arrow-drop-down"/></svg></button>
</div>
</div>
<div class="table-responsive pos-rel">
<table class="table table-hoverable">
<thead>
<tr>
<th class="has-component" style="width: 1%;"><label class="form-checkbox"><input type="checkbox"><span class="checkbox"></span><span class="visually-hidden">Select all rows</span></label></th>
<th class="text-left">Name</th>
<th class="text-left">Created</th>
<th class="text-left">Status</th>
<th class="text-right">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td class="has-component"><label class="form-checkbox"><input type="checkbox"><span class="checkbox"></span><span class="visually-hidden">Select Lorem Ipsum</span></label></td>
<td class="text-nowrap">Lorem Ipsum</td>
<td class="text-nowrap">Sep 12, 2020 at 2:44 PM</td>
<td><span class="d-flex align-items-center gap-8 text-nowrap text-red"><svg class="icon size-20" aria-hidden="true"><use href="#common-cancel"/></svg>Rejected</span></td>
<td class="has-component text-right text-nowrap">
<button type="button" class="btn sm borderless"><span class="visually-hidden">Edit Lorem Ipsum</span><svg class="icon" aria-hidden="true"><use href="#internal-edit"/></svg></button>
<button type="button" class="btn sm borderless" aria-haspopup="menu" aria-expanded="false"><span class="visually-hidden">More actions for Lorem Ipsum</span><svg class="icon" aria-hidden="true"><use href="#internal-more"/></svg></button>
</td>
</tr>
<tr>
<td class="has-component"><label class="form-checkbox"><input type="checkbox"><span class="checkbox"></span><span class="visually-hidden">Select Dolor Sit Amet</span></label></td>
<td class="text-nowrap">Dolor Sit Amet</td>
<td class="text-nowrap">Oct 5, 2021 at 11:20 AM</td>
<td><span class="d-flex align-items-center gap-8 text-nowrap text-green"><svg class="icon size-20" aria-hidden="true"><use href="#common-check-circle"/></svg>Approved</span></td>
<td class="has-component text-right text-nowrap">
<button type="button" class="btn sm borderless"><span class="visually-hidden">Edit Dolor Sit Amet</span><svg class="icon" aria-hidden="true"><use href="#internal-edit"/></svg></button>
<button type="button" class="btn sm borderless" aria-haspopup="menu" aria-expanded="false"><span class="visually-hidden">More actions for Dolor Sit Amet</span><svg class="icon" aria-hidden="true"><use href="#internal-more"/></svg></button>
</td>
</tr>
<tr>
<td class="has-component"><label class="form-checkbox"><input type="checkbox" checked><span class="checkbox"></span><span class="visually-hidden">Select Consectetur Adipiscing</span></label></td>
<td class="text-nowrap">Consectetur Adipiscing</td>
<td class="text-nowrap">Nov 14, 2022 at 9:15 AM</td>
<td><span class="d-flex align-items-center gap-8 text-nowrap text-green"><svg class="icon size-20" aria-hidden="true"><use href="#common-check-circle"/></svg>Approved</span></td>
<td class="has-component text-right text-nowrap">
<button type="button" class="btn sm borderless"><span class="visually-hidden">Edit Consectetur Adipiscing</span><svg class="icon" aria-hidden="true"><use href="#internal-edit"/></svg></button>
<button type="button" class="btn sm borderless" aria-haspopup="menu" aria-expanded="false"><span class="visually-hidden">More actions for Consectetur Adipiscing</span><svg class="icon" aria-hidden="true"><use href="#internal-more"/></svg></button>
</td>
</tr>
<tr>
<td class="has-component"><label class="form-checkbox"><input type="checkbox"><span class="checkbox"></span><span class="visually-hidden">Select Elit Sed Do</span></label></td>
<td class="text-nowrap">Elit Sed Do</td>
<td class="text-nowrap">Jan 3, 2023 at 4:50 PM</td>
<td><span class="d-flex align-items-center gap-8 text-nowrap"><svg class="icon size-20" aria-hidden="true"><use href="#common-history"/></svg>Scheduled</span></td>
<td class="has-component text-right text-nowrap">
<button type="button" class="btn sm borderless"><span class="visually-hidden">Edit Elit Sed Do</span><svg class="icon" aria-hidden="true"><use href="#internal-edit"/></svg></button>
<button type="button" class="btn sm borderless" aria-haspopup="menu" aria-expanded="false"><span class="visually-hidden">More actions for Elit Sed Do</span><svg class="icon" aria-hidden="true"><use href="#internal-more"/></svg></button>
</td>
</tr>
<tr>
<td class="has-component"><label class="form-checkbox"><input type="checkbox" checked><span class="checkbox"></span><span class="visually-hidden">Select Eiusmod Tempor</span></label></td>
<td class="text-nowrap">Eiusmod Tempor</td>
<td class="text-nowrap">Feb 20, 2021 at 8:30 AM</td>
<td><span class="d-flex align-items-center gap-8 text-nowrap text-green"><svg class="icon size-20" aria-hidden="true"><use href="#common-check-circle"/></svg>Approved</span></td>
<td class="has-component text-right text-nowrap">
<button type="button" class="btn sm borderless"><span class="visually-hidden">Edit Eiusmod Tempor</span><svg class="icon" aria-hidden="true"><use href="#internal-edit"/></svg></button>
<button type="button" class="btn sm borderless" aria-haspopup="menu" aria-expanded="false"><span class="visually-hidden">More actions for Eiusmod Tempor</span><svg class="icon" aria-hidden="true"><use href="#internal-more"/></svg></button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
// Table with bulk actions ([data-bulk-table]): the checkbox in the header selects all rows.
// The bulk actions bar shows how many rows are selected and is hidden when none are.
document.querySelectorAll("[data-bulk-table]").forEach((table) => {
const all = table.querySelector("thead input[type=checkbox]");
const rows = [...table.querySelectorAll("tbody input[type=checkbox]")];
const bar = table.querySelector("[data-bulk-bar]");
const count = table.querySelector("[data-bulk-count]");
const update = () => {
const selected = rows.filter((row) => row.checked).length;
rows.forEach((row) => row.closest("tr").classList.toggle("bg-n1", row.checked));
all.checked = selected === rows.length;
all.indeterminate = selected > 0 && selected < rows.length;
count.textContent = `${selected} Selected`;
bar.classList.toggle("hidden", selected === 0);
};
all.addEventListener("change", () => {
rows.forEach((row) => (row.checked = all.checked));
update();
});
rows.forEach((row) => row.addEventListener("change", update));
update();
});