Charts & Plugins

Charts, maps, the datatable, the rich-text editor and the advanced form inputs are optional add-ons. Each is a thin client component that loads its library on demand via dynamic import(), so nothing heavy ships unless you actually render it. Install the matching peer package and its CSS once.

Install the libraries you use

ComponentInstallCSS to load once
Chart / SparklineChartnpm i chart.jsnone — Chart.js needs no stylesheet
WorldMapnpm i jsvectormapjsvectormap/dist/jsvectormap.css
Datatablenpm i tabulator-tablestabulator_bootstrap5.min.css
Editornpm i quillquill/dist/quill.snow.css
InputFlatpickrnpm i flatpickrflatpickr/dist/flatpickr.min.css
InputTomSelectnpm i tom-selecttom-select.bootstrap5.min.css

Charts (Chart.js)

Charts use Chart.js 4 (MIT). Chart replaces ApexChart and takes a Chart.js type, data and options, plus optional plugins, height (number = pixels, default 300), ariaLabel, fallback (content inside the <canvas>), id, className and style. It loads chart.js/auto on mount, updates in place when data or options change, resizes with its container and destroys the chart on unmount:

import { Chart } from '@adminlte/react'

export function RevenueChart() {
  return (
    <Chart
      id="revenue-chart"
      type="line"
      height={300}
      ariaLabel="Monthly revenue"
      data={{
        labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
        datasets: [
          { label: 'Revenue', data: [31, 40, 28, 51, 42, 109, 100], borderColor: '#0d6efd', fill: 'origin' },
        ],
      }}
      options={{ plugins: { legend: { display: false } } }}
    />
  )
}

data and options are plain values, so a Server Component can pass them. Options that contain functions (tooltip callbacks, tick formatters) have to be built in a 'use client' component. An area chart is type="line" with a dataset fill; use "bar" (add options.indexAxis: 'y' for horizontal), "doughnut", "pie", "radar" or "polarArea" for the other types.

For inline trend lines, SparklineChart needs only an id and a data: number[]; optional color (default #DCE6EC), type ('line' area or 'bar'), height (default 50) and ariaLabel:

<SparklineChart id="sales-spark" data={[25, 66, 41, 89, 63, 25, 44]} color="#0d6efd" />

Theme preset and dark mode

Chart applies the AdminLTE preset, applyChartTheme(Chart), before it draws. The preset writes Chart.defaults from Bootstrap's CSS variables (--bs-body-font-family, --bs-body-color, --bs-secondary-color, --bs-border-color-translucent, --bs-body-bg, --bs-emphasis-color): horizontal gridlines only, rounded bars, smooth lines, point-style legends and Bootstrap-style tooltips. A filled line dataset without its own backgroundColor gets a gradient of its line colour. Mounted charts re-render when <html data-bs-theme> or <html dir> changes, so the colour-mode toggle and RTL restyle them immediately. Your options are merged over the preset.

If you create Chart.js charts yourself, outside the component, apply the same preset. readChartThemeColors() and withAlpha(color, alpha) are exported too:

'use client'
import Chart from 'chart.js/auto'
import { applyChartTheme } from '@adminlte/react'

applyChartTheme(Chart)

Chart.js plugins

Pass plugins for one chart through the plugins prop (a Chart.js Plugin[]), or register a plugin globally once with Chart.register() from chart.js. A plugin that takes callbacks has to be passed from a 'use client' component:

'use client'
import type { Plugin } from 'chart.js'
import { Chart } from '@adminlte/react'

const centerText: Plugin<'doughnut'> = {
  id: 'centerText',
  afterDraw(chart) {
    const { ctx, chartArea } = chart
    ctx.save()
    ctx.textAlign = 'center'
    ctx.fillText('72%', (chartArea.left + chartArea.right) / 2, (chartArea.top + chartArea.bottom) / 2)
    ctx.restore()
  },
}

export function Usage() {
  return (
    <Chart
      type="doughnut"
      plugins={[centerText]}
      data={{ labels: ['Used', 'Free'], datasets: [{ data: [72, 28] }] }}
    />
  )
}

WorldMap (jsVectorMap)

import { WorldMap } from '@adminlte/react'

<WorldMap id="visitors-map" height={300} />

The component dynamically imports jsvectormap and its world map data, renders into a sized container, and tears down on unmount.

Datatable (Tabulator)

import { Datatable } from '@adminlte/react'

<Datatable
  columns={[
    { title: 'Name', field: 'name' },
    { title: 'Email', field: 'email' },
    { title: 'Age', field: 'age', sorter: 'number' },
  ]}
  data={[{ name: 'Ann', email: 'ann@x.io', age: 31 }]}
/>

Pass apiUrl instead of data for progressive ajax loading, or tabulatorOptions for any other Tabulator option.

Form plugins

import { InputFlatpickr, InputTomSelect } from '@adminlte/react'

<InputFlatpickr name="due" label="Due date" dateType="date" />

<InputTomSelect
  name="tags"
  label="Tags"
  multiple
  options={[{ value: 'a', label: 'Alpha' }, { value: 'b', label: 'Beta' }]}
/>

InputFlatpickr supports dateType of text | date | time | datetime plus a raw options object; InputTomSelect accepts options, native multiple, and a tomSelectOptions escape hatch.

These components are 'use client' and import their libraries at runtime, so they only run in the browser — render them inside the dashboard, not in a Server Component's static output. Remember to load each plugin's CSS once (in your root layout or a CSS import); the JS comes in automatically via the dynamic import.


AdminLTE 4 · React port Edit on GitHub