Skip to content

v0.17.0

Choose a tag to compare

@github-actions github-actions released this 30 Oct 03:21
· 295 commits to main since this release

The twelfth Fluent UI v9 parity release: Phase 12 of the roadmap, the theming API and a charts strategy. An app can now look like its own brand without forking WaveUI or fighting it. WaveProvider tokens overrides any design token by its camelCase name, as inline custom properties on the provider's root and on every portal of its subtree, so a nested panel's dialogs, menus, popovers, tooltips and toasts match the panel (applyStylesToPortals={false} keeps the overrides off the portals). createBrandTokens('#c43e00') builds the 16-stop brand ramp from one color, each stop at the default ramp's luminance, so the light and dark themes keep their contrast whatever the seed; a full ramp of your own is checked in development. waveTokens gives every token a typed JavaScript value (waveTokens.primary is 'var(--wave-primary)'), getTokenStyle the provider's inline style for an element no provider renders (a Server Component's <html>), and chartPalette the 12 palette fills in an order for chart series. Shadows become per-theme tokens with Fluent's stronger dark values, each persona palette hue gains a tint, a tint foreground and a border, and two font families (monospace and numeric) come with Text font and a medium weight. Charts are a documented strategy, not components: the guide's new "Charts with WaveUI" chapter and Storybook stories for Recharts and Chart.js, which stay out of the package. It closes the eleven gaps of P12-01 to P12-04 (foundation-1, foundation-3, foundation-5, foundation-6, foundation-7, foundation-8, foundation-11, foundation-12, foundation-46, text-3, text-4): foundation-46 by the strategy, and foundation-6 by the palette, with the spacing, radius and stroke scales documented rather than made tokens. Nothing public was removed, and the markup of 0.16 is unchanged without tokens; WaveContextValue gains three members and TextWeight a fourth value, and the dark and high-contrast shadows are stronger: read "Upgrading from 0.16" before upgrading.

Upgrading from 0.16

  1. The dark and high-contrast shadows are stronger. The six shadow levels are tokens of each theme group (--wave-shadow-2 … --wave-shadow-64), and the shadow-2 … shadow-64 utilities read them (@theme inline maps --shadow-N to var(--wave-shadow-N)). The light theme keeps the shadows of 0.16 byte for byte (ambient opacity 0.12, key 0.14); dark and high contrast take Fluent's 0.24 and 0.28 with the same offsets and blurs, twice as dark, so every raised surface of those themes (cards, menus, popovers, tooltips, toasts, dialogs, overlay drawers) looks different: a visual change, no API change. Since a level's value is now a token, Tailwind can no longer take its colors apart: a shadow color utility or an opacity modifier (shadow-black, shadow-primary, shadow-4/50) no longer changes shadow-2 … shadow-64 (Tailwind's own shadow-sm … shadow-2xl are unaffected). Change a level for a theme through its token instead (.wave-dark { --wave-shadow-8: … }, or tokens={{ shadow8: … }} on a provider). On the Tailwind path an @theme of yours that sets --shadow-N keeps its value, which replaces Wave's alias; a build that read the literal shadow values from tokens.css now finds var(--wave-shadow-N) there.
  2. WaveContextValue has three new members: tokens (the merged overrides of the providers above; {} outside a provider), tokenStyle (the inline style that applies them; undefined when there is nothing to set) and applyStylesToPortals (true outside a provider). A hand-built value of the type (a test mock of useWaveTheme) adds them.
  3. TextWeight has a fourth value, 'medium' (500, font-medium), which the weight of Text, Label and InfoLabel takes: an exhaustive switch over it, or a Record<TextWeight, …> of your own, adds a case.
  4. With tokens, the provider root and the portal wrappers carry the overrides. Without tokens anywhere above, the markup is 0.16's: the root has no style attribute unless you pass one, and a portal wrapper's style holds only its position and z-index. With tokens, the root renders the --wave-* custom properties in its style, before your own style, which wins a conflicting property; a nested provider's root carries the whole merged map, also when it sets no tokens of its own; and each portal wrapper of the subtree puts the properties before its two own (unless applyStylesToPortals is false). A test that compares a whole style attribute, or a selector on [style], changes when you adopt tokens.
  5. Everything else is opt-in: tokens, applyStylesToPortals, createBrandTokens, waveTokens, getTokenStyle, chartPalette, Text font, the palette tints, tint foregrounds and borders, and the two font families are new props, exports and tokens, and a page that uses none of them renders as in 0.16, apart from item 1. On the ./tailwind path your Tailwind theme gains their names: the colors palette-<hue>-tint, palette-<hue>-tint-foreground and palette-<hue>-border of the 12 hues, and the font families font-wave-mono and font-wave-numeric (see the README's Global effects). cn() treats the two font families as families, so cn('font-wave', 'font-wave-mono') keeps the last.

Added

  • WaveProvider tokens (foundation-1; WaveTokenOverrides | null; Fluent's theme prop with a partial theme): design token overrides for the subtree, CSS values by token name. A name is the token's CSS variable in camelCase without --wave- (a hyphen before each capital letter and before a run of digits: primaryForeground is --wave-primary-foreground, brand80 is --wave-brand-80, paletteRedTint, shadow8, fontFamilyMonospace, zOverlay), and a number is written as its string. theme still names one of the three themes, and the overrides apply over it as inline custom properties on the provider's root (in the server HTML too, so the first paint has them) and on the wrapper of every portal in its subtree, so its dialogs, drawers, menus, popovers, tooltips, listboxes and toasts take them. An inline style beats every stylesheet rule on the same element, so an override also wins over .wave-light { --wave-primary: … }; a style you pass to the provider wins over the overrides. A nested provider merges its overrides over the enclosing provider's, key by key, also when it sets another theme (so set an override of a semantic color in the provider that sets the theme it was chosen for): an omitted tokens, or a key whose value is undefined, inherits. null clears the inherited overrides of the tokens a theme declares (the semantic colors, the palette, the shadows) and of the subtree's overlays; the theme-independent tokens of an enclosing provider (the brand and grey ramps, the font families, the stacking layers, the motion durations and curves, which are declared on :root only) still reach the subtree's own elements through the cascade, so tokens={createBrandTokens('#0f6cbd')} is the way to put a subtree back on the default ramp everywhere. Names are converted by the rule, not checked against the list of tokens: TypeScript refuses a misspelled one, and in JavaScript it sets a custom property nothing reads. A key that is not a camelCase identifier, or a value that is neither a finite number nor a string without ;, { or }, is skipped with a development warning (so a value cannot add a declaration of its own to the server-rendered style attribute, and the server and the client render the same overrides). The merged overrides keep their identity while their entries stay equal, so an inline tokens={{ … }} re-renders no consumer. Under a Content Security Policy that blocks inline style attributes (style-src without 'unsafe-inline'), the server-rendered overrides do not apply and hydration does not apply them again: ship them in a stylesheet there, and pass no tokens (nor getTokenStyle), since the overlays and the subtrees rendered in the client would still take them and leave the page half branded (guide). Fluent's provider inserts a style rule with the renderer's nonce instead; Wave renders no <style> element and needs no nonce.
  • applyStylesToPortals (foundation-3; Fluent's name; true by default): false keeps the tokens overrides off the portals of the subtree, those inherited from enclosing providers included. The theme classes, the direction and the wave-portal wrapper stay, so an overlay of a dark provider is still dark; for the tokens the theme declares it shows the theme's own values, and the theme-independent ones come from the cascade of the element it renders into. A nested provider inherits an omitted value, like theme (Fluent's is not inherited), and since Wave's portal wrapper never carried the provider root's own look, what false drops are the overrides (Fluent's false drops the root's other classes). It keeps a panel's accent out of the panel's dialogs and menus when the page's brand comes from CSS or from getTokenStyle on <html>; under an enclosing provider's tokens the overlays lose that brand too.
  • createBrandTokens(seed) (foundation-5; types BrandStop, BrandRamp, BrandTokens): the 16 brand tokens brand10 … brand160 of one color (#rgb or #rrggbb, any case), for tokens (alone or spread with other overrides) or getTokenStyle. Each stop keeps the relative luminance of the default ramp's stop and takes its hue and colorfulness from the seed: the seed's OKLCH hue and chroma, shaped per stop like the default ramp (less colorful toward both ends, the hue drifting a few degrees as the default's does), reduced to fit sRGB and rounded to a neighbouring 8-bit color on the side that keeps the stop's contrast. Contrast depends only on luminance, so every text, fill, stroke and focus-ring pair of the light and dark themes keeps, to within 8-bit rounding, the contrast it has with the default ramp, and stays above the floors the themes are held to (4.5:1 for text, 3:1 for strokes and focus rings, 1.15:1 between the states of a fill), whatever the seed: the tests run the whole contrast matrix of both themes over 16 seeds (the extremes of the color wheel, a pale pink, black and white among them) and its brand pairs over 1,648 more. The cost: the seed sets the hue, not the lightness, so stop 80 (the light primary) is the seed's hue at the default's lightness, and a light seed gives a darker button than itself. The default seed #0f6cbd gives the default ramp exactly and a grey seed a grey ramp; anything else gives the default ramp, with a development warning. For exact brand colors pass a full BrandRamp (a hex color per stop, the shape of Fluent's BrandVariants): it is returned unchanged (a missing or invalid stop takes the default ramp's color, with a development warning) and, in development, checked against the pairs the light and dark themes read from it, each pair below its minimum logging one warning that names the theme, the tokens, the stops and the ratio. The check is advisory, and a production build drops it. The high-contrast theme ignores the brand: its colors are fixed, as Fluent's high-contrast theme takes none. Fluent's createLightTheme(brand) and createDarkTheme(brand) take a full ramp only, and its library checks no contrast. Pure and server-safe; it returns a new object on each call, so compute it once.
  • waveTokens (foundation-8; types WaveTokens and WaveTokenName): every design token (202 names) as the CSS value that reads it, typed as that literal: waveTokens.primary is 'var(--wave-primary)', waveTokens.shadow8 is 'var(--wave-shadow-8)'. For inline styles, CSS-in-JS rules and SVG charts, where the values follow the theme and the overrides. Fluent's tokens object, with Wave's names. A test keeps its names equal to the variables of tokens.css. Frozen and server-safe; no component imports it, so a bundle that does not use it holds none of it.
  • getTokenStyle(overrides) (type TokenStyle; overrides typed WaveTokenOverrides, as tokens is): the inline style WaveProvider applies for tokens (--wave-* custom properties in the order of the input), or undefined for null, undefined or a map with nothing to set; it skips what the provider skips, with a development warning once per key. For an element that no provider renders: in a Server Component, <html style={getTokenStyle(createBrandTokens('#c43e00'))}> brands the page and its portals through the cascade. Only the theme-independent tokens reach that far: every theme class below re-declares the semantic ones, so primary belongs in tokens. Server-safe.
  • chartPalette (foundation-46): the 12 palette fills as token names in the order a categorical chart gives them to its series (blue, purple, brown, teal, red, navy, pumpkin, steel, gold, lavender, forest, magenta), each read through waveTokens (waveTokens[chartPalette[index]]). The order keeps neighbouring series apart: in light and dark, every two neighbours differ by at least 6.3 (OKLab ΔE ×100) under simulated protanopia, deuteranopia and tritanopia and by at least 15.7 for full color vision, with hues at least 49° apart. Series that are not neighbours can be much closer (about 3.2 among the first six), no six fills of the palette stay apart for every pair, and in high contrast every fill is white, so every chart needs a second encoding (a pattern, a marker shape, a direct label), whatever its number of series. Frozen and server-safe.
  • Per-theme shadow tokens (foundation-7): --wave-shadow-2, -4, -8, -16, -28 and -64 in every theme group (shadow8 in tokens and waveTokens), Fluent's shadow2 … shadow64 with Fluent's values per theme ("Upgrading from 0.16", 1). Fluent's brand-colored shadows have no counterpart.
  • The persona palette's tints, tint foregrounds and borders (foundation-6): for each of the 12 hues and in every theme, --wave-palette-<hue>-tint (a surface: light in the light theme, deep in the dark one), --wave-palette-<hue>-tint-foreground (text and icons on the tint, on the page and on cards: 4.5:1 on all three) and --wave-palette-<hue>-border (the hue's stroke, declared as its fill: 3:1 on the page and on the tint). The fill, --wave-palette-<hue>, and its text, --wave-palette-<hue>-foreground, are unchanged; the fill is now also asserted at 3:1 on the page, so it serves as a chart series. These are Fluent's persona roles Background2, Foreground2 and BorderActive, named in the grammar of the status tokens (success-tint, success-tint-foreground) rather than the roadmap sketch's -background, whose meaning would collide with the fill. Light tints are the fill mixed 70% toward white and dark tints the light fill mixed 40% toward black (Fluent's tint40 and shade30 of a hue); high contrast collapses every hue (tints black, tint foregrounds and borders white). On the ./tailwind path they are color utilities (bg-palette-blue-tint, text-palette-blue-tint-foreground, border-palette-blue-border); the precompiled ./styles holds only the palette utilities the components use, so there write var(--wave-palette-blue-tint) or waveTokens.paletteBlueTint. No component uses the tints yet: Avatar, Badge and Tag keep their looks.
  • Font families (foundation-11, text-3): --wave-font-family-monospace (Consolas, 'Courier New', Courier, monospace) and --wave-font-family-numeric (Bahnschrift, then the base stack), Fluent's two stacks, theme-independent on :root, with the utilities font-wave-mono and font-wave-numeric (in ./styles and on the ./tailwind path). Text font (Fluent's font): 'base', the default, keeps the inherited family and adds no class; 'monospace' adds font-wave-mono, 'numeric' font-wave-numeric; a className that sets a family replaces it. Neither sets tabular figures (tabular-nums does).
  • The medium weight (foundation-12, text-4): TextWeight gains 'medium' (500, font-medium) for the weight of Text, Label and InfoLabel ("Upgrading from 0.16", 3). Where the font has no face at weight 500, the browser draws a neighbouring face, so medium is distinct from regular and semibold only in a font that ships a 500 face: on Windows 11, whose Segoe UI, Bahnschrift and Consolas have none, Firefox draws it with the regular face and Chromium and WebKit with the semibold one (Consolas regular in all three).
  • Charts with WaveUI (foundation-46, by strategy): a guide chapter, Charts with WaveUI: chartPalette and the roles of the palette tokens in a chart; text, axes, grid lines and tooltips on the theme tokens; SVG libraries (Recharts, visx, Victory) take waveTokens values as they are and follow the theme with no code, while canvas libraries (Chart.js, ECharts) resolve them with getComputedStyle and redraw when the theme changes (a MutationObserver helper); high contrast and forced colors; accessibility (role="img" with a name and a description, a data table, never color alone); and why WaveUI documents rather than ships chart components (Fluent's chart packages). Storybook's Guides/Charts runs it: a six-series bar chart with Recharts and with Chart.js, patterns as the second encoding, a data table behind a switch, and the theme toolbar (the Chart.js chart redraws). Both libraries are devDependencies of the repository, never of the package, and verify-dist proves that dist holds neither.
  • Guide and README: the guide's theming chapter is rewritten (token overrides, nesting rules, overlays, brand colors, tokens in JavaScript, a strict Content Security Policy, overriding tokens in CSS); the color chapter gains the persona palette's roles and values, the elevation chapter per-theme tables, the typography chapter the font families and four weights, and the layout chapter Fluent's spacing, radius and stroke tokens mapped to the Tailwind classes Wave uses (the scales stay Tailwind's, with no tokens of their own). The README gains "Brand colors and token overrides".
  • Types WaveTokenName, WaveTokens, WaveTokenOverrides, TokenStyle, BrandStop, BrandRamp and BrandTokens.
  • Development warnings (keys): WaveProvider:tokens:name:<key> and WaveProvider:tokens:value:<key> (from an effect, never during render), tokens:name:<key> and tokens:value:<key> (getTokenStyle, whose messages start with getTokenStyle:), createBrandTokens:seed, createBrandTokens:ramp (once, naming every missing or invalid stop of the first ramp that has one) and createBrandTokens:contrast:<theme>:<token>:<against>.
  • Stories: WaveProvider's Brand colour, Nested accent with a dialog and Portals without styles; Text's Fonts and weights (and medium in Text's Weights and Label's weights); Guides/Charts with Recharts and Chart.js.

Changed

Visual

  • Dark and high-contrast shadows are stronger, Fluent's values at twice the opacity ("Upgrading from 0.16", 1); on a dark page the border still carries most of a raised surface's separation. The light theme's shadows are unchanged.

DOM structure

  • Unchanged without the new props: the provider root renders no style attribute and a portal wrapper's style holds only its position and stacking, as in 0.16 (a test pins the server markup). With tokens, the provider roots and the portal wrappers of the subtree carry the custom properties ("Upgrading from 0.16", 4), and Text font adds its class.

CSS

  • tokens.css declares the six shadow tokens and the 36 palette tokens in each theme group and the two font families on :root; @theme inline maps --shadow-N to var(--wave-shadow-N) and adds the palette colors and the font families; its header lists the palette's roles. dist/styles.css grew by 5.6 KiB (0.9 KiB gzip; see Size).
  • cn() recognises font-wave-mono and font-wave-numeric as font families, never a weight or a size.

Types

  • WaveContextValue gains tokens, tokenStyle and applyStylesToPortals, and TextWeight the value 'medium' ("Upgrading from 0.16", 2 and 3). WaveProviderProps gains tokens and applyStylesToPortals, and TextOwnProps gains font; every other change is a new export.

Dev gates

  • verify-dist (the Phase 12 spec, §10): an import of only createBrandTokens stays within BRAND_TOKENS_BUDGET (4,495 bytes minified, 3,072 gzip), imports no React, holds no component module and not lib/waveTokens, and, built for production, holds no createBrandTokens:contrast key (the development check is dropped); an import of only waveTokens stays within WAVE_TOKENS_BUDGET (3,839 and 3,072) and holds no component module. RECORDED_IMPORTS_0_17 gates the Button-only and MessageBar-only imports (64 bytes minified and 32 gzip over 0.16.0), Tree-only (128 and 64), Dialog-only (1,024 and 409) and an import of WaveProvider and Dialog (1,536 and 716) against 0.16.0 as published, and the CLI prints them next to the 0.15.0 lines. Exclusion probes: imports of only Dialog or only Tree hold neither lib/waveTokens nor lib/brand (and the Dialog's code no token name and no brand-generator key), and imports of only Button or only MessageBar hold no token module and not the provider, each with a positive control. The react-server check runs the three token modules on the server and requires the entry to export their public names from them. dist holds no recharts, chart.js or kurkle string. Every probe now bundles as a consumer's production build (process.env.NODE_ENV defined as "production", where it followed the environment), which changes no size of a normal run. The module-only list gains the token seams.
  • Tests: src/styles/__tests__/tokensHarness.ts holds the parser and resolver of tokens.css and the contrast matrix, moved out of tokens.test.ts without editing an assertion, and forEachContrastPair, which walks the matrix of a theme over other values; tokens.brand.test.ts runs the whole light and dark matrix with generated ramps; waveTokens.test.ts fails when tokens.css and the token names differ; and tokens.test.ts gains two guards: every declaration of a theme group but the shadows is in its token table, so no color token skips the classification of the matrix, and the tints and tint foregrounds keep their fill's hue.
  • Development dependencies: recharts 3.10.1 and chart.js 4.5.1, at exact versions and without install scripts, imported only by stories/Charts.stories.tsx.

Deprecated

  • Nothing new is deprecated.

Fixed

  • Nothing in the library. The README and the guide now list every brand stop the light and dark themes read (0.16 left out the selection's hover and pressed stops and the focus-ring stops) and the shadow level each component uses.

Size

Against 0.16.0 as published on npm, measured with this release's build tools (verify-dist's measureImport: a minified production Vite build of an entry that imports the names from dist/index.mjs, bare imports external, gzip by node:zlib; dist/styles.css as built). Sizes are in bytes:

Import 0.16.0 0.17.0
dist/styles.css (as built, KiB) 96.6 KiB (15.4 KiB gzip) 102.2 KiB (16.3 KiB gzip)
An import of only createBrandTokens (new) — 3,630 (1,956 gzip)
An import of only waveTokens (new) — 3,071 (969 gzip)
An import of only getTokenStyle (new) — 1,350 (772 gzip)
An import of only chartPalette (new) — 232 (149 gzip)
An import of only WaveProvider 2,503 (1,201 gzip) 3,902 (1,844 gzip)
An import of WaveProvider and Dialog 71,884 (24,127 gzip) 73,335 (24,747 gzip)
An import of only Dialog 70,721 (23,723 gzip) 70,850 (23,786 gzip)
An import of only Menu 87,267 (29,348 gzip) 87,396 (29,398 gzip)
An import of only Popover 56,539 (19,396 gzip) 56,668 (19,445 gzip)
An import of only Tooltip 26,002 (10,056 gzip) 26,133 (10,109 gzip)
An import of only Toaster 40,433 (14,079 gzip) 40,562 (14,127 gzip)
An import of only Text 2,105 (1,007 gzip) 2,259 (1,069 gzip)
An import of only Tree 47,248 (16,196 gzip) 47,327 (16,232 gzip)
An import of only DataGrid 70,070 (23,708 gzip) 70,097 (23,719 gzip)
An import of only Button 11,195 (3,855 gzip) 11,222 (3,866 gzip)
An import of only MessageBar 26,831 (9,312 gzip) 26,858 (9,324 gzip)
  • An app that does not theme pays little. Button-only, MessageBar-only and DataGrid-only imports grow by 27 bytes (11 or 12 gzip), the two font-family entries of cn, and Button and MessageBar hold no token module and not the provider (verify-dist gates both). Tree-only grows by 79 bytes (36 gzip): cn's 27, and 52 for the three new members of the provider context's defaults, which Tree holds because it reads the context for its direction; it holds neither waveTokens nor the brand generator.
  • A portal costs about 100 bytes more: the Dialog-, Menu-, Popover-, Tooltip- and Toaster-only imports grow by 129 to 131 bytes (48 to 63 gzip), cn's 27 and the Portal's token style with the context's new members.
  • The token handling is in the provider: an import of only WaveProvider grows by 1,399 bytes (643 gzip), about 600 of them lib/tokens (the name and value rules, the merge and the style); with Dialog, by 1,451 (620 gzip).
  • The helpers stay small and apart: createBrandTokens alone is 1,956 bytes gzip with no React, no component and no token names (a production build drops the development check of a full ramp and its table); waveTokens alone 969 gzip, its 202 names one string; chartPalette alone 232 bytes, since the names list is dropped. No component imports waveTokens or createBrandTokens, and verify-dist proves that a Dialog-only import holds no token name and no brand code.
  • Text grows by 154 bytes (62 gzip): font, the medium class and cn's 27.
  • dist/styles.css grew by 5.6 KiB (0.9 KiB gzip): the new tokens of the three theme groups, and the font-wave-mono, font-wave-numeric and font-medium utilities that Text and Label use.