|Kit
Changelog

0.25.0

CodeBlock ships about 23 Shiki chunks instead of 300, plus a Figma parity pass

CodeBlock now loads Shiki through its core, with a fixed set of languages and the JavaScript regex engine, so apps that use the kit build about 23 Shiki chunks instead of about 300 and no WASM. Languages and themes outside the built-in set have to be registered first. A Figma parity pass aligns Card, Badge, ThemeIcon, Button, Table and the pink and green ramps with the 42 UI Kit, and Switch and Checkbox now align to their label line when a description sits below.

Changes

2 breaking changes

  • CodeBlock:

    language loads only the built-in languages by name (see Languages and themes); any other name renders as plain text until its grammar is passed to registerLanguage

  • CodeBlock:

    themes loads only github-light and github-dark-default by name; any other theme falls back to the default until it is passed to registerTheme

See in the list

1added

9changed

3fixed

CodeBlock5 changesViewCheckbox2 changesViewSwitch2 changesView
  • breaking2
  • CodeBlock

    language loads only the built-in languages by name (see Languages and themes); any other name renders as plain text until its grammar is passed to registerLanguage

    #442
  • CodeBlock

    themes loads only github-light and github-dark-default by name; any other theme falls back to the default until it is passed to registerTheme

    #442
  • added1
  • CodeBlock

    CodeBlockLanguage type: the built-in language names and aliases for autocomplete, plus any registered name

    #442
  • changed9
  • CodeBlock

    Shiki loads through its core with the JavaScript regex engine: a consumer build emits about 23 Shiki chunks instead of about 300, and no Oniguruma WASM

    #442
  • CardChoice Card Group

    The dark hairline is white 8 %, Figma's border-primary (was 15 %)

    #438
  • Badge

    The edge is Figma's 0.5px stroke, drawn as an inset ring instead of a border

    #438
  • ThemeIcon

    The glyph is 12 / 14 / 16 / 18 / 22px as in Figma; outline and subtle draw the neutral glyph in full white; default's edge is white 16 %

    #438
  • Colors

    The pink and green ramps take Figma's primitives: pink is now a mauve (#c86cb6 at 500)

    #438
  • AmbientBackground

    The dark sky is tuned against Figma's Background / Cosmos: the first violet cloud and the grain are retuned

    #438
  • Button

    outline's edge is its colour at 35 %, like light's

    #438
  • TableDataTable

    The table is a card: Card's surface and edge at a 12px radius, with a clear header and pagination

    #438
  • SwitchCheckbox

    classNames.field always lands on the Field root

    #439
  • fixed3
  • CodeBlock

    An unknown language renders as plain text with a development warning, instead of leaving the block unhighlighted

    #442
  • ThemeIcon

    light tints the tile with the solid shade at 30 %, so brand and purple no longer read as black squares, and className recolours the glyph

    #438
  • SwitchCheckbox

    With a label and a description or error, the control aligns to the label line instead of centering on the whole text stack

    #439

Upgrading CodeBlock

language resolves these names on its own, each loaded on first use:

LanguageNames
Cc
C++cpp, c++
Pythonpython, py
Shellshellscript, bash, sh, shell, zsh
JavaScriptjavascript, js, cjs, mjs, jsx
TypeScripttypescript, ts, cts, mts, tsx
JSONjson
YAMLyaml, yml
Markdownmarkdown, md
HTMLhtml
CSScss
SQLsql
Gogo
Rustrust, rs
Javajava
Makefilemake, makefile
Dockerfiledocker, dockerfile
Diffdiff

Any other name now renders as plain text, with a warning in development. To keep a language you relied on, register its grammar once, before the first CodeBlock that uses it. Any of Shiki's grammars works:

import { registerLanguage } from '@42-central/ui-react/code-block';

await registerLanguage((await import('shiki/langs/haskell.mjs')).default);
// later:
<CodeBlock language="haskell" code="main = print 1" />

Themes work the same way: github-light and github-dark-default are built in, and any other theme must go through registerTheme before themes names it. See Languages and themes.

On this page

ChangesBreaking · 2CodeBlock · language loads only the built-in languages by name (see Languages and themes); any other name renders as plain text until its grammar is passed to registerLanguageCodeBlock · themes loads only github-light and github-dark-default by name; any other theme falls back to the default until it is passed to registerThemeAdded · 1CodeBlock · CodeBlockLanguage type: the built-in language names and aliases for autocomplete, plus any registered nameChanged · 9CodeBlock · Shiki loads through its core with the JavaScript regex engine: a consumer build emits about 23 Shiki chunks instead of about 300, and no Oniguruma WASMCard, Choice Card Group · The dark hairline is white 8 %, Figma's border-primary (was 15 %)Badge · The edge is Figma's 0.5px stroke, drawn as an inset ring instead of a borderThemeIcon · The glyph is 12 / 14 / 16 / 18 / 22px as in Figma; outline and subtle draw the neutral glyph in full white; default's edge is white 16 %Colors · The pink and green ramps take Figma's primitives: pink is now a mauve (#c86cb6 at 500)AmbientBackground · The dark sky is tuned against Figma's Background / Cosmos: the first violet cloud and the grain are retunedButton · outline's edge is its colour at 35 %, like light'sTable, DataTable · The table is a card: Card's surface and edge at a 12px radius, with a clear header and paginationSwitch, Checkbox · classNames.field always lands on the Field rootFixed · 3CodeBlock · An unknown language renders as plain text with a development warning, instead of leaving the block unhighlightedThemeIcon · light tints the tile with the solid shade at 30 %, so brand and purple no longer read as black squares, and className recolours the glyphSwitch, Checkbox · With a label and a description or error, the control aligns to the label line instead of centering on the whole text stackUpgrading CodeBlock