Skip to content

Sidebar Icons from lucide-react Geometry, Extracted at Build Time

Adityo Guni Waluyo

Twenty-seven manual sidebar icons drawn from real lucide-react geometry extracted at build time: inline SVG, zero runtime, theme-aware color.

TL;DR

The article explains how Lucide icons are geometry data tuples rather than images, letting a static manual generator extract and inline them as SVGs without React dependencies. By reading directly from lucide-react at build time and wrapping tuples in a standard SVG shell, the manual gets identical icons with currentColor theming and zero runtime overhead. A fallback bucket ensures no navigation links disappear silently when the source layout changes.

The generator output opened in the browser. In that static manual's sidebar, twenty-seven icons lined up: map-pin for the tourism module, landmark for culture, trophy for sports. All of them match the real admin panel's navigation, down to the group order. The file is plain HTML, opened straight through file://, without a single line of runtime JavaScript.

My first guess: an icon font. Or unicode glyphs. Or bundling lucide-react into the static artifact, which would mean dragging React along just for icons on a page that needs no interactivity. All three felt excessive for a manual that is mostly text and links.

Then I opened node_modules/lucide-react and found what was actually needed: icons in there are not image assets. They are data.

Icons are data, not a component

lucide-react is indeed an icon library package for React applications [4], but the basic form of a Lucide icon is a geometry tuple [tagName, attributes] — "SVG child nodes as [tagName, attributes] tuples" in the data documentation [2]. Paths, circles, polylines, each with its attributes. React is only the runtime wrapper; for a static artifact, the wrapper does not need to come along.

There are no images to export and no font to load. All that is left is wrapping those tuples in the Lucide default SVG shell: viewBox 24, fill none, stroke currentColor, stroke-width 2, round caps and joins [2].

The color resolves itself. currentColor represents the computed value of an element's color property, and an icon inherits its color from its parent element [3]. Lucide is designed that way: "By default, all icons have the color value: currentColor" [1]. Nothing is hardcoded, so a dark or light theme only has to set the text color.

Extract at build time

The manual generator reads those geometry tuples straight from the frontend's own lucide-react at build time, wraps them in the shell above through an ico() emitter, and flushes them into the sidebar as inline SVG inside a 15px CSS box that follows the theme tokens. This is a deliberate choice. Lucide itself offers an official framework-free route through the lucide-static package: individual SVG files, sprites, even SVG strings for server-side rendering [5]. Reading the geometry from the frontend's node_modules keeps the manual and the admin panel on one shared icon contract.

function iconSvg(nodes) {
  const children = nodes
    .map(([tag, attrs]) => `<${tag} ${Object.entries(attrs)
      .map(([k, v]) => `${k}="${v}"`).join(" ")}/>`)
    .join("");
  return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
    fill="none" stroke="currentColor" stroke-width="2"
    stroke-linecap="round" stroke-linejoin="round"
    aria-hidden="true">${children}</svg>`;
}

One gotcha worth noting: the module name is not always the icon name. When I checked in early November 2026, history.mjs in lucide-react turned out to be an alias, and the geometry lives in rotate-ccw-clock. A name-keyed icon map like SIDE_ICONS has to actually land on the module carrying the tuples.

The same discipline applies to the structure. The manual sidebar is grouped through a NAV_SECTIONS constant, following the admin panel's nav order: Utama, Modul Bidang, Konten & Layanan, Master Modul, Administrasi, with the manual index and official documents on top. A filter in sidebarHtml() sends any manifest group not registered in the section map to a "Lainnya" (Others) bucket. No link disappears silently.

const NAV_SECTIONS = [
  ["Utama", ["dashboard", "login", "hero-slider", "halaman"]],
  ["Modul Bidang", ["wisata", "budaya", "olahraga", "organisasi", "ekraf"]],
  ["Administrasi", ["users", "audit", "settings"]],
];
const listed = new Set(NAV_SECTIONS.flatMap(([, names]) => names));
const rest = manifestGroups.filter((g) => !listed.has(g)); // lands in "Lainnya"

The rule is explicit and intentional: the icon map and the section map must follow changes in the source layout.tsx. The generator reads constants, it does not parse the nav file, so manual synchronization is the price of being explicit — safer than brittle parsing. The effect goes beyond looks: the manual teaches the same mental map of the panel that its admins use every day, and the fallback bucket makes sure a new module that has not been grouped yet still has a place instead of vanishing without notice.

The end result: one static HTML page carrying twenty-seven icons identical to the real panel, theme colors following tokens through currentColor, and zero runtime dependencies added to the manual artifact. lucide-react remains the frontend's business; the manual itself needs nothing but the geometry already frozen into its markup.

Sources

  1. Lucide docs, Color (React)
  2. Lucide docs, @lucide/icons icon data
  3. MDN Web Docs, <color> CSS type (currentColor)
  4. npm, lucide-react
  5. Lucide docs, Static assets

Related articles