Character Viewer

Interactive character and glyph explorer

An interactive character/glyph explorer.

<fontdue-character-viewer
collection-slug="ibm-plex"
></fontdue-character-viewer>
import CharacterViewer from "fontdue-js/CharacterViewer";
<CharacterViewer collectionSlug="ibm-plex" />

On a server-rendered framework, preload the data in your loader with loadCharacterViewerQuery and pass it as preloadedQuery in place of an identifier, see lazy versus preloaded:

import CharacterViewer, { loadCharacterViewerQuery } from "fontdue-js/CharacterViewer";
const characters = await loadCharacterViewerQuery({ collectionSlug: "ibm-plex" });
<CharacterViewer preloadedQuery={characters} />

Collapsing the grid

A large glyph set makes for a long grid, and everything after the viewer ends up far down the page. With collapse set, the viewer shows only part of the grid, with a Load more button underneath that reveals every character. Without a value, collapse shows just the first group from the collection’s Characters tab, so the grid is exactly as tall as that group. Given a height – a number of pixels, or any CSS length such as 40vh – it cuts the grid off at that height instead and fades out the last visible rows.11The button only appears when there is something left to show: a collection with a single group, or a grid shorter than the height you set, renders in full without one.

<fontdue-character-viewer
collection-slug="ibm-plex"
collapse
></fontdue-character-viewer>
import CharacterViewer from "fontdue-js/CharacterViewer";
<CharacterViewer collectionSlug="ibm-plex" collapse />

Once expanded, the viewer stays expanded – there’s no button to collapse it again. Use load-more-label (loadMoreLabel in React) to change the button’s text – Show all characters, for example. The button takes its colour from the --character_viewer_load_more_color CSS variable, which falls back to the secondary text colour.

The collapse and loadMoreLabel props need fontdue-js 3.15.0 or later.22The script-tag integration doesn’t need an upgrade – sites loading fontdue.js from the CDN get both options automatically.

Properties

Property Description Type
collection-id or collection-slug Identifier for collection string Required
collapse Shows part of the grid behind a Load more button. With no value, only the first character group shows; a number (480) or CSS length (40vh) cuts the grid off at that height. string
load-more-label Text of the button that expands a collapsed viewer. Defaults to Load more. string
Prop Description Type
collectionId or collectionSlug Identifier for the collection. Required unless you pass preloadedQuery. string
preloadedQuery Server-preloaded data from loadCharacterViewerQuery, passed instead of an identifier. object
collapse Shows part of the grid behind a Load more button. true shows only the first character group; a number of pixels (480) or a CSS length ("40vh") cuts the grid off at that height. boolean, number or string
loadMoreLabel Text of the button that expands a collapsed viewer. Defaults to Load more. string
1 The button only appears when there is something left to show: a collection with a single group, or a grid shorter than the height you set, renders in full without one. ↩
2 The script-tag integration doesn’t need an upgrade – sites loading fontdue.js from the CDN get both options automatically. ↩