@nswds/ui 4.7.0 → 4.7.2

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.
Files changed (42) hide show
  1. package/README.md +23 -4
  2. package/dist/components/badge.d.ts +1 -1
  3. package/dist/components/badge.js +1 -1
  4. package/dist/components/badge.js.map +1 -1
  5. package/dist/components/button.d.ts +3 -3
  6. package/dist/components/button.js +1 -1
  7. package/dist/components/button.js.map +1 -1
  8. package/dist/components/expandable-search.js +2 -2
  9. package/dist/components/expandable-search.js.map +1 -1
  10. package/dist/components/field.js +1 -1
  11. package/dist/components/field.js.map +1 -1
  12. package/dist/components/footer.js +11 -8
  13. package/dist/components/footer.js.map +1 -1
  14. package/dist/components/header.d.ts +1 -1
  15. package/dist/components/header.js +9 -6
  16. package/dist/components/header.js.map +1 -1
  17. package/dist/components/input.js +1 -1
  18. package/dist/components/input.js.map +1 -1
  19. package/dist/components/link.d.ts +1 -1
  20. package/dist/components/link.js +1 -1
  21. package/dist/components/link.js.map +1 -1
  22. package/dist/components/main-nav.js +4 -4
  23. package/dist/components/main-nav.js.map +1 -1
  24. package/dist/components/masthead.d.ts +1 -1
  25. package/dist/components/navigation-menu.js +7 -7
  26. package/dist/components/navigation-menu.js.map +1 -1
  27. package/dist/components/push-menu.d.ts +5 -5
  28. package/dist/components/push-menu.js +2 -2
  29. package/dist/components/push-menu.js.map +1 -1
  30. package/dist/components/side-nav.js +5 -5
  31. package/dist/components/side-nav.js.map +1 -1
  32. package/dist/components/site-search.js +2 -2
  33. package/dist/components/site-search.js.map +1 -1
  34. package/dist/components/skip-link.d.ts +1 -1
  35. package/dist/components/skip-link.js +1 -1
  36. package/dist/components/skip-link.js.map +1 -1
  37. package/dist/components/spinner.js +1 -1
  38. package/dist/components/spinner.js.map +1 -1
  39. package/dist/components/step-indicator.js +5 -5
  40. package/dist/components/step-indicator.js.map +1 -1
  41. package/dist/styles.css +1 -1
  42. package/package.json +3 -2
package/README.md CHANGED
@@ -28,20 +28,39 @@ export default function Demo() {
28
28
 
29
29
  `@nswds/ui/styles.css` ships the full token foundation (NSW palette, masterbrand theme, semantic tokens) plus all component styles, so components render correctly with no extra wiring.
30
30
 
31
- ### Import it last
31
+ ### Import order
32
32
 
33
- If your app also imports the `@nswds/tokens` Tailwind bridges — you only need them when your **own** Tailwind build has to know the NSW scales, so `bg-primary-800` or `text-text-muted` written in your code resolves — put `@nswds/ui/styles.css` **after** them:
33
+ If your app also imports the `@nswds/tokens` Tailwind bridges — you only need them when your **own** Tailwind build has to know the NSW scales, so `bg-primary-800` or `text-text-muted` written in your code resolves — put `@nswds/ui/styles.css` **after** them, and your own Tailwind build after that:
34
34
 
35
35
  ```css
36
36
  /* Bridges first: they teach your Tailwind build the NSW scales. */
37
37
  @import '@nswds/tokens/tailwind/colors/global/oklch.css';
38
38
  @import '@nswds/tokens/tailwind/colors/semantic/oklch.css';
39
39
 
40
- /* @nswds/ui last: it is the only one of these that carries dark mode. */
40
+ /* @nswds/ui after the bridges: it is the only one of them that carries dark mode. */
41
41
  @import '@nswds/ui/styles.css';
42
+
43
+ /* Your own Tailwind build last — see the next section. */
44
+ @import 'tailwindcss';
45
+ ```
46
+
47
+ 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.
48
+
49
+ ### Using it with your own Tailwind build
50
+
51
+ `@import 'tailwindcss'` goes last for a different reason: it leaves you with two independently-sorted sets of utilities in the same `utilities` cascade layer, and a media query adds no specificity. Within one Tailwind build the sorter guarantees `.lg\:justify-start` is emitted after `.justify-center`; across two builds nothing does, so whichever half comes last wins any tie. Ours going first means your utilities win those ties, which is what you want: a class you wrote should beat one you didn't.
52
+
53
+ Reverse it and the same mechanism works against you — our plain `.inline-flex` (Button's base) would outrank your `hidden sm:inline-flex`, showing a button you meant to hide on mobile.
54
+
55
+ Our components no longer depend on that tiebreak. Where a component needs a responsive override it uses mutually exclusive variants (`max-lg:justify-center lg:justify-start`) rather than a bare utility plus an override of it, so no rule you emit can displace one of ours on an element you never referenced. This is enforced on every build — see `scripts/check-cascade-safety.mjs`.
56
+
57
+ If you do hit a conflict, a call-site override outranks both halves:
58
+
59
+ ```tsx
60
+ <Footer className='[&_[data-slot=footer-legal-links]]:lg:justify-start' />
42
61
  ```
43
62
 
44
- The order matters 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 the 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.
63
+ > **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.
45
64
 
46
65
  ### Dark mode
47
66
 
@@ -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/grey" | "light" | "primary/white" | "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | null | undefined;
9
+ color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "primary/grey" | "light" | "primary/white" | 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'> & {
@@ -96,7 +96,7 @@ const focusOutline = {
96
96
  const styles = {
97
97
  base: [
98
98
  // Base
99
- "relative isolate inline-flex items-center rounded-sm font-normal border forced-colors:outline transition-all motion-reduce:transition-none h-fit shrink-0",
99
+ "relative isolate inline-flex items-center rounded-sm font-normal border forced-colors:outline motion-safe:transition-all h-fit shrink-0",
100
100
  // Icon — one flat size, for the same reason the type scale below is flat.
101
101
  "*:data-[slot=icon]:size-4 *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center"
102
102
  ],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/badge.tsx"],"names":["ButtonPrimitive"],"mappings":";;;;;;;;AAWA,MAAM,YAAA,GAAe;AAAA,EACnB,cAAA,EAAgB;AAAA;AAAA,IAEd,4CAAA;AAAA;AAAA,IAEA,8CAAA;AAAA;AAAA,IAEA,mEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,KAAA,EAAO;AAAA;AAAA,IAEL,yCAAA;AAAA;AAAA,IAEA,8CAAA;AAAA;AAAA,IAEA,qEAAA;AAAA;AAAA,IAEA,gEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,eAAA,EAAiB;AAAA;AAAA,IAEf,4CAAA;AAAA;AAAA,IAEA,2CAAA;AAAA;AAAA,IAEA,mEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,IAAA,EAAM;AAAA;AAAA,IAEJ,yCAAA;AAAA;AAAA,IAEA,8CAAA;AAAA;AAAA,IAEA,gEAAA;AAAA;AAAA,IAEA,qEAAA;AAAA;AAAA,IAEA,wEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,KAAA,EAAO;AAAA;AAAA,IAEL,sCAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,OAAA,EAAS;AAAA;AAAA,IAEP,4CAAA;AAAA;AAAA,IAEA,mEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,SAAA,EAAW;AAAA;AAAA,IAET,4CAAA;AAAA;AA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AAAA,EACA,GAAG;AACL,CAAA,EAAqB;AACnB,EAAA,uBACE,GAAA;AAAA,IAACA,MAAA;AAAA,IAAA;AAAA,MACC,cAAA,EAAc,OAAA;AAAA,MACb,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,KAAK,mBAAA,CAAoB,EAAE,OAAO,SAAA,EAAW,GAAG,gBAAgB,CAAA;AAAA,MAC3E,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,WAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAM,OAAA,EAAkB,OAAO,KAAA,IAAS,MAAA,EAAW,IAAA,EACjD,QAAA,EACH,CAAA,EACF;AAAA;AAAA,GACF;AAEJ;AAGA,SAAS,SAAA,CAAU,EAAE,OAAA,EAAS,KAAA,EAAO,IAAA,EAAM,WAAW,QAAA,EAAU,GAAA,EAAK,GAAG,KAAA,EAAM,EAAmB;AAC/F,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MAIC,OAAA,EAAQ,UAAA;AAAA,MACR,cAAA,EAAc,OAAA;AAAA,MACb,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,mBAAA,CAAoB,EAAE,KAAA,EAAO,WAAW,CAAA;AAAA,MACnD,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,WAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAM,OAAA,EAAkB,OAAO,KAAA,IAAS,MAAA,EAAW,IAAA,EACjD,QAAA,EACH,CAAA,EACF;AAAA;AAAA,GACF;AAEJ","file":"badge.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'\nimport { TouchTarget } from './button.js'\nimport { Link } from './link.js'\n\nconst focusOutline = {\n 'primary/grey': [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-600)]',\n // Soft, Surface and outline\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft, Surface and outline dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n ],\n light: [\n // Base\n '[--focus-outline:var(--color-grey-300)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-100)]',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n // Surface\n 'data-[variant=surface]:[--focus-outline:var(--color-grey-600)]',\n // Surface dark mode\n 'dark:data-[variant=surface]:[--focus-outline:var(--color-white)]/70',\n ],\n 'primary/white': [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-white)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n ],\n grey: [\n // Base\n '[--focus-outline:var(--color-grey-600)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-500)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-grey-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/20',\n // Outline dark mode\n 'dark:data-[variant=outline]:[--focus-outline:var(--color-grey-100)]/30',\n // Surface dark mode\n 'dark:data-[variant=surface]:[--focus-outline:var(--color-grey-200)]/20',\n ],\n white: [\n // Base\n '[--focus-outline:var(--color-white)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-white)]/20',\n ],\n primary: [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/60',\n ],\n secondary: [\n // Base\n '[--focus-outline:var(--color-primary-200)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-200)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-200)]/60',\n ],\n tertiary: [\n // Base\n '[--focus-outline:var(--color-primary-600)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-600)]/60',\n ],\n accent: [\n // Base\n '[--focus-outline:var(--color-accent-600)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-accent-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-accent-600)]/60',\n ],\n}\n\nconst styles = {\n base: [\n // Base\n 'relative isolate inline-flex items-center rounded-sm font-normal border forced-colors:outline transition-all motion-reduce:transition-none h-fit shrink-0',\n // Icon — one flat size, for the same reason the type scale below is flat.\n '*:data-[slot=icon]:size-4 *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center',\n ],\n solid: [\n // Text color\n 'text-(--badge-text)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--badge-border)',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-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-(--badge-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 // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-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-(--badge-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--badge-bg)/5',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-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-(--badge-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: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 // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-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-(--badge-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-(--badge-bg)/50 bg-(--badge-bg)/5',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-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-(--badge-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-(--badge-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 'group-active:border-(--badge-bg) group-hover:border-(--badge-bg)',\n // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-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-(--badge-bg) text-(--badge-bg)',\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-(--badge-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 // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-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 colors: {\n 'primary/grey': [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-grey-600)] dark:[--badge-border:var(--color-grey-600)]/90 dark:[--badge-text:var(--color-white)] dark:text-white',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-grey-200)]/20',\n ],\n light: [\n // Base\n '[--badge-bg:var(--color-grey-200)] [--badge-border:var(--color-grey-200)]/90 [--badge-text:var(--color-grey-800)]',\n 'text-grey-800',\n // Soft\n 'data-[variant=soft]:[--badge-bg:var(--color-grey-500)]',\n // Surface\n 'data-[variant=surface]:[--badge-bg:var(--color-grey-500)]',\n // States\n '[--badge-hover-overlay:var(--color-grey-200)]/10 data-[variant=outline]:[--badge-hover-overlay:var(--color-grey-200)]/20 data-[variant=solid]:[--badge-hover-overlay:var(--color-grey-400)]/50',\n // Dark mode\n 'dark:text-grey-200 dark:data-[variant=solid]:text-grey-800',\n // Dark mode states\n '',\n ],\n 'primary/white': [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-white)] dark:[--badge-border:var(--color-white)]/90 dark:[--badge-text:var(--color-grey-800)]',\n // Dark mode states\n '',\n ],\n grey: [\n // Base\n '[--badge-bg:var(--color-grey-600)] [--badge-border:var(--color-grey-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-white',\n // Dark mode states\n '',\n ],\n white: [\n // Base\n '[--badge-bg:var(--color-white)] [--badge-border:var(--color-white)]/90 text-white data-[variant=solid]:text-grey-800',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-grey-200 dark:data-[variant=solid]:text-grey-800',\n // Dark mode states\n '',\n ],\n primary: [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-white dark:bg-(--badge-bg)/40 dark:data-[variant=solid]:bg-(--badge-bg)',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-800)]/50 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/5',\n // Dark border\n 'dark:data-[variant=surface]:border-(--badge-border)/60',\n 'dark:data-[variant=outline]:border-(--badge-border)',\n // Dark border states\n 'dark:data-[variant=surface]:active:border-(--badge-border)',\n 'dark:data-[variant=surface]:hover:border-(--badge-border)',\n ],\n secondary: [\n // Base\n '[--badge-bg:var(--color-primary-200)] [--badge-border:var(--color-primary-200)]/90 [--badge-text:var(--color-primary-800)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-200)]/30 data-[variant=solid]:[--badge-hover-overlay:var(--color-primary-250)]',\n // Dark mode\n 'dark:[--badge-bg:var(--color-primary-400)] dark:[--badge-border:var(--color-primary-400)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-400)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n tertiary: [\n // Base\n '[--badge-bg:var(--color-primary-600)] [--badge-border:var(--color-primary-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-600)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-primary-500)] dark:[--badge-border:var(--color-primary-500)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-500)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n accent: [\n // Base\n '[--badge-bg:var(--color-accent-600)] [--badge-border:var(--color-accent-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-accent-600)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-accent-500)] dark:[--badge-border:var(--color-accent-500)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-accent-500)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n },\n // ───────────────────────────────────────────────────────────────────────────\n // Type scale (flat — do not reintroduce a `sm:` shrink)\n // ───────────────────────────────────────────────────────────────────────────\n //\n // Each size holds one font-size at every viewport. Sizes are chosen from the\n // hierarchy field.tsx documents: 16px is the body-copy ideal, 14px reads as\n // supporting information, and 12px is below the NSW Government digital\n // service standards minimum body-text size.\n //\n // These variants used to shrink at `sm:` (640px) — `text-sm/5 sm:text-xs/5`\n // and `text-base/5 sm:text-sm/5` — inherited from the Catalyst-derived\n // scaffolding this component started life as (4889aba). That put `default`\n // and `sm` badges at 12px from 640px up, i.e. under the floor precisely where\n // there is the most room, and capped `lg` at 14px so no badge in the system\n // could meet a 16px minimum on desktop. Buttons — which badges sit beside in\n // the header — have always been a flat `text-base/7`, so the shrink was also\n // out of step with its closest sibling.\n //\n // Below 640px nothing changed: every value here is the size that breakpoint\n // already rendered.\n size: {\n default:\n 'py-[calc(--spacing(1))] px-[calc(--spacing(2))] gap-[calc(--spacing(1)*1.5)] text-sm/5',\n sm: 'py-[calc(--spacing(1)*0.5)] px-[calc(--spacing(1)*1.5)] gap-[calc(--spacing(1)*1.5)] text-sm/5',\n lg: 'py-[calc(--spacing(1))] px-[calc(--spacing(2)*1.25)] gap-[calc(--spacing(2))] text-base/5',\n },\n}\n\nconst badgeVariants = cva(styles.base, {\n variants: {\n variant: {\n solid: styles.solid,\n soft: styles.soft,\n surface: styles.surface,\n outline: styles.outline,\n },\n color: {\n 'primary/grey': styles.colors['primary/grey'],\n light: styles.colors.light,\n 'primary/white': styles.colors['primary/white'],\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 },\n size: {\n default: styles.size.default,\n sm: styles.size.sm,\n lg: styles.size.lg,\n },\n },\n defaultVariants: {\n variant: 'soft',\n color: 'primary',\n size: 'default',\n },\n})\n\ntype BadgeProps = VariantProps<typeof badgeVariants> &\n React.ComponentPropsWithoutRef<'span'> & { ref?: React.Ref<HTMLSpanElement> }\n\nfunction Badge({ variant, color, size, className, ref, ...props }: BadgeProps) {\n return (\n <span\n {...props}\n data-variant={variant}\n className={cn(badgeVariants({ variant, color, size }), className)}\n ref={ref}\n />\n )\n}\n\n/** Visual/content props shared by `BadgeButton` and `BadgeLink`. */\ntype BadgeOwnProps = VariantProps<typeof badgeVariants> & {\n className?: string\n children: React.ReactNode\n}\n\ntype BadgeButtonProps = BadgeOwnProps & Omit<ButtonPrimitive.Props, 'className'>\n\ntype BadgeLinkProps = BadgeOwnProps &\n Omit<React.ComponentPropsWithoutRef<typeof Link>, 'className' | 'variant'> & {\n ref?: React.Ref<HTMLAnchorElement>\n }\n\nfunction badgeWrapperClasses({ color, className }: Pick<BadgeOwnProps, 'color' | 'className'>) {\n return clsx(className, focusOutline[(color ?? undefined) as keyof typeof focusOutline], [\n // Base\n 'group relative inline-flex rounded-sm',\n // Focus\n 'focus:outline-1 focus:outline-offset-1 focus:outline-(--focus-outline)',\n // Disabled\n 'disabled:pointer-events-none disabled:opacity-50',\n ])\n}\n\n/**\n * Interactive badge on the Base UI button primitive. For badge-styled\n * navigation, use `BadgeLink` — the `href` polymorphism that previously\n * lived on this component was removed in v2.\n */\nfunction BadgeButton({\n variant,\n color,\n size,\n className,\n children,\n ref,\n ...props\n}: BadgeButtonProps) {\n return (\n <ButtonPrimitive\n data-variant={variant}\n {...props}\n className={clsx(badgeWrapperClasses({ color, className }), 'cursor-pointer')}\n ref={ref}\n >\n <TouchTarget>\n <Badge variant={variant} color={color ?? undefined} size={size}>\n {children}\n </Badge>\n </TouchTarget>\n </ButtonPrimitive>\n )\n}\n\n/** Badge-styled anchor; renders through `Link` (so `LinkProvider` applies). */\nfunction BadgeLink({ variant, color, size, className, children, ref, ...props }: BadgeLinkProps) {\n return (\n <Link\n // Opt out of Link's built-in styling — BadgeLink wraps the inner\n // Badge with its own focus ring / hit target and doesn't want Link's\n // underline, halo, or icon defaults composing on top.\n variant='unstyled'\n data-variant={variant}\n {...props}\n className={badgeWrapperClasses({ color, className })}\n ref={ref}\n >\n <TouchTarget>\n <Badge variant={variant} color={color ?? undefined} size={size}>\n {children}\n </Badge>\n </TouchTarget>\n </Link>\n )\n}\n\nexport { Badge, BadgeButton, BadgeLink, badgeVariants }\nexport type { BadgeButtonProps, BadgeLinkProps, BadgeProps }\n"]}
1
+ {"version":3,"sources":["../../src/components/badge.tsx"],"names":["ButtonPrimitive"],"mappings":";;;;;;;;AAWA,MAAM,YAAA,GAAe;AAAA,EACnB,cAAA,EAAgB;AAAA;AAAA,IAEd,4CAAA;AAAA;AAAA,IAEA,8CAAA;AAAA;AAAA,IAEA,mEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,KAAA,EAAO;AAAA;AAAA,IAEL,yCAAA;AAAA;AAAA,IAEA,8CAAA;AAAA;AAAA,IAEA,qEAAA;AAAA;AAAA,IAEA,gEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,eAAA,EAAiB;AAAA;AAAA,IAEf,4CAAA;AAAA;AAAA,IAEA,2CAAA;AAAA;AAAA,IAEA,mEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,IAAA,EAAM;AAAA;AAAA,IAEJ,yCAAA;AAAA;AAAA,IAEA,8CAAA;AAAA;AAAA,IAEA,gEAAA;AAAA;AAAA,IAEA,qEAAA;AAAA;AAAA,IAEA,wEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,KAAA,EAAO;AAAA;AAAA,IAEL,sCAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,OAAA,EAAS;AAAA;AAAA,IAEP,4CAAA;AAAA;AAAA,IAEA,m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OAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAqB;AACnB,EAAA,uBACE,GAAA;AAAA,IAACA,MAAA;AAAA,IAAA;AAAA,MACC,cAAA,EAAc,OAAA;AAAA,MACb,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,KAAK,mBAAA,CAAoB,EAAE,OAAO,SAAA,EAAW,GAAG,gBAAgB,CAAA;AAAA,MAC3E,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,WAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAM,OAAA,EAAkB,OAAO,KAAA,IAAS,MAAA,EAAW,IAAA,EACjD,QAAA,EACH,CAAA,EACF;AAAA;AAAA,GACF;AAEJ;AAGA,SAAS,SAAA,CAAU,EAAE,OAAA,EAAS,KAAA,EAAO,IAAA,EAAM,WAAW,QAAA,EAAU,GAAA,EAAK,GAAG,KAAA,EAAM,EAAmB;AAC/F,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MAIC,OAAA,EAAQ,UAAA;AAAA,MACR,cAAA,EAAc,OAAA;AAAA,MACb,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,mBAAA,CAAoB,EAAE,KAAA,EAAO,WAAW,CAAA;AAAA,MACnD,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,WAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAM,OAAA,EAAkB,OAAO,KAAA,IAAS,MAAA,EAAW,IAAA,EACjD,QAAA,EACH,CAAA,EACF;AAAA;AAAA,GACF;AAEJ","file":"badge.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'\nimport { TouchTarget } from './button.js'\nimport { Link } from './link.js'\n\nconst focusOutline = {\n 'primary/grey': [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-600)]',\n // Soft, Surface and outline\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft, Surface and outline dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n ],\n light: [\n // Base\n '[--focus-outline:var(--color-grey-300)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-100)]',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n // Surface\n 'data-[variant=surface]:[--focus-outline:var(--color-grey-600)]',\n // Surface dark mode\n 'dark:data-[variant=surface]:[--focus-outline:var(--color-white)]/70',\n ],\n 'primary/white': [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-white)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n ],\n grey: [\n // Base\n '[--focus-outline:var(--color-grey-600)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-500)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-grey-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/20',\n // Outline dark mode\n 'dark:data-[variant=outline]:[--focus-outline:var(--color-grey-100)]/30',\n // Surface dark mode\n 'dark:data-[variant=surface]:[--focus-outline:var(--color-grey-200)]/20',\n ],\n white: [\n // Base\n '[--focus-outline:var(--color-white)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-white)]/20',\n ],\n primary: [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/60',\n ],\n secondary: [\n // Base\n '[--focus-outline:var(--color-primary-200)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-200)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-200)]/60',\n ],\n tertiary: [\n // Base\n '[--focus-outline:var(--color-primary-600)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-600)]/60',\n ],\n accent: [\n // Base\n '[--focus-outline:var(--color-accent-600)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-accent-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-accent-600)]/60',\n ],\n}\n\nconst styles = {\n base: [\n // Base\n 'relative isolate inline-flex items-center rounded-sm font-normal border forced-colors:outline motion-safe:transition-all h-fit shrink-0',\n // Icon — one flat size, for the same reason the type scale below is flat.\n '*:data-[slot=icon]:size-4 *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center',\n ],\n solid: [\n // Text color\n 'text-(--badge-text)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--badge-border)',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-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-(--badge-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 // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-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-(--badge-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--badge-bg)/5',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-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-(--badge-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: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 // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-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-(--badge-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-(--badge-bg)/50 bg-(--badge-bg)/5',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-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-(--badge-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-(--badge-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 'group-active:border-(--badge-bg) group-hover:border-(--badge-bg)',\n // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-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-(--badge-bg) text-(--badge-bg)',\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-(--badge-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 // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-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 colors: {\n 'primary/grey': [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-grey-600)] dark:[--badge-border:var(--color-grey-600)]/90 dark:[--badge-text:var(--color-white)] dark:text-white',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-grey-200)]/20',\n ],\n light: [\n // Base\n '[--badge-bg:var(--color-grey-200)] [--badge-border:var(--color-grey-200)]/90 [--badge-text:var(--color-grey-800)]',\n 'text-grey-800',\n // Soft\n 'data-[variant=soft]:[--badge-bg:var(--color-grey-500)]',\n // Surface\n 'data-[variant=surface]:[--badge-bg:var(--color-grey-500)]',\n // States\n '[--badge-hover-overlay:var(--color-grey-200)]/10 data-[variant=outline]:[--badge-hover-overlay:var(--color-grey-200)]/20 data-[variant=solid]:[--badge-hover-overlay:var(--color-grey-400)]/50',\n // Dark mode\n 'dark:text-grey-200 dark:data-[variant=solid]:text-grey-800',\n // Dark mode states\n '',\n ],\n 'primary/white': [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-white)] dark:[--badge-border:var(--color-white)]/90 dark:[--badge-text:var(--color-grey-800)]',\n // Dark mode states\n '',\n ],\n grey: [\n // Base\n '[--badge-bg:var(--color-grey-600)] [--badge-border:var(--color-grey-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-white',\n // Dark mode states\n '',\n ],\n white: [\n // Base\n '[--badge-bg:var(--color-white)] [--badge-border:var(--color-white)]/90 text-white data-[variant=solid]:text-grey-800',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-grey-200 dark:data-[variant=solid]:text-grey-800',\n // Dark mode states\n '',\n ],\n primary: [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-white dark:bg-(--badge-bg)/40 dark:data-[variant=solid]:bg-(--badge-bg)',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-800)]/50 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/5',\n // Dark border\n 'dark:data-[variant=surface]:border-(--badge-border)/60',\n 'dark:data-[variant=outline]:border-(--badge-border)',\n // Dark border states\n 'dark:data-[variant=surface]:active:border-(--badge-border)',\n 'dark:data-[variant=surface]:hover:border-(--badge-border)',\n ],\n secondary: [\n // Base\n '[--badge-bg:var(--color-primary-200)] [--badge-border:var(--color-primary-200)]/90 [--badge-text:var(--color-primary-800)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-200)]/30 data-[variant=solid]:[--badge-hover-overlay:var(--color-primary-250)]',\n // Dark mode\n 'dark:[--badge-bg:var(--color-primary-400)] dark:[--badge-border:var(--color-primary-400)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-400)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n tertiary: [\n // Base\n '[--badge-bg:var(--color-primary-600)] [--badge-border:var(--color-primary-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-600)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-primary-500)] dark:[--badge-border:var(--color-primary-500)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-500)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n accent: [\n // Base\n '[--badge-bg:var(--color-accent-600)] [--badge-border:var(--color-accent-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-accent-600)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-accent-500)] dark:[--badge-border:var(--color-accent-500)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-accent-500)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n },\n // ───────────────────────────────────────────────────────────────────────────\n // Type scale (flat — do not reintroduce a `sm:` shrink)\n // ───────────────────────────────────────────────────────────────────────────\n //\n // Each size holds one font-size at every viewport. Sizes are chosen from the\n // hierarchy field.tsx documents: 16px is the body-copy ideal, 14px reads as\n // supporting information, and 12px is below the NSW Government digital\n // service standards minimum body-text size.\n //\n // These variants used to shrink at `sm:` (640px) — `text-sm/5 sm:text-xs/5`\n // and `text-base/5 sm:text-sm/5` — inherited from the Catalyst-derived\n // scaffolding this component started life as (4889aba). That put `default`\n // and `sm` badges at 12px from 640px up, i.e. under the floor precisely where\n // there is the most room, and capped `lg` at 14px so no badge in the system\n // could meet a 16px minimum on desktop. Buttons — which badges sit beside in\n // the header — have always been a flat `text-base/7`, so the shrink was also\n // out of step with its closest sibling.\n //\n // Below 640px nothing changed: every value here is the size that breakpoint\n // already rendered.\n size: {\n default:\n 'py-[calc(--spacing(1))] px-[calc(--spacing(2))] gap-[calc(--spacing(1)*1.5)] text-sm/5',\n sm: 'py-[calc(--spacing(1)*0.5)] px-[calc(--spacing(1)*1.5)] gap-[calc(--spacing(1)*1.5)] text-sm/5',\n lg: 'py-[calc(--spacing(1))] px-[calc(--spacing(2)*1.25)] gap-[calc(--spacing(2))] text-base/5',\n },\n}\n\nconst badgeVariants = cva(styles.base, {\n variants: {\n variant: {\n solid: styles.solid,\n soft: styles.soft,\n surface: styles.surface,\n outline: styles.outline,\n },\n color: {\n 'primary/grey': styles.colors['primary/grey'],\n light: styles.colors.light,\n 'primary/white': styles.colors['primary/white'],\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 },\n size: {\n default: styles.size.default,\n sm: styles.size.sm,\n lg: styles.size.lg,\n },\n },\n defaultVariants: {\n variant: 'soft',\n color: 'primary',\n size: 'default',\n },\n})\n\ntype BadgeProps = VariantProps<typeof badgeVariants> &\n React.ComponentPropsWithoutRef<'span'> & { ref?: React.Ref<HTMLSpanElement> }\n\nfunction Badge({ variant, color, size, className, ref, ...props }: BadgeProps) {\n return (\n <span\n {...props}\n data-variant={variant}\n className={cn(badgeVariants({ variant, color, size }), className)}\n ref={ref}\n />\n )\n}\n\n/** Visual/content props shared by `BadgeButton` and `BadgeLink`. */\ntype BadgeOwnProps = VariantProps<typeof badgeVariants> & {\n className?: string\n children: React.ReactNode\n}\n\ntype BadgeButtonProps = BadgeOwnProps & Omit<ButtonPrimitive.Props, 'className'>\n\ntype BadgeLinkProps = BadgeOwnProps &\n Omit<React.ComponentPropsWithoutRef<typeof Link>, 'className' | 'variant'> & {\n ref?: React.Ref<HTMLAnchorElement>\n }\n\nfunction badgeWrapperClasses({ color, className }: Pick<BadgeOwnProps, 'color' | 'className'>) {\n return clsx(className, focusOutline[(color ?? undefined) as keyof typeof focusOutline], [\n // Base\n 'group relative inline-flex rounded-sm',\n // Focus\n 'focus:outline-1 focus:outline-offset-1 focus:outline-(--focus-outline)',\n // Disabled\n 'disabled:pointer-events-none disabled:opacity-50',\n ])\n}\n\n/**\n * Interactive badge on the Base UI button primitive. For badge-styled\n * navigation, use `BadgeLink` — the `href` polymorphism that previously\n * lived on this component was removed in v2.\n */\nfunction BadgeButton({\n variant,\n color,\n size,\n className,\n children,\n ref,\n ...props\n}: BadgeButtonProps) {\n return (\n <ButtonPrimitive\n data-variant={variant}\n {...props}\n className={clsx(badgeWrapperClasses({ color, className }), 'cursor-pointer')}\n ref={ref}\n >\n <TouchTarget>\n <Badge variant={variant} color={color ?? undefined} size={size}>\n {children}\n </Badge>\n </TouchTarget>\n </ButtonPrimitive>\n )\n}\n\n/** Badge-styled anchor; renders through `Link` (so `LinkProvider` applies). */\nfunction BadgeLink({ variant, color, size, className, children, ref, ...props }: BadgeLinkProps) {\n return (\n <Link\n // Opt out of Link's built-in styling — BadgeLink wraps the inner\n // Badge with its own focus ring / hit target and doesn't want Link's\n // underline, halo, or icon defaults composing on top.\n variant='unstyled'\n data-variant={variant}\n {...props}\n className={badgeWrapperClasses({ color, className })}\n ref={ref}\n >\n <TouchTarget>\n <Badge variant={variant} color={color ?? undefined} size={size}>\n {children}\n </Badge>\n </TouchTarget>\n </Link>\n )\n}\n\nexport { Badge, BadgeButton, BadgeLink, badgeVariants }\nexport type { BadgeButtonProps, BadgeLinkProps, BadgeProps }\n"]}
@@ -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?: "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;
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" | "sm" | "icon" | "lg" | null | undefined;
11
11
  iconOnly?: boolean | null | undefined;
12
12
  } & class_variance_authority_types.ClassProp) | undefined) => string;
13
13
  /**
@@ -11,7 +11,7 @@ import { Spinner } from '../components/spinner.js';
11
11
  const styles = {
12
12
  base: [
13
13
  // Base
14
- "relative isolate inline-flex items-baseline justify-center gap-x-2 rounded-sm border text-base/7 font-bold transition-all motion-reduce:transition-none",
14
+ "relative isolate inline-flex items-baseline justify-center gap-x-2 rounded-sm border text-base/7 font-bold motion-safe:transition-all",
15
15
  // Height floor, published per size step as `--btn-h` (see `styles.size`).
16
16
  // A floor rather than a fixed height so a wrapped label can still grow.
17
17
  "min-h-(--btn-h)",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/button.tsx"],"names":["ButtonPrimitive"],"mappings":";;;;;;;;;AAYA,MAAM,MAAA,GAAS;AAAA,EACb,IAAA,EAAM;AAAA;AAAA,IAEJ,yJAAA;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,IAEP,iBAAA;AAAA;AAAA,IAEA,oEAAA;AAAA;AAAA,IAEA,uBAAA;AAAA;AAAA,IAEA,gHAAA;AAAA;AAA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A,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 transition-all motion-reduce:transition-none',\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,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,IA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AA,QACjB,eAAA,EAAiB,EAAA;AAAA,QACjB,QAAA,EAAU,EAAA;AAAA,QACV,OAAA,EAAS,CAAC,CAAA,KAA2C,CAAA,CAAE,cAAA;AAAe,UAExE,EAAC;AAAA,MACL,WAAW,aAAA,CAAc;AAAA,QACvB,OAAA;AAAA,QACA,KAAA;AAAA,QACA,IAAA;AAAA,QACA,QAAA;AAAA,QACA,KAAA;AAAA,QACA,YAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,MACD,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA;AAAA,QAAC,aAAA;AAAA,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"]}
@@ -198,7 +198,7 @@ function ExpandableSearchField({
198
198
  // form root, which shrink-wraps this element.
199
199
  "flex h-12 w-12 cursor-pointer overflow-hidden rounded-sm border-0 bg-transparent text-transparent",
200
200
  "placeholder:text-transparent placeholder:opacity-0",
201
- "transition-[width,box-shadow,background-color] duration-300 ease-in-out motion-reduce:transition-none",
201
+ "duration-300 ease-in-out motion-safe:transition-[width,box-shadow,background-color]",
202
202
  // Hide WebKit's native clear affordance: the source field (type
203
203
  // text) had none, and Escape already clears a search input.
204
204
  "[&::-webkit-search-cancel-button]:appearance-none",
@@ -230,7 +230,7 @@ function ExpandableSearchField({
230
230
  type: "submit",
231
231
  className: cn(
232
232
  "absolute top-0 right-0 z-10 flex h-12 w-12 cursor-pointer rounded-sm",
233
- "transition-[background-color,box-shadow] duration-200 motion-reduce:transition-none",
233
+ "duration-200 motion-safe:transition-[background-color,box-shadow]",
234
234
  // Icon and halos all derive from the ink; the whole-form
235
235
  // focus-within halo marks the button as the pending action while
236
236
  // the user types.