Skip to content

Tooltip Plugin

The Tooltip plugin shows popover tooltips when header or cell text overflows its container. It uses the Popover API with CSS anchor positioning for a native, consistent experience across browsers — with a JavaScript fallback for older browsers.

Tooltips appear automatically on hover. Per-column overrides let you provide custom static text or dynamic content derived from row data.

import '@toolbox-web/grid/features/tooltip';
import { queryGrid } from '@toolbox-web/grid';
import '@toolbox-web/grid/features/tooltip';
const grid = queryGrid('tbw-grid');
grid.gridConfig = {
columns: [
{ field: 'id', header: 'ID', width: 60 },
{ field: 'name', header: 'Name' },
{ field: 'email', header: 'Email Address' },
{ field: 'department', header: 'Department / Division' },
],
features: { tooltip: true },
};

Hover over truncated column headers or cell values to see tooltips. Toggle header/cell tooltips with the controls. The Job Title column demonstrates a custom headerTooltip string and a dynamic cellTooltip function.

Header tooltips Show tooltips when header text overflows
Cell tooltips Show tooltips when cell text overflows
OptionTypeDefaultDescription
headerbooleantrueEnable automatic tooltips on overflowing header text
cellbooleantrueEnable automatic tooltips on overflowing cell text

Override tooltip behavior on individual columns with headerTooltip and cellTooltip:

const columns = [
// Static header tooltip
{ field: 'revenue', header: 'Rev.', headerTooltip: 'Total revenue in USD (before tax)' },
// Dynamic cell tooltip that adds context beyond the cell value
{ field: 'name', cellTooltip: (ctx) => `Hired ${new Date(ctx.row.hireDate).toLocaleDateString()}` },
// Disable tooltip for a specific column
{ field: 'actions', cellTooltip: false, headerTooltip: false },
];
PropertyTypeDescription
headerTooltipfalse | string | (ctx) => string | nullOverride header tooltip. false disables it, a string sets static text, a function returns dynamic text (return null to suppress).
cellTooltipfalse | string | (ctx) => string | nullOverride cell tooltip. Same signature as headerTooltip. The callback receives { value, row, field, column }.

The tooltip popover includes a directional arrow that automatically flips when the tooltip appears above the cell. It supports CSS custom properties:

PropertyDefaultDescription
--tbw-tooltip-bgvar(--tbw-color-panel-bg)Tooltip background color
--tbw-tooltip-fgvar(--tbw-color-panel-fg)Tooltip text color
--tbw-tooltip-bordervar(--tbw-color-border)Tooltip border and arrow color
--tbw-tooltip-shadow0 2px 8px rgba(0,0,0,.15)Tooltip box shadow
--tbw-tooltip-radiusvar(--tbw-border-radius)Border radius
--tbw-tooltip-arrow-offset12pxHorizontal offset of the arrow from the left edge
tbw-grid {
--tbw-tooltip-bg: #1e1e2e;
--tbw-tooltip-fg: #cdd6f4;
--tbw-tooltip-border: #45475a;
}
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt