@nswds/ui 5.0.1 → 5.0.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
@@ -114,7 +114,7 @@ Passing the component itself (`leadingVisual={IconDownload}`) throws there:
114
114
 
115
115
  ## Components
116
116
 
117
- Badge, Button, ButtonLink, Card, DescriptionList, Field, Input, Label, LabeledSeparator, Link, Logo (NSW Government logo), Separator, Spinner — plus the icon set under `@nswds/ui/icons`.
117
+ Badge, Button, ButtonLink, Card, Field, Input, Label, LabeledSeparator, Link, Logo (NSW Government logo), Separator, Spinner — plus the icon set under `@nswds/ui/icons`.
118
118
 
119
119
  Every interactive component wraps a Base UI primitive, which provides focus management, keyboard navigation, and ARIA semantics. Each component also exports its `cva` variants function (for example `buttonVariants`) so you can extend styling.
120
120
 
@@ -124,10 +124,10 @@ Every visual property traces back to a CSS custom property token. Components ref
124
124
 
125
125
  ## Prefer the source in your repo?
126
126
 
127
- The same components are distributed through a [shadcn](https://ui.shadcn.com/) registry at **https://nswds-ui-registry.vercel.app**, which copies the component source directly into your project for teams that want to adapt it:
127
+ The same components are distributed through a [shadcn](https://ui.shadcn.com/) registry at **https://ui.digital.nsw.gov.au/registry**, which copies the component source directly into your project for teams that want to adapt it:
128
128
 
129
129
  ```bash
130
- npx shadcn@latest add https://nswds-ui-registry.vercel.app/r/button.json
130
+ npx shadcn@latest add https://ui.digital.nsw.gov.au/registry/r/button.json
131
131
  ```
132
132
 
133
133
  The npm package gives you versioned, upgradeable components; the registry gives you editable source. See the [registry installation guide](https://github.com/digitalnsw/nswds-ui/blob/main/docs/installing-from-the-registry.md) for the full setup, including the one-time `@nswds` namespace configuration.
@@ -6,7 +6,7 @@ import { Link } from './link.js';
6
6
 
7
7
  declare const badgeVariants: (props?: ({
8
8
  variant?: "solid" | "soft" | "surface" | "outline" | null | undefined;
9
- color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "primary/grey" | "light" | "primary/white" | null | undefined;
9
+ color?: "primary/grey" | "light" | "primary/white" | "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | null | undefined;
11
11
  } & class_variance_authority_types.ClassProp) | undefined) => string;
12
12
  type BadgeProps = VariantProps<typeof badgeVariants> & React__default.ComponentPropsWithoutRef<'span'> & {
@@ -5,9 +5,9 @@ import React__default from 'react';
5
5
  import { Link } from './link.js';
6
6
 
7
7
  declare const buttonVariants: (props?: ({
8
- variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
9
- color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "danger" | "success" | "warning" | null | undefined;
10
- size?: "default" | "icon" | "sm" | "lg" | null | undefined;
8
+ variant?: "solid" | "soft" | "surface" | "outline" | "link" | "ghost" | null | undefined;
9
+ color?: "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | "danger" | "success" | "warning" | null | undefined;
10
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
11
11
  iconOnly?: boolean | null | undefined;
12
12
  } & class_variance_authority_types.ClassProp) | undefined) => string;
13
13
  /**
@@ -26,7 +26,23 @@ declare const buttonVariants: (props?: ({
26
26
  */
27
27
  type IconSlot = React__default.ElementType | React__default.ReactElement;
28
28
  /** Visual/content props shared by `Button` and `ButtonLink`. */
29
- type ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOnly'> & {
29
+ type ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOnly' | 'color'> & {
30
+ /**
31
+ * Colour token. Most are safe on any surface: the non-solid variants take
32
+ * their ink from the token and it flips for dark mode, so `primary` reads
33
+ * correctly on a light page and on a dark one.
34
+ *
35
+ * `white` and `secondary` are the exceptions — both are
36
+ * **surface-conditional, for dark surfaces only**. Their inks (`white` and
37
+ * `primary-200`) are already light, which is what makes them right on a
38
+ * dark surface and unusable on a light one: a non-solid button in either
39
+ * colour measures around 1.2:1 on white, against the 3:1 WCAG 1.4.11 asks
40
+ * of a UI component. Reach for them the way `Hero` does — over a
41
+ * `primary-800` panel — and use `primary` on a light or theme-flipping
42
+ * surface. `solid` is unaffected either way, since it pairs `--btn-fill`
43
+ * with `--btn-text` rather than painting the ink.
44
+ */
45
+ color?: 'white' | 'grey' | 'primary' | 'secondary' | 'tertiary' | 'accent' | 'danger' | 'success' | 'warning' | null;
30
46
  /**
31
47
  * Scale step. `sm` / `default` / `lg` render 52 / 60 / 68px tall below
32
48
  * `sm:` and 44 / 52 / 60px at or above it. The step changes padding only —
@@ -24,9 +24,25 @@ const styles = {
24
24
  // Focus — deliberately `focus:` (paints on pointer clicks too), unlike
25
25
  // Link/Input which use `focus-visible:`. Buttons give click feedback with
26
26
  // the ring; links only ring for keyboard/AT focus. Do not "unify" this.
27
+ // The ring is offset 2px, so it lands on the *page* rather than on the
28
+ // button. `--btn-bg` is the ink (see the note above `styles.colors`), which
29
+ // flips for dark mode, so the ring follows the theme for every variant —
30
+ // including `solid`, whose ring used to be its own fill colour and so went
31
+ // near-invisible on a dark surface.
27
32
  "focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--btn-bg)",
28
33
  // Disabled
29
34
  "data-disabled:opacity-50 data-disabled:pointer-events-none",
35
+ // State overlays, derived from the ink rather than restated per colour.
36
+ // Deriving them means they follow `--btn-bg` wherever it comes from: the
37
+ // colour token, its dark-mode counterpart, or a surface that re-points the
38
+ // ink at its own (`[--btn-bg:var(--footer-ink)]` in footer.tsx and
39
+ // footer-cta.tsx). `solid` overrides both with its white/black pair at
40
+ // `data-[variant=solid]:` — an attribute selector, so it outranks these
41
+ // regardless of source order. `oklab` matches the interpolation space
42
+ // Tailwind's own `/10` alpha modifier emits, so the painted colour is
43
+ // unchanged from when each colour restated these itself.
44
+ "[--btn-hover-overlay:color-mix(in_oklab,var(--btn-bg)_10%,transparent)]",
45
+ "[--btn-active-overlay:color-mix(in_oklab,var(--btn-bg)_20%,transparent)]",
30
46
  // Glyph size beside a label: one value for every step and breakpoint.
31
47
  // Every step sets `text-base/7`, so the label is 16px whatever the step —
32
48
  // only the padding changes. An icon next to it has to match the *text*,
@@ -49,9 +65,9 @@ const styles = {
49
65
  // Optical border, implemented as the button background to avoid corner artifacts
50
66
  "border-transparent bg-(--btn-border)",
51
67
  // Dark mode: border is rendered on `after` so background is set to button background
52
- "dark:bg-(--btn-bg)",
68
+ "dark:bg-(--btn-fill)",
53
69
  // Button background, implemented as foreground layer to stack on top of pseudo-border layer
54
- "before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)",
70
+ "before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-fill)",
55
71
  // Drop shadow, applied to the inset `before` layer so it blends with the border
56
72
  "before:shadow-sm",
57
73
  // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
@@ -176,57 +192,98 @@ const styles = {
176
192
  "hover:shadow-[0_-2px_0_var(--link-halo),0_4px_0_var(--link-halo)]",
177
193
  "active:shadow-[0_-2px_0_var(--link-halo-active),0_4px_0_var(--link-halo-active)]"
178
194
  ],
195
+ // Two variables, deliberately separate.
196
+ //
197
+ // `--btn-fill` is the block of colour `solid` paints behind `--btn-text`.
198
+ // `--btn-bg` is the *ink*: the glyph and label on every non-solid variant
199
+ // (`text-(--btn-bg)`), the border on `outline`/`surface`, the tint on
200
+ // `soft`/`surface`, the `link` halos, the state overlays derived in
201
+ // `styles.base`, and the focus ring. They start life the same colour, and
202
+ // only part company in dark mode.
203
+ //
204
+ // They used to be one variable, which made the ink un-flippable. The values
205
+ // here are masterbrand palette steps, and palette steps are theme-invariant —
206
+ // `styles.css` re-declares only the *semantic* tokens under
207
+ // `[data-theme=dark], .dark`. Design-system surfaces do flip, though
208
+ // (`Header color='white'` is `bg-white dark:bg-grey-900`), so a non-solid
209
+ // button kept its light-mode ink on a dark surface: `primary-800` on
210
+ // `grey-900` measures 1.32:1, far under the 3:1 WCAG 1.4.11 asks of a UI
211
+ // component, with the overlays and focus ring unpainted for the same reason.
212
+ // Splitting the fill off means `--btn-bg` can flip on its own without
213
+ // repainting `solid`, so the dark counterparts below need no variant scoping
214
+ // and stay at single-class specificity — which is what keeps them overridable
215
+ // by a surface that imposes its own ink (`[--btn-bg:var(--footer-ink)]` in
216
+ // footer.tsx and footer-cta.tsx). Raising their specificity would silently
217
+ // win against those, so keep any future dark value a bare `dark:` utility.
218
+ //
219
+ // `-200` is the package's established ink-on-dark (`--link-color`,
220
+ // `--main-nav-panel-ink`) and clears 10:1 against every dark surface token.
221
+ // `white` and `secondary` are already light inks, so they have no counterpart.
222
+ //
223
+ // Dark values use the raw NSW tokens for the tree-shaking reason spelled out
224
+ // above `danger` below.
179
225
  colors: {
180
226
  grey: [
181
227
  // Base
182
- "[--btn-bg:var(--color-grey-600)] [--btn-border:var(--color-grey-600)]/90 [--btn-text:white]",
228
+ "[--btn-fill:var(--color-grey-600)] [--btn-bg:var(--color-grey-600)] [--btn-border:var(--color-grey-600)]/90 [--btn-text:white]",
229
+ // Dark mode: ink
230
+ "dark:[--btn-bg:var(--grey-200)]",
183
231
  // State: Hover
184
- "[--btn-hover-overlay:var(--color-grey-600)]/10 [--btn-active-overlay:var(--color-grey-600)]/20",
185
232
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10",
186
233
  // State: Active
187
234
  "data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
188
235
  ],
189
236
  white: [
237
+ // No dark counterpart: white is already the maximum-contrast ink on any
238
+ // dark surface. Surface-conditional in the same way as `secondary` — on a
239
+ // light surface a non-solid `white` button is white on white. See the
240
+ // note on the `color` prop.
190
241
  // Base
191
- "[--btn-bg:var(--color-white)] [--btn-border:var(--color-white)]/90 [--btn-text:var(--color-grey-800)]",
242
+ "[--btn-fill:var(--color-white)] [--btn-bg:var(--color-white)] [--btn-border:var(--color-white)]/90 [--btn-text:var(--color-grey-800)]",
192
243
  // State: Hover
193
- "[--btn-hover-overlay:var(--color-white)]/10 [--btn-active-overlay:var(--color-white)]/20",
194
244
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-black)]/10",
195
245
  // State: Active
196
246
  "data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
197
247
  ],
198
248
  primary: [
199
249
  // Base
200
- "[--btn-bg:var(--color-primary-800)] [--btn-border:var(--color-primary-800)]/90 [--btn-text:white]",
250
+ "[--btn-fill:var(--color-primary-800)] [--btn-bg:var(--color-primary-800)] [--btn-border:var(--color-primary-800)]/90 [--btn-text:white]",
251
+ // Dark mode: ink
252
+ "dark:[--btn-bg:var(--primary-200)]",
201
253
  // State: Hover
202
- "[--btn-hover-overlay:var(--color-primary-800)]/10 [--btn-active-overlay:var(--color-primary-800)]/20",
203
254
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10",
204
255
  // State: Active
205
256
  "data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
206
257
  ],
207
258
  secondary: [
259
+ // No dark counterpart: `primary-200` already *is* the ink the other
260
+ // colours flip to. Like `white`, this token is surface-conditional — it
261
+ // is meant for dark surfaces, where it lands at 15.40:1. As a non-solid
262
+ // ink on a light one it measures ~1.2:1, so that pairing is misuse
263
+ // rather than a defect to fix here. See the note on the `color` prop.
208
264
  // Base
209
- "[--btn-bg:var(--color-primary-200)] [--btn-border:var(--color-primary-200)]/90 [--btn-text:var(--color-primary-800)]",
265
+ "[--btn-fill:var(--color-primary-200)] [--btn-bg:var(--color-primary-200)] [--btn-border:var(--color-primary-200)]/90 [--btn-text:var(--color-primary-800)]",
210
266
  // State: Hover
211
- "[--btn-hover-overlay:var(--color-primary-200)]/10 [--btn-active-overlay:var(--color-primary-200)]/20",
212
267
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/15",
213
268
  // State: Active
214
269
  "data-[variant=solid]:[--btn-active-overlay:var(--color-primary-800)]/10"
215
270
  ],
216
271
  tertiary: [
217
272
  // Base
218
- "[--btn-bg:var(--color-primary-600)] [--btn-border:var(--color-primary-600)]/90 [--btn-text:white]",
273
+ "[--btn-fill:var(--color-primary-600)] [--btn-bg:var(--color-primary-600)] [--btn-border:var(--color-primary-600)]/90 [--btn-text:white]",
274
+ // Dark mode: ink
275
+ "dark:[--btn-bg:var(--primary-200)]",
219
276
  // State: Hover
220
- "[--btn-hover-overlay:var(--color-primary-600)]/10 [--btn-active-overlay:var(--color-primary-600)]/20",
221
277
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10",
222
278
  // State: Active
223
279
  "data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
224
280
  ],
225
281
  accent: [
226
282
  // Base
227
- "[--btn-bg:var(--color-accent-600)] [--btn-border:var(--color-accent-600)]/90 [--btn-text:white]",
283
+ "[--btn-fill:var(--color-accent-600)] [--btn-bg:var(--color-accent-600)] [--btn-border:var(--color-accent-600)]/90 [--btn-text:white]",
284
+ // Dark mode: ink
285
+ "dark:[--btn-bg:var(--accent-200)]",
228
286
  // State: Hover
229
- "[--btn-hover-overlay:var(--color-accent-600)]/10 [--btn-active-overlay:var(--color-accent-600)]/20",
230
287
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10",
231
288
  // State: Active
232
289
  "data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
@@ -240,27 +297,30 @@ const styles = {
240
297
  // not a Tailwind theme), so they always resolve.
241
298
  danger: [
242
299
  // Base
243
- "[--btn-bg:var(--danger-600)] [--btn-border:var(--danger-600)]/90 [--btn-text:white]",
300
+ "[--btn-fill:var(--danger-600)] [--btn-bg:var(--danger-600)] [--btn-border:var(--danger-600)]/90 [--btn-text:white]",
301
+ // Dark mode: ink
302
+ "dark:[--btn-bg:var(--danger-200)]",
244
303
  // State: Hover
245
- "[--btn-hover-overlay:var(--danger-600)]/10 [--btn-active-overlay:var(--danger-600)]/20",
246
304
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10",
247
305
  // State: Active
248
306
  "data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
249
307
  ],
250
308
  success: [
251
309
  // Base
252
- "[--btn-bg:var(--success-600)] [--btn-border:var(--success-600)]/90 [--btn-text:white]",
310
+ "[--btn-fill:var(--success-600)] [--btn-bg:var(--success-600)] [--btn-border:var(--success-600)]/90 [--btn-text:white]",
311
+ // Dark mode: ink
312
+ "dark:[--btn-bg:var(--success-200)]",
253
313
  // State: Hover
254
- "[--btn-hover-overlay:var(--success-600)]/10 [--btn-active-overlay:var(--success-600)]/20",
255
314
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10",
256
315
  // State: Active
257
316
  "data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
258
317
  ],
259
318
  warning: [
260
319
  // Base
261
- "[--btn-bg:var(--warning-600)] [--btn-border:var(--warning-600)]/90 [--btn-text:white]",
320
+ "[--btn-fill:var(--warning-600)] [--btn-bg:var(--warning-600)] [--btn-border:var(--warning-600)]/90 [--btn-text:white]",
321
+ // Dark mode: ink
322
+ "dark:[--btn-bg:var(--warning-200)]",
262
323
  // State: Hover
263
- "[--btn-hover-overlay:var(--warning-600)]/10 [--btn-active-overlay:var(--warning-600)]/20",
264
324
  "data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10",
265
325
  // State: Active
266
326
  "data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15"
@@ -448,7 +508,14 @@ function warnIfIconButtonUnlabelled(size, iconOnly, props) {
448
508
  }
449
509
  function Button({
450
510
  className,
451
- variant,
511
+ // Defaulted here rather than left to cva's `defaultVariants` so that
512
+ // `data-variant` below is always present in the DOM. cva resolves its own
513
+ // default internally and emits the right classes either way, but the
514
+ // attribute was simply absent — so the `data-[variant=solid]:` state-overlay
515
+ // rules in `styles.colors` never matched a default `<Button>`. It fell
516
+ // through to the derived overlay in `styles.base` and painted `--btn-bg` at
517
+ // 10% over its own fill, which is the same colour: no visible hover at all.
518
+ variant = "solid",
452
519
  color,
453
520
  size,
454
521
  iconOnly,
@@ -504,7 +571,8 @@ function Button({
504
571
  }
505
572
  function ButtonLink({
506
573
  className,
507
- variant,
574
+ // Always emitted as `data-variant` — see the note in `Button`.
575
+ variant = "solid",
508
576
  color,
509
577
  size,
510
578
  iconOnly,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/button.tsx"],"names":["ButtonPrimitive"],"mappings":";;;;;;;;;AAYA,MAAM,MAAA,GAAS;AAAA,EACb,IAAA,EAAM;AAAA;AAAA,IAEJ,uIAAA;AAAA;AAAA;AAAA,IAGA,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,sBAAA;AAAA;AAAA;AAAA;AAAA,IAIA,+EAAA;AAAA;AAAA,IAEA,4DAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,gCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA,GACF;AAAA,EACA,KAAA,EAAO;AAAA;AAAA,IAEL,mBAAA;AAAA;AAAA,IAEA,sCAAA;AAAA;AAAA,IAEA,oBAAA;AAAA;AAAA,IAEA,8GAAA;AAAA;AAAA,IAEA,kBAAA;AAAA;AAAA,IAEA,oBAAA;AAAA;AAAA,IAEA,qBAAA;AAAA;AAAA,IAEA,qFAAA;AAAA;AAAA,IAEA,6EAAA;AAAA;AAAA,IAEA,4CAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,IAAA,EAAM;AAAA;AAAA,IAEJ,iBAAA;AAAA;AAAA,IAEA,qCAAA;AAAA;AAAA,IAEA,uBAAA;AAAA;AAAA,IAEA,iHAAA;AAAA;AAAA,IAEA,kBAAA;AAAA;AAAA,IAEA,wBAAA;AAAA;AAAA,IAEA,qBAAA;AAAA;AAAA,IAEA,qFAAA;AAAA;AAAA,IAEA,6EAAA;AAAA;AAAA,IAEA,4CAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,OAAA,EAAS;AAAA;AAAA,IA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A,QAAA;AAAA,UACC,OAAA;AAAA,UACA,aAAA;AAAA,UACA,cAAA;AAAA,UACA,cAAA;AAAA,UACA,SAAA;AAAA,UACA,KAAA;AAAA,UACA,UAAA;AAAA,UAEC;AAAA;AAAA;AACH;AAAA,GACF;AAEJ;AAKA,SAAS,WAAA,CAAY,EAAE,QAAA,EAAS,EAAkC;AAChE,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAU,8IAAA;AAAA,QACV,aAAA,EAAY;AAAA;AAAA,KACd;AAAA,IACC;AAAA,GAAA,EACH,CAAA;AAEJ","file":"button.js","sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport clsx from 'clsx'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Link } from '../components/link.js'\nimport { Spinner } from '../components/spinner.js'\n\nconst styles = {\n base: [\n // Base\n 'relative isolate inline-flex items-baseline justify-center gap-x-2 rounded-sm border text-base/7 font-bold motion-safe:transition-all',\n // Height floor, published per size step as `--btn-h` (see `styles.size`).\n // A floor rather than a fixed height so a wrapped label can still grow.\n 'min-h-(--btn-h)',\n // Border width, so the size steps can subtract it from their padding and\n // keep the outer box identical across variants. `outline` and `surface`\n // draw a 2px border and raise this to match; everything else stays 1px.\n // Without it the steps subtracted a hard-coded 1px and those two variants\n // came out 2px taller than `solid` at every step and breakpoint.\n '[--btn-border-w:1px]',\n // Focus — deliberately `focus:` (paints on pointer clicks too), unlike\n // Link/Input which use `focus-visible:`. Buttons give click feedback with\n // the ring; links only ring for keyboard/AT focus. Do not \"unify\" this.\n 'focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--btn-bg)',\n // Disabled\n 'data-disabled:opacity-50 data-disabled:pointer-events-none',\n // Glyph size beside a label: one value for every step and breakpoint.\n // Every step sets `text-base/7`, so the label is 16px whatever the step —\n // only the padding changes. An icon next to it has to match the *text*,\n // not the box, so scaling it per step pairs a growing glyph with type that\n // never moves: at `lg` a 28px icon sat beside a 16px word, two and a half\n // times its cap height. 24px is 1.5x the label at every step, and the same\n // number `size='icon'` uses. `iconOnly` overrides this per step in\n // `compoundVariants` — with no label to match, it scales with its box.\n '[--btn-icon-size:--spacing(6)]',\n // Icon. No vertical margin: the glyph is `self-center` in a baseline-aligned\n // row, so margin buys it nothing optically and only inflates the flex line.\n // It was inert at `sm`/`default` (glyph + margin stayed inside the 1.75rem\n // line box) but pushed `lg` 2px past its own height below `sm:`, so a `lg`\n // button measured 70px with an icon and 68px without.\n '*:data-[slot=icon]:-mx-0.25 *:data-[slot=icon]:size-(--btn-icon-size) *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center *:data-[slot=icon]:text-(--btn-icon) forced-colors:[--btn-icon:ButtonText] forced-colors:hover:[--btn-icon:ButtonText]',\n ],\n solid: [\n // Text color\n 'text-(--btn-text)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-border)',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n soft: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-bg)/10',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)/20',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)/10',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:bg-white/5',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n surface: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-(--btn-bg)/50 border-2 bg-(--btn-bg)/5 [--btn-border-w:2px]',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)/30',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)/5',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--btn-bg)/50',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // Border color on hover\n 'active:border-(--btn-bg) hover:border-(--btn-bg)',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n outline: [\n // Text color\n 'border-(--btn-bg) text-(--btn-bg) border-2 [--btn-border-w:2px]',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'bg-transparent',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-transparent',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--btn-bg)',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n ghost: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-transparent)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-transparent)',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n link: [\n // Text color — inherits from color token, no background or border\n 'text-(--btn-bg) border-transparent bg-transparent',\n // Halo tokens derive from the colour token via color-mix, mirroring Link\n '[--link-halo:color-mix(in_oklch,var(--btn-bg)_10%,transparent)]',\n '[--link-halo-active:color-mix(in_oklch,var(--btn-bg)_18%,transparent)]',\n // Resting underline, thickened on interaction — matching Link\n 'underline underline-offset-4 hover:decoration-2 active:decoration-2',\n // Hover / active halos match the GOV.UK-style halo on Link (see link.tsx\n // styledBase): the fill is painted on the `after` layer — consistent with\n // the other variants' hover overlays — and the box-shadow extends it 2px\n // above and 4px below the line box\n 'after:absolute after:inset-0 after:-z-10',\n 'hover:after:bg-(--link-halo) active:after:bg-(--link-halo-active)',\n 'hover:shadow-[0_-2px_0_var(--link-halo),0_4px_0_var(--link-halo)]',\n 'active:shadow-[0_-2px_0_var(--link-halo-active),0_4px_0_var(--link-halo-active)]',\n ],\n colors: {\n grey: [\n // Base\n '[--btn-bg:var(--color-grey-600)] [--btn-border:var(--color-grey-600)]/90 [--btn-text:white]',\n // State: Hover\n '[--btn-hover-overlay:var(--color-grey-600)]/10 [--btn-active-overlay:var(--color-grey-600)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n white: [\n // Base\n '[--btn-bg:var(--color-white)] [--btn-border:var(--color-white)]/90 [--btn-text:var(--color-grey-800)]',\n // State: Hover\n '[--btn-hover-overlay:var(--color-white)]/10 [--btn-active-overlay:var(--color-white)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-black)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n primary: [\n // Base\n '[--btn-bg:var(--color-primary-800)] [--btn-border:var(--color-primary-800)]/90 [--btn-text:white]',\n // State: Hover\n '[--btn-hover-overlay:var(--color-primary-800)]/10 [--btn-active-overlay:var(--color-primary-800)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n secondary: [\n // Base\n '[--btn-bg:var(--color-primary-200)] [--btn-border:var(--color-primary-200)]/90 [--btn-text:var(--color-primary-800)]',\n // State: Hover\n '[--btn-hover-overlay:var(--color-primary-200)]/10 [--btn-active-overlay:var(--color-primary-200)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/15',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-primary-800)]/10',\n ],\n tertiary: [\n // Base\n '[--btn-bg:var(--color-primary-600)] [--btn-border:var(--color-primary-600)]/90 [--btn-text:white]',\n // State: Hover\n '[--btn-hover-overlay:var(--color-primary-600)]/10 [--btn-active-overlay:var(--color-primary-600)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n accent: [\n // Base\n '[--btn-bg:var(--color-accent-600)] [--btn-border:var(--color-accent-600)]/90 [--btn-text:white]',\n // State: Hover\n '[--btn-hover-overlay:var(--color-accent-600)]/10 [--btn-active-overlay:var(--color-accent-600)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n // Semantic colours use the raw NSW token names (--danger-600, --success-600,\n // --warning-600) rather than Tailwind's `--color-*` bridge aliases. The\n // bridge aliases are tree-shaken by Tailwind v4 unless a matching utility\n // class is detected in scanned source, and arbitrary-property usages like\n // `[--btn-bg:var(--color-success-600)]` do NOT count as a usage signal.\n // The raw tokens are defined on :root by @nswds/tokens (a plain CSS import,\n // not a Tailwind theme), so they always resolve.\n danger: [\n // Base\n '[--btn-bg:var(--danger-600)] [--btn-border:var(--danger-600)]/90 [--btn-text:white]',\n // State: Hover\n '[--btn-hover-overlay:var(--danger-600)]/10 [--btn-active-overlay:var(--danger-600)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n success: [\n // Base\n '[--btn-bg:var(--success-600)] [--btn-border:var(--success-600)]/90 [--btn-text:white]',\n // State: Hover\n '[--btn-hover-overlay:var(--success-600)]/10 [--btn-active-overlay:var(--success-600)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n warning: [\n // Base\n '[--btn-bg:var(--warning-600)] [--btn-border:var(--warning-600)]/90 [--btn-text:white]',\n // State: Hover\n '[--btn-hover-overlay:var(--warning-600)]/10 [--btn-active-overlay:var(--warning-600)]/20',\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n },\n // Each step publishes its own height as `--btn-h`, built from the same two\n // numbers that produce its box: one line box (`text-base/7` — Tailwind's\n // `/7` is `--spacing(7)`, so this is the same token, not a matching literal)\n // plus twice the vertical padding. `styles.base` pins it with `min-h`, and\n // `styles.iconOnly` reads it as both dimensions of the square — so an\n // icon-only button is exactly as tall as the text button beside it by\n // construction, and stays that way if a step is ever retuned.\n //\n // The border cancels out of that sum: padding is `--spacing(n) -\n // --btn-border-w` and the border adds `--btn-border-w` back, so every\n // variant lands on `--btn-h` whether it draws a 1px or 2px edge, and the\n // outer geometry stays put while the label shifts 1px to make room.\n //\n // The steps set padding and height only. Glyph size lives on the base (one\n // value beside a label) and in `compoundVariants` (per step when icon-only).\n size: {\n default:\n 'px-[calc(--spacing(6)-var(--btn-border-w))] py-[calc(--spacing(4)-var(--btn-border-w))] sm:px-[calc(--spacing(5.5)-var(--btn-border-w))] sm:py-[calc(--spacing(3)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(4)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(3)*2)]',\n sm: 'px-[calc(--spacing(5)-var(--btn-border-w))] py-[calc(--spacing(3)-var(--btn-border-w))] sm:px-[calc(--spacing(4.5)-var(--btn-border-w))] sm:py-[calc(--spacing(2)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(3)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(2)*2)]',\n lg: 'px-[calc(--spacing(7)-var(--btn-border-w))] py-[calc(--spacing(5)-var(--btn-border-w))] sm:px-[calc(--spacing(6.5)-var(--btn-border-w))] sm:py-[calc(--spacing(4)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(5)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(4)*2)]',\n // A compact chrome square that deliberately sits below the text steps —\n // header actions, dialog close buttons, footer social links. For an icon\n // button that must line up with text buttons beside it, use `iconOnly`\n // with `sm`/`default`/`lg` instead. Its glyph is the base 24px.\n icon: 'w-10 h-10 flex-none [--btn-h:--spacing(10)]',\n },\n // Square the button at the current step and drop the horizontal padding, so\n // the scale step and \"is this icon-only\" are independent axes. The glyph\n // needs no adjustment — the step already sizes it off the ladder.\n iconOnly: 'size-(--btn-h) flex-none p-0 sm:p-0',\n}\n\nconst buttonVariants = cva(styles.base, {\n variants: {\n variant: {\n solid: styles.solid,\n soft: styles.soft,\n surface: styles.surface,\n outline: styles.outline,\n ghost: styles.ghost,\n link: styles.link,\n },\n color: {\n white: styles.colors.white,\n grey: styles.colors.grey,\n primary: styles.colors.primary,\n secondary: styles.colors.secondary,\n tertiary: styles.colors.tertiary,\n accent: styles.colors.accent,\n danger: styles.colors.danger,\n success: styles.colors.success,\n warning: styles.colors.warning,\n },\n size: {\n default: styles.size.default,\n sm: styles.size.sm,\n lg: styles.size.lg,\n icon: styles.size.icon,\n },\n // Declared after `size` so its `p-0` reaches `cn()` downstream of the\n // step's `px-*`/`py-*` and wins the tailwind-merge conflict.\n iconOnly: {\n true: styles.iconOnly,\n false: '',\n },\n },\n compoundVariants: [\n // ── Icon-only glyph sizes ────────────────────────────────────────────\n //\n // With no label beside it the glyph has nothing to match, so here — and\n // only here — it scales with its box, off the icon ladder: 20 / 24 / 28 /\n // 32 / 36 / 40px, i.e. `--spacing(5)` through `--spacing(10)`. Every level\n // is a multiple of 4, so glyphs share the grid with the padding and\n // heights around them and land on whole device pixels at 1x. A discrete\n // ladder rather than a proportion of the box, because a glyph is only\n // crisp at the sizes it was drawn for — \"40% of the box\" would ask for\n // sizes no glyph exists at.\n //\n // One value per step, not per breakpoint: the square never gets smaller\n // on a wider viewport, so neither should what sits inside it.\n { size: 'sm', iconOnly: true, className: '[--btn-icon-size:--spacing(5)]' },\n { size: 'default', iconOnly: true, className: '[--btn-icon-size:--spacing(6)]' },\n { size: 'lg', iconOnly: true, className: '[--btn-icon-size:--spacing(7)]' },\n // The link variant reads as an inline Link despite the <button> tag:\n // strip the button chrome (padding from `size`, border, radius, bold\n // weight) and adopt Link's typography and 1em icon sizing so the hover\n // halo hugs the text instead of filling a button-shaped box.\n {\n variant: 'link',\n className: [\n 'rounded-none border-0 p-0 sm:p-0',\n // Release the step's height floor too — an inline link hugs its line\n // box, it does not stand a button's worth of space tall.\n 'min-h-0',\n // Hug the label even in stretching grid/flex contexts so the hover\n // halo wraps the text like an inline Link, not the allocated box.\n // `block` still wins — its w-full is applied after this in cn().\n 'w-fit',\n 'text-[length:inherit] font-medium',\n '*:data-[slot=icon]:size-[1em]',\n ],\n },\n ],\n defaultVariants: {\n variant: 'solid',\n color: 'primary',\n size: 'default',\n },\n})\n\n/**\n * An icon slot. Takes either form:\n *\n * - the component itself — `leadingVisual={IconDownload}`\n * - a rendered element — `leadingVisual={<IconDownload />}`\n *\n * **From a React Server Component, use the element form.** `Button` and\n * `ButtonLink` are `'use client'` modules, while the icon modules carry no\n * directive — deliberately, so an icon stays server-renderable and ships no\n * JavaScript. That means in a server component `IconDownload` is an ordinary\n * function value, and functions cannot cross the RSC boundary into a client\n * component (\"Functions cannot be passed directly to Client Components\"). A\n * React element can, because it serialises. Client components can use either.\n */\ntype IconSlot = React.ElementType | React.ReactElement\n\n/**\n * Renders an icon slot in whichever form it arrived, stamping `data-slot='icon'`\n * so the `*:data-[slot=icon]:…` rules above size and colour it. An element that\n * sets its own `data-slot` to an actual value keeps it — a consumer who named one\n * deliberately meant it. `undefined` and `null` count as unset and get the stamp,\n * because forwarding an optional prop that happens to be absent is idiomatic React\n * and must not silently strip the icon's sizing and colour.\n *\n * Passing only the key we intend to set is deliberate: `cloneElement` already seeds\n * its props from `slot.props`, so spreading them back into the config would be a\n * no-op — except that React 19 copies every config key across with no undefined-skip\n * (`defaultProps` having been removed), which is exactly how a forwarded\n * `data-slot={undefined}` would erase the stamp.\n */\nfunction renderIconSlot(slot: IconSlot | undefined | null): React.ReactNode {\n if (!slot) return null\n if (React.isValidElement<{ 'data-slot'?: string }>(slot)) {\n return React.cloneElement(slot, { 'data-slot': slot.props['data-slot'] ?? 'icon' })\n }\n // `isValidElement` is a type guard, but its false branch does not subtract\n // ReactElement from the union — TS keeps both members — so name the remaining\n // case explicitly. Anything that is not a valid element is a component type.\n const Icon = slot as React.ElementType\n return <Icon data-slot='icon' />\n}\n\n/** Visual/content props shared by `Button` and `ButtonLink`. */\ntype ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOnly'> & {\n /**\n * Scale step. `sm` / `default` / `lg` render 52 / 60 / 68px tall below\n * `sm:` and 44 / 52 / 60px at or above it. The step changes padding only —\n * the label is 16px and an icon beside it 24px at every step.\n *\n * `icon` is not a fourth step on that ramp — it is a flat 40×40 chrome\n * square (header actions, dialog close buttons, footer social links) that\n * lines up with none of them. For an icon-only button that must sit level\n * with text buttons beside it, pair `iconOnly` with `sm`/`default`/`lg`.\n */\n size?: 'sm' | 'default' | 'lg' | 'icon' | null\n /**\n * Render as a square containing only the icon, at the height of the current\n * `size` step — so `iconOnly` beside a `size='default'` button matches it\n * exactly. Supply an `aria-label`, since there is no visible text.\n *\n * With no label to match, the glyph scales with the square instead of\n * holding the 24px used beside text: 20px at `sm`, 24px at `default`, 28px\n * at `lg`, the same at every breakpoint. For a denser icon button that does\n * not line up with the text steps, use `size='icon'` (24px in a 40×40 box).\n */\n iconOnly?: boolean | null\n className?: string\n /** Button label. Optional for icon-only buttons (supply an `aria-label`). */\n children?: React.ReactNode\n /** Stretch button to fill its container width. */\n block?: boolean\n /** Show a spinner and disable interaction. */\n loading?: boolean\n /** Horizontal alignment of button content. */\n alignContent?: 'center' | 'start'\n disabled?: boolean\n /** Icon rendered before the label. Component or element — see `IconSlot`. */\n leadingVisual?: IconSlot\n /** Icon rendered after the label. Component or element — see `IconSlot`. */\n trailingVisual?: IconSlot\n /** Icon rendered as a trailing action (far end). Component or element. */\n trailingAction?: IconSlot\n /** Allow the button label to wrap onto multiple lines. Defaults to true. */\n labelWrap?: boolean\n /** Optional numeric badge rendered after the label. */\n count?: number\n /**\n * Visually-hidden suffix announced after `count`, giving the bare number\n * context for screen readers (e.g. \"unread messages\" → \"Inbox 3 unread\n * messages\").\n */\n countLabel?: string\n}\n\ntype ButtonProps = ButtonOwnProps & Omit<ButtonPrimitive.Props, 'className' | 'disabled'>\n\ntype ButtonLinkProps = ButtonOwnProps &\n Omit<React.ComponentPropsWithoutRef<typeof Link>, 'className' | 'variant'> & {\n ref?: React.Ref<HTMLAnchorElement>\n }\n\nfunction buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n}: ButtonOwnProps & { effectiveDisabled?: boolean }) {\n return clsx(\n cn(\n buttonVariants({ variant, color, size, iconOnly }),\n block && 'w-full',\n alignContent === 'start' && 'justify-start',\n className,\n ),\n effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer',\n )\n}\n\n/** Shared inner layout: spinner, visuals, label, count, touch target. */\nfunction ButtonContent({\n loading,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n children,\n}: Pick<\n ButtonOwnProps,\n | 'loading'\n | 'leadingVisual'\n | 'trailingVisual'\n | 'trailingAction'\n | 'labelWrap'\n | 'count'\n | 'countLabel'\n | 'children'\n>) {\n return (\n <TouchTarget>\n {loading && (\n <Spinner\n data-slot='icon'\n role={undefined}\n aria-hidden\n color='current'\n // The button's own label + aria-busy convey the busy state; the\n // spinner's default \"Loading\" announcement would be redundant.\n label=''\n // `block` overrides Spinner's default `inline` so the svg isn't\n // pushed below centre by the button's line-height; `size-full` fills\n // the icon-sized, self-centred wrapper span.\n svgClassName='block size-full'\n />\n )}\n {renderIconSlot(leadingVisual)}\n {labelWrap === false ? <span className='whitespace-nowrap'>{children}</span> : children}\n {count !== undefined && (\n <span className='rounded-full px-1.5 py-0.5 text-xs font-medium tabular-nums opacity-75'>\n {count}\n {countLabel ? <span className='sr-only'> {countLabel}</span> : null}\n </span>\n )}\n {renderIconSlot(trailingVisual)}\n {renderIconSlot(trailingAction)}\n </TouchTarget>\n )\n}\n\n/**\n * Dev-only guard shared by `Button` and `ButtonLink`: an icon-only button\n * (`size=\"icon\"` or `iconOnly`) renders no visible text, so it must carry an\n * explicit accessible name. Warns in development when one is missing; a no-op\n * in production. A falsy `aria-label` (including `\"\"`) counts as missing.\n */\nfunction warnIfIconButtonUnlabelled(\n size: ButtonOwnProps['size'],\n iconOnly: ButtonOwnProps['iconOnly'],\n props: { 'aria-label'?: unknown; 'aria-labelledby'?: unknown },\n) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if ((size === 'icon' || iconOnly) && !props['aria-label'] && !props['aria-labelledby']) {\n console.warn(\n '[nswds/ui] Icon-only buttons (size=\"icon\" or iconOnly) have no visible label — pass aria-label or aria-labelledby so the control has an accessible name.',\n )\n }\n}\n\n/**\n * Action button on the Base UI button primitive. For button-styled\n * navigation, use `ButtonLink` — the `href` polymorphism that previously\n * lived on this component was removed in v2.\n *\n * Base UI's `render` prop is available for composition (e.g. rendering a\n * framework-specific element while keeping Button behaviour).\n */\nfunction Button({\n className,\n variant,\n color,\n size,\n iconOnly,\n children,\n block,\n loading,\n alignContent = 'center',\n disabled,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n ref,\n ...props\n}: ButtonProps) {\n const effectiveDisabled = disabled || loading\n\n warnIfIconButtonUnlabelled(size, iconOnly, props)\n\n return (\n <ButtonPrimitive\n data-variant={variant}\n aria-busy={loading || undefined}\n {...props}\n disabled={effectiveDisabled}\n className={buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n })}\n ref={ref}\n >\n <ButtonContent\n loading={loading}\n leadingVisual={leadingVisual}\n trailingVisual={trailingVisual}\n trailingAction={trailingAction}\n labelWrap={labelWrap}\n count={count}\n countLabel={countLabel}\n >\n {children}\n </ButtonContent>\n </ButtonPrimitive>\n )\n}\n\n/**\n * Button-styled anchor. Renders through `Link`, so it picks up the\n * framework link component from `LinkProvider` (e.g. next/link) and accepts\n * all anchor props. Disabled/loading states are conveyed with\n * `aria-disabled` and a click guard, since anchors have no `disabled`\n * attribute.\n */\nfunction ButtonLink({\n className,\n variant,\n color,\n size,\n iconOnly,\n children,\n block,\n loading,\n alignContent = 'center',\n disabled,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n ref,\n ...props\n}: ButtonLinkProps) {\n const effectiveDisabled = disabled || loading\n\n warnIfIconButtonUnlabelled(size, iconOnly, props)\n\n return (\n <Link\n // Opt out of Link's built-in styling — ButtonLink supplies its own\n // complete visual treatment (background, border, focus ring, icon\n // sizing) and any Link styling layered on top would conflict.\n variant='unstyled'\n data-variant={variant}\n aria-busy={loading || undefined}\n {...props}\n {...(effectiveDisabled\n ? {\n 'aria-disabled': true,\n 'data-disabled': '',\n tabIndex: -1,\n onClick: (e: React.MouseEvent<HTMLAnchorElement>) => e.preventDefault(),\n }\n : {})}\n className={buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n })}\n ref={ref}\n >\n <ButtonContent\n loading={loading}\n leadingVisual={leadingVisual}\n trailingVisual={trailingVisual}\n trailingAction={trailingAction}\n labelWrap={labelWrap}\n count={count}\n countLabel={countLabel}\n >\n {children}\n </ButtonContent>\n </Link>\n )\n}\n\n/**\n * Expand the hit area to at least 44×44px on touch devices\n */\nfunction TouchTarget({ children }: { children: React.ReactNode }) {\n return (\n <>\n <span\n className='absolute top-1/2 left-1/2 size-[max(100%,2.75rem)] -translate-x-1/2 -translate-y-1/2 rounded-sm bg-transparent [@media(pointer:fine)]:hidden'\n aria-hidden='true'\n />\n {children}\n </>\n )\n}\n\nexport { Button, ButtonLink, buttonVariants, TouchTarget }\nexport type { ButtonLinkProps, ButtonProps, IconSlot }\n"]}
1
+ {"version":3,"sources":["../../src/components/button.tsx"],"names":["ButtonPrimitive"],"mappings":";;;;;;;;;AAYA,MAAM,MAAA,GAAS;AAAA,EACb,IAAA,EAAM;AAAA;AAAA,IAEJ,uIAAA;AAAA;AAAA;AAAA,IAGA,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,sBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,+EAAA;AAAA;AAAA,IAEA,4DAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,yEAAA;AAAA,IACA,0EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,gCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA,GACF;AAAA,EACA,KAAA,EAAO;AAAA;AAAA,IAEL,mBAAA;AAAA;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MAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAU,8IAAA;AAAA,QACV,aAAA,EAAY;AAAA;AAAA,KACd;AAAA,IACC;AAAA,GAAA,EACH,CAAA;AAEJ","file":"button.js","sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport clsx from 'clsx'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Link } from '../components/link.js'\nimport { Spinner } from '../components/spinner.js'\n\nconst styles = {\n base: [\n // Base\n 'relative isolate inline-flex items-baseline justify-center gap-x-2 rounded-sm border text-base/7 font-bold motion-safe:transition-all',\n // Height floor, published per size step as `--btn-h` (see `styles.size`).\n // A floor rather than a fixed height so a wrapped label can still grow.\n 'min-h-(--btn-h)',\n // Border width, so the size steps can subtract it from their padding and\n // keep the outer box identical across variants. `outline` and `surface`\n // draw a 2px border and raise this to match; everything else stays 1px.\n // Without it the steps subtracted a hard-coded 1px and those two variants\n // came out 2px taller than `solid` at every step and breakpoint.\n '[--btn-border-w:1px]',\n // Focus — deliberately `focus:` (paints on pointer clicks too), unlike\n // Link/Input which use `focus-visible:`. Buttons give click feedback with\n // the ring; links only ring for keyboard/AT focus. Do not \"unify\" this.\n // The ring is offset 2px, so it lands on the *page* rather than on the\n // button. `--btn-bg` is the ink (see the note above `styles.colors`), which\n // flips for dark mode, so the ring follows the theme for every variant —\n // including `solid`, whose ring used to be its own fill colour and so went\n // near-invisible on a dark surface.\n 'focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--btn-bg)',\n // Disabled\n 'data-disabled:opacity-50 data-disabled:pointer-events-none',\n // State overlays, derived from the ink rather than restated per colour.\n // Deriving them means they follow `--btn-bg` wherever it comes from: the\n // colour token, its dark-mode counterpart, or a surface that re-points the\n // ink at its own (`[--btn-bg:var(--footer-ink)]` in footer.tsx and\n // footer-cta.tsx). `solid` overrides both with its white/black pair at\n // `data-[variant=solid]:` — an attribute selector, so it outranks these\n // regardless of source order. `oklab` matches the interpolation space\n // Tailwind's own `/10` alpha modifier emits, so the painted colour is\n // unchanged from when each colour restated these itself.\n '[--btn-hover-overlay:color-mix(in_oklab,var(--btn-bg)_10%,transparent)]',\n '[--btn-active-overlay:color-mix(in_oklab,var(--btn-bg)_20%,transparent)]',\n // Glyph size beside a label: one value for every step and breakpoint.\n // Every step sets `text-base/7`, so the label is 16px whatever the step —\n // only the padding changes. An icon next to it has to match the *text*,\n // not the box, so scaling it per step pairs a growing glyph with type that\n // never moves: at `lg` a 28px icon sat beside a 16px word, two and a half\n // times its cap height. 24px is 1.5x the label at every step, and the same\n // number `size='icon'` uses. `iconOnly` overrides this per step in\n // `compoundVariants` — with no label to match, it scales with its box.\n '[--btn-icon-size:--spacing(6)]',\n // Icon. No vertical margin: the glyph is `self-center` in a baseline-aligned\n // row, so margin buys it nothing optically and only inflates the flex line.\n // It was inert at `sm`/`default` (glyph + margin stayed inside the 1.75rem\n // line box) but pushed `lg` 2px past its own height below `sm:`, so a `lg`\n // button measured 70px with an icon and 68px without.\n '*:data-[slot=icon]:-mx-0.25 *:data-[slot=icon]:size-(--btn-icon-size) *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center *:data-[slot=icon]:text-(--btn-icon) forced-colors:[--btn-icon:ButtonText] forced-colors:hover:[--btn-icon:ButtonText]',\n ],\n solid: [\n // Text color\n 'text-(--btn-text)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-border)',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-fill)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-fill)',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n soft: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-bg)/10',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)/20',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)/10',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:bg-white/5',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n surface: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-(--btn-bg)/50 border-2 bg-(--btn-bg)/5 [--btn-border-w:2px]',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)/30',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)/5',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--btn-bg)/50',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // Border color on hover\n 'active:border-(--btn-bg) hover:border-(--btn-bg)',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n outline: [\n // Text color\n 'border-(--btn-bg) text-(--btn-bg) border-2 [--btn-border-w:2px]',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'bg-transparent',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-transparent',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--btn-bg)',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n ghost: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-transparent)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-transparent)',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n link: [\n // Text color — inherits from color token, no background or border\n 'text-(--btn-bg) border-transparent bg-transparent',\n // Halo tokens derive from the colour token via color-mix, mirroring Link\n '[--link-halo:color-mix(in_oklch,var(--btn-bg)_10%,transparent)]',\n '[--link-halo-active:color-mix(in_oklch,var(--btn-bg)_18%,transparent)]',\n // Resting underline, thickened on interaction — matching Link\n 'underline underline-offset-4 hover:decoration-2 active:decoration-2',\n // Hover / active halos match the GOV.UK-style halo on Link (see link.tsx\n // styledBase): the fill is painted on the `after` layer — consistent with\n // the other variants' hover overlays — and the box-shadow extends it 2px\n // above and 4px below the line box\n 'after:absolute after:inset-0 after:-z-10',\n 'hover:after:bg-(--link-halo) active:after:bg-(--link-halo-active)',\n 'hover:shadow-[0_-2px_0_var(--link-halo),0_4px_0_var(--link-halo)]',\n 'active:shadow-[0_-2px_0_var(--link-halo-active),0_4px_0_var(--link-halo-active)]',\n ],\n // Two variables, deliberately separate.\n //\n // `--btn-fill` is the block of colour `solid` paints behind `--btn-text`.\n // `--btn-bg` is the *ink*: the glyph and label on every non-solid variant\n // (`text-(--btn-bg)`), the border on `outline`/`surface`, the tint on\n // `soft`/`surface`, the `link` halos, the state overlays derived in\n // `styles.base`, and the focus ring. They start life the same colour, and\n // only part company in dark mode.\n //\n // They used to be one variable, which made the ink un-flippable. The values\n // here are masterbrand palette steps, and palette steps are theme-invariant —\n // `styles.css` re-declares only the *semantic* tokens under\n // `[data-theme=dark], .dark`. Design-system surfaces do flip, though\n // (`Header color='white'` is `bg-white dark:bg-grey-900`), so a non-solid\n // button kept its light-mode ink on a dark surface: `primary-800` on\n // `grey-900` measures 1.32:1, far under the 3:1 WCAG 1.4.11 asks of a UI\n // component, with the overlays and focus ring unpainted for the same reason.\n // Splitting the fill off means `--btn-bg` can flip on its own without\n // repainting `solid`, so the dark counterparts below need no variant scoping\n // and stay at single-class specificity — which is what keeps them overridable\n // by a surface that imposes its own ink (`[--btn-bg:var(--footer-ink)]` in\n // footer.tsx and footer-cta.tsx). Raising their specificity would silently\n // win against those, so keep any future dark value a bare `dark:` utility.\n //\n // `-200` is the package's established ink-on-dark (`--link-color`,\n // `--main-nav-panel-ink`) and clears 10:1 against every dark surface token.\n // `white` and `secondary` are already light inks, so they have no counterpart.\n //\n // Dark values use the raw NSW tokens for the tree-shaking reason spelled out\n // above `danger` below.\n colors: {\n grey: [\n // Base\n '[--btn-fill:var(--color-grey-600)] [--btn-bg:var(--color-grey-600)] [--btn-border:var(--color-grey-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--grey-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n white: [\n // No dark counterpart: white is already the maximum-contrast ink on any\n // dark surface. Surface-conditional in the same way as `secondary` — on a\n // light surface a non-solid `white` button is white on white. See the\n // note on the `color` prop.\n // Base\n '[--btn-fill:var(--color-white)] [--btn-bg:var(--color-white)] [--btn-border:var(--color-white)]/90 [--btn-text:var(--color-grey-800)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-black)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n primary: [\n // Base\n '[--btn-fill:var(--color-primary-800)] [--btn-bg:var(--color-primary-800)] [--btn-border:var(--color-primary-800)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--primary-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n secondary: [\n // No dark counterpart: `primary-200` already *is* the ink the other\n // colours flip to. Like `white`, this token is surface-conditional — it\n // is meant for dark surfaces, where it lands at 15.40:1. As a non-solid\n // ink on a light one it measures ~1.2:1, so that pairing is misuse\n // rather than a defect to fix here. See the note on the `color` prop.\n // Base\n '[--btn-fill:var(--color-primary-200)] [--btn-bg:var(--color-primary-200)] [--btn-border:var(--color-primary-200)]/90 [--btn-text:var(--color-primary-800)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/15',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-primary-800)]/10',\n ],\n tertiary: [\n // Base\n '[--btn-fill:var(--color-primary-600)] [--btn-bg:var(--color-primary-600)] [--btn-border:var(--color-primary-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--primary-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n accent: [\n // Base\n '[--btn-fill:var(--color-accent-600)] [--btn-bg:var(--color-accent-600)] [--btn-border:var(--color-accent-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--accent-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n // Semantic colours use the raw NSW token names (--danger-600, --success-600,\n // --warning-600) rather than Tailwind's `--color-*` bridge aliases. The\n // bridge aliases are tree-shaken by Tailwind v4 unless a matching utility\n // class is detected in scanned source, and arbitrary-property usages like\n // `[--btn-bg:var(--color-success-600)]` do NOT count as a usage signal.\n // The raw tokens are defined on :root by @nswds/tokens (a plain CSS import,\n // not a Tailwind theme), so they always resolve.\n danger: [\n // Base\n '[--btn-fill:var(--danger-600)] [--btn-bg:var(--danger-600)] [--btn-border:var(--danger-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--danger-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n success: [\n // Base\n '[--btn-fill:var(--success-600)] [--btn-bg:var(--success-600)] [--btn-border:var(--success-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--success-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n warning: [\n // Base\n '[--btn-fill:var(--warning-600)] [--btn-bg:var(--warning-600)] [--btn-border:var(--warning-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--warning-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n },\n // Each step publishes its own height as `--btn-h`, built from the same two\n // numbers that produce its box: one line box (`text-base/7` — Tailwind's\n // `/7` is `--spacing(7)`, so this is the same token, not a matching literal)\n // plus twice the vertical padding. `styles.base` pins it with `min-h`, and\n // `styles.iconOnly` reads it as both dimensions of the square — so an\n // icon-only button is exactly as tall as the text button beside it by\n // construction, and stays that way if a step is ever retuned.\n //\n // The border cancels out of that sum: padding is `--spacing(n) -\n // --btn-border-w` and the border adds `--btn-border-w` back, so every\n // variant lands on `--btn-h` whether it draws a 1px or 2px edge, and the\n // outer geometry stays put while the label shifts 1px to make room.\n //\n // The steps set padding and height only. Glyph size lives on the base (one\n // value beside a label) and in `compoundVariants` (per step when icon-only).\n size: {\n default:\n 'px-[calc(--spacing(6)-var(--btn-border-w))] py-[calc(--spacing(4)-var(--btn-border-w))] sm:px-[calc(--spacing(5.5)-var(--btn-border-w))] sm:py-[calc(--spacing(3)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(4)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(3)*2)]',\n sm: 'px-[calc(--spacing(5)-var(--btn-border-w))] py-[calc(--spacing(3)-var(--btn-border-w))] sm:px-[calc(--spacing(4.5)-var(--btn-border-w))] sm:py-[calc(--spacing(2)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(3)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(2)*2)]',\n lg: 'px-[calc(--spacing(7)-var(--btn-border-w))] py-[calc(--spacing(5)-var(--btn-border-w))] sm:px-[calc(--spacing(6.5)-var(--btn-border-w))] sm:py-[calc(--spacing(4)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(5)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(4)*2)]',\n // A compact chrome square that deliberately sits below the text steps —\n // header actions, dialog close buttons, footer social links. For an icon\n // button that must line up with text buttons beside it, use `iconOnly`\n // with `sm`/`default`/`lg` instead. Its glyph is the base 24px.\n icon: 'w-10 h-10 flex-none [--btn-h:--spacing(10)]',\n },\n // Square the button at the current step and drop the horizontal padding, so\n // the scale step and \"is this icon-only\" are independent axes. The glyph\n // needs no adjustment — the step already sizes it off the ladder.\n iconOnly: 'size-(--btn-h) flex-none p-0 sm:p-0',\n}\n\nconst buttonVariants = cva(styles.base, {\n variants: {\n variant: {\n solid: styles.solid,\n soft: styles.soft,\n surface: styles.surface,\n outline: styles.outline,\n ghost: styles.ghost,\n link: styles.link,\n },\n color: {\n white: styles.colors.white,\n grey: styles.colors.grey,\n primary: styles.colors.primary,\n secondary: styles.colors.secondary,\n tertiary: styles.colors.tertiary,\n accent: styles.colors.accent,\n danger: styles.colors.danger,\n success: styles.colors.success,\n warning: styles.colors.warning,\n },\n size: {\n default: styles.size.default,\n sm: styles.size.sm,\n lg: styles.size.lg,\n icon: styles.size.icon,\n },\n // Declared after `size` so its `p-0` reaches `cn()` downstream of the\n // step's `px-*`/`py-*` and wins the tailwind-merge conflict.\n iconOnly: {\n true: styles.iconOnly,\n false: '',\n },\n },\n compoundVariants: [\n // ── Icon-only glyph sizes ────────────────────────────────────────────\n //\n // With no label beside it the glyph has nothing to match, so here — and\n // only here — it scales with its box, off the icon ladder: 20 / 24 / 28 /\n // 32 / 36 / 40px, i.e. `--spacing(5)` through `--spacing(10)`. Every level\n // is a multiple of 4, so glyphs share the grid with the padding and\n // heights around them and land on whole device pixels at 1x. A discrete\n // ladder rather than a proportion of the box, because a glyph is only\n // crisp at the sizes it was drawn for — \"40% of the box\" would ask for\n // sizes no glyph exists at.\n //\n // One value per step, not per breakpoint: the square never gets smaller\n // on a wider viewport, so neither should what sits inside it.\n { size: 'sm', iconOnly: true, className: '[--btn-icon-size:--spacing(5)]' },\n { size: 'default', iconOnly: true, className: '[--btn-icon-size:--spacing(6)]' },\n { size: 'lg', iconOnly: true, className: '[--btn-icon-size:--spacing(7)]' },\n // The link variant reads as an inline Link despite the <button> tag:\n // strip the button chrome (padding from `size`, border, radius, bold\n // weight) and adopt Link's typography and 1em icon sizing so the hover\n // halo hugs the text instead of filling a button-shaped box.\n {\n variant: 'link',\n className: [\n 'rounded-none border-0 p-0 sm:p-0',\n // Release the step's height floor too — an inline link hugs its line\n // box, it does not stand a button's worth of space tall.\n 'min-h-0',\n // Hug the label even in stretching grid/flex contexts so the hover\n // halo wraps the text like an inline Link, not the allocated box.\n // `block` still wins — its w-full is applied after this in cn().\n 'w-fit',\n 'text-[length:inherit] font-medium',\n '*:data-[slot=icon]:size-[1em]',\n ],\n },\n ],\n defaultVariants: {\n variant: 'solid',\n color: 'primary',\n size: 'default',\n },\n})\n\n/**\n * An icon slot. Takes either form:\n *\n * - the component itself — `leadingVisual={IconDownload}`\n * - a rendered element — `leadingVisual={<IconDownload />}`\n *\n * **From a React Server Component, use the element form.** `Button` and\n * `ButtonLink` are `'use client'` modules, while the icon modules carry no\n * directive — deliberately, so an icon stays server-renderable and ships no\n * JavaScript. That means in a server component `IconDownload` is an ordinary\n * function value, and functions cannot cross the RSC boundary into a client\n * component (\"Functions cannot be passed directly to Client Components\"). A\n * React element can, because it serialises. Client components can use either.\n */\ntype IconSlot = React.ElementType | React.ReactElement\n\n/**\n * Renders an icon slot in whichever form it arrived, stamping `data-slot='icon'`\n * so the `*:data-[slot=icon]:…` rules above size and colour it. An element that\n * sets its own `data-slot` to an actual value keeps it — a consumer who named one\n * deliberately meant it. `undefined` and `null` count as unset and get the stamp,\n * because forwarding an optional prop that happens to be absent is idiomatic React\n * and must not silently strip the icon's sizing and colour.\n *\n * Passing only the key we intend to set is deliberate: `cloneElement` already seeds\n * its props from `slot.props`, so spreading them back into the config would be a\n * no-op — except that React 19 copies every config key across with no undefined-skip\n * (`defaultProps` having been removed), which is exactly how a forwarded\n * `data-slot={undefined}` would erase the stamp.\n */\nfunction renderIconSlot(slot: IconSlot | undefined | null): React.ReactNode {\n if (!slot) return null\n if (React.isValidElement<{ 'data-slot'?: string }>(slot)) {\n return React.cloneElement(slot, { 'data-slot': slot.props['data-slot'] ?? 'icon' })\n }\n // `isValidElement` is a type guard, but its false branch does not subtract\n // ReactElement from the union — TS keeps both members — so name the remaining\n // case explicitly. Anything that is not a valid element is a component type.\n const Icon = slot as React.ElementType\n return <Icon data-slot='icon' />\n}\n\n/** Visual/content props shared by `Button` and `ButtonLink`. */\ntype ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOnly' | 'color'> & {\n /**\n * Colour token. Most are safe on any surface: the non-solid variants take\n * their ink from the token and it flips for dark mode, so `primary` reads\n * correctly on a light page and on a dark one.\n *\n * `white` and `secondary` are the exceptions — both are\n * **surface-conditional, for dark surfaces only**. Their inks (`white` and\n * `primary-200`) are already light, which is what makes them right on a\n * dark surface and unusable on a light one: a non-solid button in either\n * colour measures around 1.2:1 on white, against the 3:1 WCAG 1.4.11 asks\n * of a UI component. Reach for them the way `Hero` does — over a\n * `primary-800` panel — and use `primary` on a light or theme-flipping\n * surface. `solid` is unaffected either way, since it pairs `--btn-fill`\n * with `--btn-text` rather than painting the ink.\n */\n color?:\n | 'white'\n | 'grey'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'accent'\n | 'danger'\n | 'success'\n | 'warning'\n | null\n /**\n * Scale step. `sm` / `default` / `lg` render 52 / 60 / 68px tall below\n * `sm:` and 44 / 52 / 60px at or above it. The step changes padding only —\n * the label is 16px and an icon beside it 24px at every step.\n *\n * `icon` is not a fourth step on that ramp — it is a flat 40×40 chrome\n * square (header actions, dialog close buttons, footer social links) that\n * lines up with none of them. For an icon-only button that must sit level\n * with text buttons beside it, pair `iconOnly` with `sm`/`default`/`lg`.\n */\n size?: 'sm' | 'default' | 'lg' | 'icon' | null\n /**\n * Render as a square containing only the icon, at the height of the current\n * `size` step — so `iconOnly` beside a `size='default'` button matches it\n * exactly. Supply an `aria-label`, since there is no visible text.\n *\n * With no label to match, the glyph scales with the square instead of\n * holding the 24px used beside text: 20px at `sm`, 24px at `default`, 28px\n * at `lg`, the same at every breakpoint. For a denser icon button that does\n * not line up with the text steps, use `size='icon'` (24px in a 40×40 box).\n */\n iconOnly?: boolean | null\n className?: string\n /** Button label. Optional for icon-only buttons (supply an `aria-label`). */\n children?: React.ReactNode\n /** Stretch button to fill its container width. */\n block?: boolean\n /** Show a spinner and disable interaction. */\n loading?: boolean\n /** Horizontal alignment of button content. */\n alignContent?: 'center' | 'start'\n disabled?: boolean\n /** Icon rendered before the label. Component or element — see `IconSlot`. */\n leadingVisual?: IconSlot\n /** Icon rendered after the label. Component or element — see `IconSlot`. */\n trailingVisual?: IconSlot\n /** Icon rendered as a trailing action (far end). Component or element. */\n trailingAction?: IconSlot\n /** Allow the button label to wrap onto multiple lines. Defaults to true. */\n labelWrap?: boolean\n /** Optional numeric badge rendered after the label. */\n count?: number\n /**\n * Visually-hidden suffix announced after `count`, giving the bare number\n * context for screen readers (e.g. \"unread messages\" → \"Inbox 3 unread\n * messages\").\n */\n countLabel?: string\n}\n\ntype ButtonProps = ButtonOwnProps & Omit<ButtonPrimitive.Props, 'className' | 'disabled'>\n\ntype ButtonLinkProps = ButtonOwnProps &\n Omit<React.ComponentPropsWithoutRef<typeof Link>, 'className' | 'variant'> & {\n ref?: React.Ref<HTMLAnchorElement>\n }\n\nfunction buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n}: ButtonOwnProps & { effectiveDisabled?: boolean }) {\n return clsx(\n cn(\n buttonVariants({ variant, color, size, iconOnly }),\n block && 'w-full',\n alignContent === 'start' && 'justify-start',\n className,\n ),\n effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer',\n )\n}\n\n/** Shared inner layout: spinner, visuals, label, count, touch target. */\nfunction ButtonContent({\n loading,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n children,\n}: Pick<\n ButtonOwnProps,\n | 'loading'\n | 'leadingVisual'\n | 'trailingVisual'\n | 'trailingAction'\n | 'labelWrap'\n | 'count'\n | 'countLabel'\n | 'children'\n>) {\n return (\n <TouchTarget>\n {loading && (\n <Spinner\n data-slot='icon'\n role={undefined}\n aria-hidden\n color='current'\n // The button's own label + aria-busy convey the busy state; the\n // spinner's default \"Loading\" announcement would be redundant.\n label=''\n // `block` overrides Spinner's default `inline` so the svg isn't\n // pushed below centre by the button's line-height; `size-full` fills\n // the icon-sized, self-centred wrapper span.\n svgClassName='block size-full'\n />\n )}\n {renderIconSlot(leadingVisual)}\n {labelWrap === false ? <span className='whitespace-nowrap'>{children}</span> : children}\n {count !== undefined && (\n <span className='rounded-full px-1.5 py-0.5 text-xs font-medium tabular-nums opacity-75'>\n {count}\n {countLabel ? <span className='sr-only'> {countLabel}</span> : null}\n </span>\n )}\n {renderIconSlot(trailingVisual)}\n {renderIconSlot(trailingAction)}\n </TouchTarget>\n )\n}\n\n/**\n * Dev-only guard shared by `Button` and `ButtonLink`: an icon-only button\n * (`size=\"icon\"` or `iconOnly`) renders no visible text, so it must carry an\n * explicit accessible name. Warns in development when one is missing; a no-op\n * in production. A falsy `aria-label` (including `\"\"`) counts as missing.\n */\nfunction warnIfIconButtonUnlabelled(\n size: ButtonOwnProps['size'],\n iconOnly: ButtonOwnProps['iconOnly'],\n props: { 'aria-label'?: unknown; 'aria-labelledby'?: unknown },\n) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if ((size === 'icon' || iconOnly) && !props['aria-label'] && !props['aria-labelledby']) {\n console.warn(\n '[nswds/ui] Icon-only buttons (size=\"icon\" or iconOnly) have no visible label — pass aria-label or aria-labelledby so the control has an accessible name.',\n )\n }\n}\n\n/**\n * Action button on the Base UI button primitive. For button-styled\n * navigation, use `ButtonLink` — the `href` polymorphism that previously\n * lived on this component was removed in v2.\n *\n * Base UI's `render` prop is available for composition (e.g. rendering a\n * framework-specific element while keeping Button behaviour).\n */\nfunction Button({\n className,\n // Defaulted here rather than left to cva's `defaultVariants` so that\n // `data-variant` below is always present in the DOM. cva resolves its own\n // default internally and emits the right classes either way, but the\n // attribute was simply absent — so the `data-[variant=solid]:` state-overlay\n // rules in `styles.colors` never matched a default `<Button>`. It fell\n // through to the derived overlay in `styles.base` and painted `--btn-bg` at\n // 10% over its own fill, which is the same colour: no visible hover at all.\n variant = 'solid',\n color,\n size,\n iconOnly,\n children,\n block,\n loading,\n alignContent = 'center',\n disabled,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n ref,\n ...props\n}: ButtonProps) {\n const effectiveDisabled = disabled || loading\n\n warnIfIconButtonUnlabelled(size, iconOnly, props)\n\n return (\n <ButtonPrimitive\n data-variant={variant}\n aria-busy={loading || undefined}\n {...props}\n disabled={effectiveDisabled}\n className={buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n })}\n ref={ref}\n >\n <ButtonContent\n loading={loading}\n leadingVisual={leadingVisual}\n trailingVisual={trailingVisual}\n trailingAction={trailingAction}\n labelWrap={labelWrap}\n count={count}\n countLabel={countLabel}\n >\n {children}\n </ButtonContent>\n </ButtonPrimitive>\n )\n}\n\n/**\n * Button-styled anchor. Renders through `Link`, so it picks up the\n * framework link component from `LinkProvider` (e.g. next/link) and accepts\n * all anchor props. Disabled/loading states are conveyed with\n * `aria-disabled` and a click guard, since anchors have no `disabled`\n * attribute.\n */\nfunction ButtonLink({\n className,\n // Always emitted as `data-variant` — see the note in `Button`.\n variant = 'solid',\n color,\n size,\n iconOnly,\n children,\n block,\n loading,\n alignContent = 'center',\n disabled,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n ref,\n ...props\n}: ButtonLinkProps) {\n const effectiveDisabled = disabled || loading\n\n warnIfIconButtonUnlabelled(size, iconOnly, props)\n\n return (\n <Link\n // Opt out of Link's built-in styling — ButtonLink supplies its own\n // complete visual treatment (background, border, focus ring, icon\n // sizing) and any Link styling layered on top would conflict.\n variant='unstyled'\n data-variant={variant}\n aria-busy={loading || undefined}\n {...props}\n {...(effectiveDisabled\n ? {\n 'aria-disabled': true,\n 'data-disabled': '',\n tabIndex: -1,\n onClick: (e: React.MouseEvent<HTMLAnchorElement>) => e.preventDefault(),\n }\n : {})}\n className={buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n })}\n ref={ref}\n >\n <ButtonContent\n loading={loading}\n leadingVisual={leadingVisual}\n trailingVisual={trailingVisual}\n trailingAction={trailingAction}\n labelWrap={labelWrap}\n count={count}\n countLabel={countLabel}\n >\n {children}\n </ButtonContent>\n </Link>\n )\n}\n\n/**\n * Expand the hit area to at least 44×44px on touch devices\n */\nfunction TouchTarget({ children }: { children: React.ReactNode }) {\n return (\n <>\n <span\n className='absolute top-1/2 left-1/2 size-[max(100%,2.75rem)] -translate-x-1/2 -translate-y-1/2 rounded-sm bg-transparent [@media(pointer:fine)]:hidden'\n aria-hidden='true'\n />\n {children}\n </>\n )\n}\n\nexport { Button, ButtonLink, buttonVariants, TouchTarget }\nexport type { ButtonLinkProps, ButtonProps, IconSlot }\n"]}
@@ -110,7 +110,7 @@ const footerLinkClassName = [
110
110
  "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--footer-ink)"
111
111
  ].join(" ");
112
112
  const footerSocialLinkClassName = [
113
- "[--btn-bg:var(--footer-ink)]",
113
+ "[--btn-bg:var(--footer-ink)] dark:[--btn-bg:var(--footer-ink)]",
114
114
  "[--btn-icon:var(--footer-ink)]",
115
115
  "[--btn-transparent:transparent]",
116
116
  "[--btn-hover-overlay:var(--footer-halo)]",