Skip to content

Handsontable DataGrid with Tabler Icons

This tutorial shows you how to swap all of Handsontable DataGrid’s built-in icons for the Tabler Icons webfont. You register a theme, map each icon slot to a Tabler class list, and pass the theme to the grid as an object.

TypeScript
/* file: app.component.ts */
import { Component } from '@angular/core';
import { GridSettings, HotTableModule } from '@handsontable/angular-wrapper';
import { registerAllModules } from 'handsontable/registry';
import { mainTheme, registerTheme } from 'handsontable/themes';
// Register all Handsontable's modules.
registerAllModules();
/* start:skip-in-preview */
// In your project, install `@tabler/icons-webfont` and import its stylesheet instead.
const tablerCss = document.createElement('link');
tablerCss.rel = 'stylesheet';
tablerCss.href = 'https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.31.0/dist/tabler-icons.min.css';
document.head.appendChild(tablerCss);
/* end:skip-in-preview */
// Every icon slot the grid renders, mapped to a Tabler Icons class list.
const tablerTheme = registerTheme(mainTheme);
tablerTheme.params({
icons: {
arrowRight: 'ti ti-chevron-right',
arrowRightWithBar: 'ti ti-chevron-right-pipe',
arrowLeft: 'ti ti-chevron-left',
arrowLeftWithBar: 'ti ti-chevron-left-pipe',
arrowDown: 'ti ti-chevron-down',
menu: 'ti ti-menu-2',
selectArrow: 'ti ti-caret-down-filled',
arrowNarrowUp: 'ti ti-arrow-narrow-up',
arrowNarrowDown: 'ti ti-arrow-narrow-down',
check: 'ti ti-check',
checkbox: 'ti ti-check',
caretHiddenLeft: 'ti ti-caret-left-filled',
caretHiddenRight: 'ti ti-caret-right-filled',
caretHiddenUp: 'ti ti-caret-up-filled',
caretHiddenDown: 'ti ti-caret-down-filled',
collapseOff: 'ti ti-minus',
collapseOn: 'ti ti-plus',
radio: 'ti ti-point-filled',
chipClose: 'ti ti-x',
search: 'ti ti-search',
plus: 'ti ti-plus',
menuList: 'ti ti-list',
},
});
@Component({
selector: 'example1-tabler-icons',
standalone: true,
imports: [HotTableModule],
template: ` <div>
<hot-table [data]="data" [settings]="gridSettings"></hot-table>
</div>`,
})
export class AppComponent {
readonly data = [
{ product: 'Standing desk', category: 'Furniture', inStock: true, units: 24 },
{ product: 'Monitor arm', category: 'Accessories', inStock: true, units: 61 },
{ product: 'Ergonomic chair', category: 'Furniture', inStock: false, units: 0 },
{ product: 'USB-C dock', category: 'Electronics', inStock: true, units: 138 },
{ product: 'Desk lamp', category: 'Lighting', inStock: true, units: 45 },
{ product: 'Cable tray', category: 'Accessories', inStock: false, units: 0 },
];
readonly gridSettings: GridSettings = {
// The mapping applies only when the theme is passed as an object.
theme: tablerTheme,
columns: [
{ data: 'product' },
{ data: 'category', type: 'dropdown', source: ['Furniture', 'Accessories', 'Electronics', 'Lighting'] },
{ data: 'inStock', type: 'checkbox' },
{ data: 'units', type: 'numeric' },
],
colHeaders: ['Product', 'Category', 'In stock', 'Units'],
rowHeaders: true,
columnSorting: true,
dropdownMenu: true,
filters: true,
// The hidden Units column puts a caret on the In stock header.
hiddenColumns: { columns: [3], indicators: true },
height: 260,
// licenseKey: 'your-license-key', // get a key at https://handsontable.com/pricing/
};
}
/* end-file */
/* file: app.config.ts */
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { registerAllModules } from 'handsontable/registry';
import { HOT_GLOBAL_CONFIG, HotGlobalConfig } from '@handsontable/angular-wrapper';
// Register Handsontable's modules.
registerAllModules();
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
{
provide: HOT_GLOBAL_CONFIG,
useValue: {
// license: 'your-license-key', // get a key at https://handsontable.com/pricing/
} as HotGlobalConfig,
},
],
};
/* end-file */
HTML
<div>
<example1-tabler-icons></example1-tabler-icons>
</div>

Overview

Every icon in the grid is an <i class="ht-icon ht-icon-<name>"> element painted from a CSS mask. The theme icons parameter lets you replace that mask with something else per icon slot. For an icon font, the value is a class list: Handsontable adds the classes to the element together with ht-icon--external, which turns off the built-in mask and sizes the font glyph to the theme’s icon size. The font’s own stylesheet then draws the glyph.

Tabler Icons ships a webfont whose classes follow the ti ti-<icon-name> pattern, so a mapping is one string per slot.

Difficulty: Beginner
Time: ~10 minutes
Stack: Handsontable, @tabler/icons-webfont

Prerequisites

  • Handsontable 19.0 or later. Earlier versions draw icons as CSS pseudo-elements, which the icons parameter cannot replace.
  • A build that lets you pass the theme as an object through the theme option. See Requires a theme object below.
  1. Install the Tabler webfont

    Terminal window
    npm install @tabler/icons-webfont

    Import the stylesheet once, before the grid renders:

    import '@tabler/icons-webfont/dist/tabler-icons.min.css';

    The live example above adds the same stylesheet from a CDN with a <link> element, so it runs without a build step. In your project, prefer the npm import.

  2. Register a theme and map the icon slots

    Start from a built-in theme and pass an icons object to params(). Each key is an icon slot, and each value is the Tabler class list for that slot:

    import { mainTheme, registerTheme } from 'handsontable/themes';
    const tablerTheme = registerTheme(mainTheme);
    tablerTheme.params({
    icons: {
    menu: 'ti ti-menu-2',
    selectArrow: 'ti ti-caret-down-filled',
    check: 'ti ti-check',
    // one entry per slot, see the table below
    },
    });

    Slots you leave out keep their built-in glyph, so you can migrate one icon at a time.

  3. Pass the theme as an object

    new Handsontable(container, {
    theme: tablerTheme,
    // other options
    });

    With the Angular wrapper, set theme inside gridSettings.

    The theme must be an object

    A class-list mapping runs in JavaScript when the grid builds each icon element. That only happens when the grid receives the theme through the theme option as a configuration object. Putting a ht-theme-main class on the container element, or passing a themeName string, applies the theme through the stylesheet alone, and the icons mapping does nothing. There is no warning.

  4. Check the icons in context

    The example hides the Units column (hiddenColumns: { columns: [3], indicators: true }), so the In stock header shows the hidden-column caret. Its box is a fixed 10px, smaller than the icon size every other slot uses, and the grid sizes a font glyph in it to match, so no extra CSS is needed. Sort a column, open a header menu, or open the Category dropdown to see the other slots.

    Tabler glyphs paint with currentColor, so every state color the theme defines (hover, checked, disabled, active header) applies to them unchanged.

Icon slot reference

SlotWhere it rendersTabler class list
arrowRightSubmenu arrow, pagination nextti ti-chevron-right
arrowRightWithBarPagination last pageti ti-chevron-right-pipe
arrowLeftPagination previous, sheets barti ti-chevron-left
arrowLeftWithBarPagination first pageti ti-chevron-left-pipe
arrowDownPagination page-size selectti ti-chevron-down
menuColumn header menu buttonti ti-menu-2
selectArrowAutocomplete, dropdown, and select arrows, filters condition select, sheets bar tab menuti ti-caret-down-filled
arrowNarrowUpAscending sort indicatorti ti-arrow-narrow-up
arrowNarrowDownDescending sort indicatorti ti-arrow-narrow-down
checkMenu item check markti ti-check
checkboxCheckbox cell tick, multi-select list tickti ti-check
caretHiddenLeftHidden column, on the header before the gapti ti-caret-left-filled
caretHiddenRightHidden column, on the header after the gapti ti-caret-right-filled
caretHiddenUpHidden row, on the header above the gapti ti-caret-up-filled
caretHiddenDownHidden row, on the header below the gapti ti-caret-down-filled
collapseOffExpanded group header, expanded nested row, mixed menu itemti ti-minus
collapseOnCollapsed group header, collapsed nested rowti ti-plus
radioFilters condition radio dotti ti-point-filled
chipCloseMulti-select chip remove, notification closeti ti-x
searchMulti-select editor searchti ti-search
plusSheets bar add sheetti ti-plus
menuListSheets bar all sheetsti ti-list

Pagination arrows, the submenu arrow, and the sheets bar arrows mirror in a right-to-left layout on their own, so the left and right slots take the physical left and right glyphs.

Limitations

  • Runtime theme changes. A remapped icon reaches every slot without re-creating the grid, but not at the same moment: pagination, the sheets bar, and notifications update their icons in place at once, the header menu button on the next header render, the filters select and radio on the next menu open, and the select editor arrow on the next editor open.
  • Class-based theming. As described in Step 3, a class on the container or a themeName string ignores the icons mapping.
  • Glyph metrics. Tabler glyphs are drawn on a 24px grid with a 2px stroke. At the default 16px icon size they read slightly lighter than the built-in set. Raise --ht-icon-size or pick a heavier Tabler variant if that matters for your design.