Repository navigation
v0.17.0
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
- 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 theshadow-2…shadow-64utilities read them (@theme inlinemaps--shadow-Ntovar(--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 changesshadow-2…shadow-64(Tailwind's ownshadow-sm…shadow-2xlare unaffected). Change a level for a theme through its token instead (.wave-dark { --wave-shadow-8: … }, ortokens={{ shadow8: … }}on a provider). On the Tailwind path an@themeof yours that sets--shadow-Nkeeps its value, which replaces Wave's alias; a build that read the literal shadow values fromtokens.cssnow findsvar(--wave-shadow-N)there. WaveContextValuehas three new members:tokens(the merged overrides of the providers above;{}outside a provider),tokenStyle(the inline style that applies them;undefinedwhen there is nothing to set) andapplyStylesToPortals(trueoutside a provider). A hand-built value of the type (a test mock ofuseWaveTheme) adds them.TextWeighthas a fourth value,'medium'(500,font-medium), which theweightof Text, Label and InfoLabel takes: an exhaustiveswitchover it, or aRecord<TextWeight, …>of your own, adds a case.- With
tokens, the provider root and the portal wrappers carry the overrides. Withouttokensanywhere above, the markup is 0.16's: the root has nostyleattribute unless you pass one, and a portal wrapper'sstyleholds only itspositionandz-index. Withtokens, the root renders the--wave-*custom properties in itsstyle, before your ownstyle, which wins a conflicting property; a nested provider's root carries the whole merged map, also when it sets notokensof its own; and each portal wrapper of the subtree puts the properties before its two own (unlessapplyStylesToPortalsisfalse). A test that compares a wholestyleattribute, or a selector on[style], changes when you adopttokens. - 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./tailwindpath your Tailwind theme gains their names: the colorspalette-<hue>-tint,palette-<hue>-tint-foregroundandpalette-<hue>-borderof the 12 hues, and the font familiesfont-wave-monoandfont-wave-numeric(see the README's Global effects).cn()treats the two font families as families, socn('font-wave', 'font-wave-mono')keeps the last.
Added
WaveProvider tokens(foundation-1;WaveTokenOverrides | null; Fluent'sthemeprop 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:primaryForegroundis--wave-primary-foreground,brand80is--wave-brand-80,paletteRedTint,shadow8,fontFamilyMonospace,zOverlay), and a number is written as its string.themestill 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: … }; astyleyou 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 anothertheme(so set an override of a semantic color in the provider that sets the theme it was chosen for): an omittedtokens, or a key whose value isundefined, inherits.nullclears 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:rootonly) still reach the subtree's own elements through the cascade, sotokens={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-renderedstyleattribute, and the server and the client render the same overrides). The merged overrides keep their identity while their entries stay equal, so an inlinetokens={{ … }}re-renders no consumer. Under a Content Security Policy that blocks inline style attributes (style-srcwithout'unsafe-inline'), the server-rendered overrides do not apply and hydration does not apply them again: ship them in a stylesheet there, and pass notokens(norgetTokenStyle), 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;trueby default):falsekeeps thetokensoverrides off the portals of the subtree, those inherited from enclosing providers included. The theme classes, the direction and thewave-portalwrapper 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, liketheme(Fluent's is not inherited), and since Wave's portal wrapper never carried the provider root's own look, whatfalsedrops are the overrides (Fluent'sfalsedrops 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 fromgetTokenStyleon<html>; under an enclosing provider'stokensthe overlays lose that brand too.createBrandTokens(seed)(foundation-5; typesBrandStop,BrandRamp,BrandTokens): the 16 brand tokensbrand10…brand160of one color (#rgbor#rrggbb, any case), fortokens(alone or spread with other overrides) orgetTokenStyle. 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#0f6cbdgives 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 fullBrandRamp(a hex color per stop, the shape of Fluent'sBrandVariants): 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'screateLightTheme(brand)andcreateDarkTheme(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; typesWaveTokensandWaveTokenName): every design token (202 names) as the CSS value that reads it, typed as that literal:waveTokens.primaryis'var(--wave-primary)',waveTokens.shadow8is'var(--wave-shadow-8)'. For inline styles, CSS-in-JS rules and SVG charts, where the values follow the theme and the overrides. Fluent'stokensobject, with Wave's names. A test keeps its names equal to the variables oftokens.css. Frozen and server-safe; no component imports it, so a bundle that does not use it holds none of it.getTokenStyle(overrides)(typeTokenStyle; overrides typedWaveTokenOverrides, astokensis): the inline styleWaveProviderapplies fortokens(--wave-*custom properties in the order of the input), orundefinedfornull,undefinedor 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, soprimarybelongs intokens. 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 throughwaveTokens(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,-28and-64in every theme group (shadow8intokensandwaveTokens), Fluent'sshadow2…shadow64with 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 rolesBackground2,Foreground2andBorderActive, 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'stint40andshade30of a hue); high contrast collapses every hue (tints black, tint foregrounds and borders white). On the./tailwindpath they are color utilities (bg-palette-blue-tint,text-palette-blue-tint-foreground,border-palette-blue-border); the precompiled./stylesholds only the palette utilities the components use, so there writevar(--wave-palette-blue-tint)orwaveTokens.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 utilitiesfont-wave-monoandfont-wave-numeric(in./stylesand on the./tailwindpath).Text font(Fluent'sfont):'base', the default, keeps the inherited family and adds no class;'monospace'addsfont-wave-mono,'numeric'font-wave-numeric; aclassNamethat sets a family replaces it. Neither sets tabular figures (tabular-numsdoes). - The
mediumweight (foundation-12,text-4):TextWeightgains'medium'(500,font-medium) for theweightof Text, Label and InfoLabel ("Upgrading from 0.16", 3). Where the font has no face at weight 500, the browser draws a neighbouring face, somediumis 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:chartPaletteand the roles of the palette tokens in a chart; text, axes, grid lines and tooltips on the theme tokens; SVG libraries (Recharts, visx, Victory) takewaveTokensvalues as they are and follow the theme with no code, while canvas libraries (Chart.js, ECharts) resolve them withgetComputedStyleand redraw when the theme changes (aMutationObserverhelper); 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'sGuides/Chartsruns 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, andverify-distproves thatdistholds 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,BrandRampandBrandTokens. - Development warnings (keys):
WaveProvider:tokens:name:<key>andWaveProvider:tokens:value:<key>(from an effect, never during render),tokens:name:<key>andtokens:value:<key>(getTokenStyle, whose messages start withgetTokenStyle:),createBrandTokens:seed,createBrandTokens:ramp(once, naming every missing or invalid stop of the first ramp that has one) andcreateBrandTokens:contrast:<theme>:<token>:<against>. - Stories: WaveProvider's
Brand colour,Nested accent with a dialogandPortals without styles; Text'sFonts and weights(andmediumin Text'sWeightsand Label's weights);Guides/ChartswithRechartsandChart.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
styleattribute and a portal wrapper'sstyleholds only its position and stacking, as in 0.16 (a test pins the server markup). Withtokens, the provider roots and the portal wrappers of the subtree carry the custom properties ("Upgrading from 0.16", 4), andText fontadds its class.
CSS
tokens.cssdeclares the six shadow tokens and the 36 palette tokens in each theme group and the two font families on:root;@theme inlinemaps--shadow-Ntovar(--wave-shadow-N)and adds the palette colors and the font families; its header lists the palette's roles.dist/styles.cssgrew by 5.6 KiB (0.9 KiB gzip; see Size).cn()recognisesfont-wave-monoandfont-wave-numericas font families, never a weight or a size.
Types
WaveContextValuegainstokens,tokenStyleandapplyStylesToPortals, andTextWeightthe value'medium'("Upgrading from 0.16", 2 and 3).WaveProviderPropsgainstokensandapplyStylesToPortals, andTextOwnPropsgainsfont; every other change is a new export.
Dev gates
verify-dist(the Phase 12 spec, §10): an import of onlycreateBrandTokensstays withinBRAND_TOKENS_BUDGET(4,495 bytes minified, 3,072 gzip), imports no React, holds no component module and notlib/waveTokens, and, built for production, holds nocreateBrandTokens:contrastkey (the development check is dropped); an import of onlywaveTokensstays withinWAVE_TOKENS_BUDGET(3,839 and 3,072) and holds no component module.RECORDED_IMPORTS_0_17gates 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 ofWaveProviderandDialog(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 onlyDialogor onlyTreehold neitherlib/waveTokensnorlib/brand(and the Dialog's code no token name and no brand-generator key), and imports of onlyButtonor onlyMessageBarhold 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.distholds norecharts,chart.jsorkurklestring. Every probe now bundles as a consumer's production build (process.env.NODE_ENVdefined 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.tsholds the parser and resolver oftokens.cssand the contrast matrix, moved out oftokens.test.tswithout editing an assertion, andforEachContrastPair, which walks the matrix of a theme over other values;tokens.brand.test.tsruns the whole light and dark matrix with generated ramps;waveTokens.test.tsfails whentokens.cssand the token names differ; andtokens.test.tsgains 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:
recharts3.10.1 andchart.js4.5.1, at exact versions and without install scripts, imported only bystories/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-distgates 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 neitherwaveTokensnor 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
WaveProvidergrows by 1,399 bytes (643 gzip), about 600 of themlib/tokens(the name and value rules, the merge and the style); withDialog, by 1,451 (620 gzip). - The helpers stay small and apart:
createBrandTokensalone 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);waveTokensalone 969 gzip, its 202 names one string;chartPalettealone 232 bytes, since the names list is dropped. No component importswaveTokensorcreateBrandTokens, andverify-distproves that a Dialog-only import holds no token name and no brand code. - Text grows by 154 bytes (62 gzip):
font, themediumclass andcn's 27. dist/styles.cssgrew by 5.6 KiB (0.9 KiB gzip): the new tokens of the three theme groups, and thefont-wave-mono,font-wave-numericandfont-mediumutilities that Text and Label use.