@nswds/ui 9.1.2 → 9.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,6 +42,12 @@ If your app also imports the `@nswds/tokens` Tailwind bridges — you only need
42
42
 
43
43
  /* Your own Tailwind build last — see the next section. */
44
44
  @import 'tailwindcss';
45
+
46
+ /* Your build re-emits Tailwind's default font stacks; map them back — see Fonts. */
47
+ @theme {
48
+ --font-sans: var(--font-family-sans);
49
+ --font-mono: var(--font-family-mono);
50
+ }
45
51
  ```
46
52
 
47
53
  The bridges must come first because both stylesheets emit an unlayered `:root` block of light-mode values, and only `@nswds/ui/styles.css` also ships the `[data-theme='dark'], .dark` block. `:root` and `.dark` have identical specificity, so the block that appears **last** wins. Import a bridge afterwards and its light values land last: every `bg-*` utility still flips to dark (those are compiled classes, not tokens) while the semantic role tokens stay light — so backgrounds go dark and text stays dark on top of them. Nothing errors; it just looks broken.
@@ -81,6 +87,36 @@ If you do hit a conflict, a call-site override outranks both halves:
81
87
 
82
88
  > **Don't reach for a named cascade layer to pin the order.** `@import '@nswds/ui/styles.css' layer(nswds)` looks tidy, but it also layers the `:root` and `[data-theme='dark'], .dark` token blocks the file carries, and layered custom properties lose to any unlayered `:root` — including the ones the bridges above ship. That is the dark-mode failure described in the previous section, with no import order that recovers it.
83
89
 
90
+ Your own build also re-emits Tailwind's default font stacks, which win over ours — add the `@theme` mapping described under [Fonts](#fonts).
91
+
92
+ ### Fonts
93
+
94
+ Text uses the NSW stacks from `@nswds/tokens`: **Public Sans** for `font-sans` (body text, via `body`) and **JetBrains Mono** for `font-mono`, each with system fallbacks.
95
+
96
+ **Load the font files yourself.** `@nswds/ui` ships no `@font-face`, so Public Sans only renders where your app loads it (or it happens to be installed locally); everywhere else you get the system fallback. With Next.js, `next/font` works out of the box — use `variable: '--font-sans'` (and `'--font-mono'`) and put the class on `<html>`, not `<body>`, so it overrides the stack at the root.
97
+
98
+ **Change the font with `--font-sans`, not `font-family` on `html`.** `body` sets `font-family: var(--font-sans)`, so a `font-family` you put on `html` never reaches body text. If your loader registers Public Sans under another name — `@fontsource-variable/public-sans` registers `'Public Sans Variable'` — put that name in front of the NSW stack:
99
+
100
+ ```css
101
+ :root {
102
+ --font-sans: 'Public Sans Variable', var(--font-family-sans);
103
+ }
104
+ ```
105
+
106
+ **Two-build setups** (`@nswds/ui/styles.css` plus your own `@import 'tailwindcss'`) need one more step. Your build re-emits Tailwind's default `--font-sans` and `--font-mono` in the same `theme` layer as ours, and after ours, so they win and your app renders in system fonts. Point them back at the NSW stacks, which `@nswds/ui/styles.css` ships on `:root` as `--font-family-sans` / `--font-family-mono`, right after your `@import 'tailwindcss'`:
107
+
108
+ ```css
109
+ @import '@nswds/ui/styles.css';
110
+ @import 'tailwindcss';
111
+
112
+ @theme {
113
+ --font-sans: var(--font-family-sans);
114
+ --font-mono: var(--font-family-mono);
115
+ }
116
+ ```
117
+
118
+ Keep it a plain `@theme`, not `@theme inline`: your `font-sans` utilities then read `var(--font-sans)` where they are used, so an override of `--font-sans` — at `:root` as above, or on any subtree — reaches them. The single-build entry needs none of this; its own theme already carries the NSW stacks.
119
+
84
120
  ### Dark mode
85
121
 
86
122
  Toggle `class="dark"` or `data-theme="dark"` on a **root element** (for example with [`next-themes`](https://github.com/pacocoursey/next-themes)). Semantic tokens and `dark:` utilities both key off either marker, and both match the element carrying it as well as its descendants.
@@ -24,7 +24,7 @@ import * as React from 'react';
24
24
  * look lands on the 4px grid (40px tall, 48px with the ellipsis).
25
25
  */
26
26
  declare const breadcrumbVariants: (props?: ({
27
- variant?: "default" | "band" | "soft" | "rail" | null | undefined;
27
+ variant?: "default" | "soft" | "band" | "rail" | null | undefined;
28
28
  } & class_variance_authority_types.ClassProp) | undefined) => string;
29
29
  /**
30
30
  * The `sideOffset` to give a DropdownMenuContent opened from the ellipsis. The
@@ -6,7 +6,7 @@ import { Link } from './link.js';
6
6
 
7
7
  declare const buttonCva: (props?: ({
8
8
  variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
9
- color?: "danger" | "tertiary" | "accent" | "success" | "warning" | "white" | "grey" | "primary" | "secondary" | null | undefined;
9
+ color?: "primary" | "secondary" | "white" | "accent" | "tertiary" | "success" | "warning" | "grey" | "danger" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
11
11
  iconOnly?: boolean | null | undefined;
12
12
  onTint?: boolean | null | undefined;
@@ -27,7 +27,7 @@ type ButtonVariantProps = NonNullable<Parameters<typeof buttonCva>[0]>;
27
27
  */
28
28
  declare function buttonVariants({ onTint, ...props }?: ButtonVariantProps): string;
29
29
  declare const buttonColorCva: (props?: ({
30
- color?: "danger" | "tertiary" | "accent" | "success" | "warning" | "white" | "grey" | "primary" | "secondary" | null | undefined;
30
+ color?: "primary" | "secondary" | "white" | "accent" | "tertiary" | "success" | "warning" | "grey" | "danger" | null | undefined;
31
31
  onTint?: boolean | null | undefined;
32
32
  } & class_variance_authority_types.ClassProp) | undefined) => string;
33
33
  /**
@@ -25,7 +25,7 @@ type CalloutStatus = 'info' | 'success' | 'warning' | 'danger';
25
25
  * drift out of step with the token library.
26
26
  */
27
27
  declare const calloutVariants: (props?: ({
28
- status?: "danger" | "success" | "warning" | "info" | null | undefined;
28
+ status?: "success" | "warning" | "danger" | "info" | null | undefined;
29
29
  } & class_variance_authority_types.ClassProp) | undefined) => string;
30
30
  type CalloutProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> & VariantProps<typeof calloutVariants> & {
31
31
  /** Optional bold lead line above the body copy. */
@@ -66,7 +66,7 @@ declare function Callout({ className, status, title, icon, children, ref, ...pro
66
66
  */
67
67
  declare const Alert: typeof Callout;
68
68
  declare const alertVariants: (props?: ({
69
- status?: "danger" | "success" | "warning" | "info" | null | undefined;
69
+ status?: "success" | "warning" | "danger" | "info" | null | undefined;
70
70
  } & class_variance_authority_types.ClassProp) | undefined) => string;
71
71
  type AlertProps = CalloutProps;
72
72
  type AlertStatus = CalloutStatus;
@@ -35,7 +35,7 @@ declare function InputGroupButton({ className, type, variant, size, ...props }:
35
35
  type?: 'button' | 'submit' | 'reset';
36
36
  }): React.JSX.Element;
37
37
  declare const inputGroupActionVariants: (props?: ({
38
- variant?: "open" | "solid" | "subtle" | null | undefined;
38
+ variant?: "solid" | "open" | "subtle" | null | undefined;
39
39
  } & class_variance_authority_types.ClassProp) | undefined) => string;
40
40
  declare function InputGroupAction({ className, type, variant, ...props }: Omit<React.ComponentProps<typeof Button>, 'size' | 'type' | 'variant'> & VariantProps<typeof inputGroupActionVariants> & {
41
41
  type?: 'button' | 'submit' | 'reset';
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
5
  declare const linkVariants: (props?: ({
6
- variant?: "white" | "primary" | "secondary" | "unstyled" | null | undefined;
6
+ variant?: "primary" | "secondary" | "white" | "unstyled" | null | undefined;
7
7
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
8
  type LinkComponent = React__default.ElementType;
9
9
  /**