Icons

Components•5 min read|
|

Icons are resolved when you build, not when a reader loads the page. DocsLit looks each icon up in two bundled libraries, Lucide and Font Awesome Free 6, and writes the SVG straight into the page. There is no CDN request at view time, no flash of missing icons, and every icon works in an offline build opened from disk.

Ways to write an icon

The same value works in wc-icon and in the icon attribute of every component that has one.

You write You get Example
A bare name The Lucide or Font Awesome icon with that name rocket
Font Awesome classes A specific Font Awesome style fa-solid fa-gear, fa-regular fa-star, fa-brands fa-github
A library prefix A specific library lucide:zap, fa:zap
An emoji The emoji as text 🚀
An image path or URL The image, for example an SVG or PNG img/mark.svg, https://example.com/logo.svg
Inline <svg> Your own SVG, with scripts and event handlers removed <svg viewBox="0 0 24 24">…</svg>

Image icons are sized to the icon box of the component, or to size on wc-icon, so an SVG or PNG fits wherever a named icon would.

Here they are, live:

rocket · github · fa-solid fa-gear · fa-regular fa-star · fa-brands fa-docker · lucide:zap · 🚀 🚀

<wc-icon name="rocket"></wc-icon> <wc-icon name="fa-solid fa-gear"></wc-icon> <wc-icon name="lucide:zap"></wc-icon> <wc-icon name="🚀"></wc-icon>

Font Awesome names and styles

Font Awesome icons are in three styles: solid, regular and brands. A bare name picks the first style that has it, and brand names such as github and docker find the brands set. To choose a style, use classes (fa-regular fa-star, or the short forms fas, far and fab), or set icon-type next to a bare name:

<wc-icon name="star" icon-type="regular"></wc-icon> <wc-icon name="fa-brands fa-github" size="20"></wc-icon>

Pro-only styles (fa-light, fa-thin, fa-duotone, fa-sharp) are not bundled, and they fall back to the free solid icon of the same name. Size and animation classes such as fa-lg and fa-spin are ignored. Use size and color instead.

Choose which library wins

A bare name can exist in both libraries. The icons.library setting in docslit.json decides which one is tried first:

{ "icons": { "library": "lucide" } }
library Bare names are looked up
auto (default) The original DocsLit names (check, x, info, search, star, zap, book, settings and 25 more) in Lucide first, so existing sites look the same. Every other name in Font Awesome first, then Lucide.
fontawesome In Font Awesome first, then Lucide.
lucide In Lucide first, then Font Awesome.

A prefix or Font Awesome classes always override the setting. The importer writes fontawesome for Mintlify sites that use it.

Where you can use icons

  • Components: wc-icon, wc-callout, wc-banner, wc-badge, wc-accordion, wc-expandable, wc-card, wc-tile, wc-button (icon and right-icon), wc-tab, wc-view-panel, wc-step, wc-prompt, wc-panel and code blocks (icon=).
  • Navigation: sidebar groups and pages, tabs and anchors, navbar links and buttons, and custom contextual menu options.
  • Frontmatter: the icon key, which sets the sidebar icon of the page.

Components take an icon-type attribute (solid, regular or brands) for bare Font Awesome names.

<wc-card title="Fast builds" icon="zap" href="/0.3/deployment/static-hosting"> Build your entire docs site in seconds. </wc-card> <wc-button icon="rocket" right-icon="arrow-right" href="/0.3/getting-started/quickstart">Get started</wc-button> Build your entire docs site in seconds.

Get started

icon-name is the older spelling of icon on wc-card and wc-tile. It still works.

Check your icons

An icon name that exists in neither library renders nothing. docslit validate reports it as unknown-icon with a line number and the nearest known name, so a typo does not slip through:

⚠ [docs/index.md:16] <wc-icon name="rockett">: unknown icon. Did you mean "rocket"?

Browse the available names in the Lucide and Font Awesome Free catalogs. DocsLit bundles Lucide 1.60 and Font Awesome Free 6.7.2. Tabler icons are not bundled, but a Tabler name that also exists in Lucide or Font Awesome still resolves.

wc-icon attributes

The icon, unless you set src: a bare name, Font Awesome classes, lucide:name, an emoji, an image path or URL, or inline <svg>. The Font Awesome style for a bare name: solid, regular or brands. An image path or URL to use as the icon. It wins over name, so name is not needed when you set it, as in <wc-icon src="img/mark.svg"></wc-icon>. The icon size in pixels. The icon color, as any CSS color. An accessible name. Icons are decorative and hidden from screen readers unless you set this.

Licenses

Lucide is ISC licensed. Font Awesome Free icons are CC BY 4.0, and the attribution is in the NOTICES file shipped with the docslit package.

Next steps