@nswds/ui 5.6.0 → 5.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -5
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/breadcrumb.d.ts +10 -0
- package/dist/components/breadcrumb.js +0 -2
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.js +14 -4
- package/dist/components/button.js.map +1 -1
- package/dist/components/carousel.d.ts +15 -3
- package/dist/components/carousel.js +100 -16
- package/dist/components/carousel.js.map +1 -1
- package/dist/components/combobox.d.ts +8 -1
- package/dist/components/combobox.js +2 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/header.d.ts +1 -1
- package/dist/components/link.d.ts +1 -1
- package/dist/components/main-nav.d.ts +4 -1
- package/dist/components/main-nav.js.map +1 -1
- package/dist/components/masthead.d.ts +1 -1
- package/dist/components/pagination.d.ts +1 -1
- package/dist/components/pagination.js +13 -2
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/sheet.d.ts +6 -1
- package/dist/components/sheet.js +2 -1
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/skip-link.d.ts +1 -1
- package/dist/hooks/use-chrome-height.d.ts +4 -1
- package/dist/hooks/use-chrome-height.js +39 -4
- package/dist/hooks/use-chrome-height.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,12 +64,14 @@ If you do hit a conflict, a call-site override outranks both halves:
|
|
|
64
64
|
|
|
65
65
|
### Dark mode
|
|
66
66
|
|
|
67
|
-
Toggle `class="dark"` or `data-theme="dark"` on a root element (for example with [`next-themes`](https://github.com/pacocoursey/next-themes)). Semantic tokens and `dark:` utilities both key off either marker, and both match the element carrying it as well as its descendants
|
|
67
|
+
Toggle `class="dark"` or `data-theme="dark"` on a **root element** (for example with [`next-themes`](https://github.com/pacocoursey/next-themes)). Semantic tokens and `dark:` utilities both key off either marker, and both match the element carrying it as well as its descendants.
|
|
68
68
|
|
|
69
69
|
```tsx
|
|
70
70
|
<html lang='en' className='dark'>
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
**A scoped `<div class="dark">` gives you only a partial dark mode.** The semantic tokens are declared on `:root` in terms of mode-aware role tokens (`--primary: var(--action-default)`), and a `var()` is substituted where it is declared — so on a nested element the role token changes too late. The `dark:` utilities flip (those are compiled classes) while the semantic colours stay light. Put the marker on the root element.
|
|
74
|
+
|
|
73
75
|
### Icons
|
|
74
76
|
|
|
75
77
|
Icons are tree-shakeable from the barrel, or importable individually:
|
|
@@ -147,15 +149,54 @@ import {
|
|
|
147
149
|
|
|
148
150
|
## Components
|
|
149
151
|
|
|
150
|
-
|
|
152
|
+
62 components, plus 12 copy-and-adapt blocks on the registry channel. The complete catalogue —
|
|
153
|
+
with every export and a description per item — is in the
|
|
154
|
+
[component reference](https://github.com/digitalnsw/nswds-ui/blob/main/docs/reference-components.md).
|
|
155
|
+
|
|
156
|
+
**NSW-original** (no upstream equivalent — the reference is their only documentation):
|
|
157
|
+
Callout, Container, DescriptionList, ExpandableSearch, Footer, Header, LabeledSeparator, Link,
|
|
158
|
+
LinkCard, Logo, MainNav, Masthead, OnThisPage, PushMenu, Section, SideNav, SiteSearch, SkipLink,
|
|
159
|
+
StepIndicator, TabNav, ThemeSwitcher.
|
|
160
|
+
|
|
161
|
+
**Shadcn shapes on Base UI primitives, NSW-styled:**
|
|
162
|
+
Accordion, AspectRatio, Avatar, Badge, Breadcrumb, Button, ButtonGroup, Card, Carousel, Checkbox,
|
|
163
|
+
Collapsible, Combobox, DirectionProvider, Drawer, Field, HoverCard, Input, InputGroup, InputOTP,
|
|
164
|
+
Kbd, Label, NativeSelect, Pagination, Popover, Progress, RadioGroup, ResizablePanelGroup, ScrollArea, Select,
|
|
165
|
+
Separator, Sheet, Slider, Spinner, Switch, Table, Tabs, Textarea, Toaster, Toggle, ToggleGroup,
|
|
166
|
+
Tooltip.
|
|
151
167
|
|
|
152
|
-
|
|
168
|
+
Plus the icon set under `@nswds/ui/icons` and the brand marks under `@nswds/ui/icons/brands`.
|
|
153
169
|
|
|
154
|
-
|
|
170
|
+
Hooks: `useChromeHeight`, which measures a sticky header and publishes its height as a CSS custom
|
|
171
|
+
property, for `scroll-padding-top`, `MainNav`'s `--main-nav-top`, and `OnThisPage`'s scroll-spy
|
|
172
|
+
offset.
|
|
173
|
+
|
|
174
|
+
Every interactive component wraps a Base UI primitive, which provides focus management, keyboard
|
|
175
|
+
navigation, and ARIA semantics. Each component also exports its `cva` variants function (for
|
|
176
|
+
example `buttonVariants`) so you can extend styling.
|
|
155
177
|
|
|
156
178
|
## Theming
|
|
157
179
|
|
|
158
|
-
Every visual property traces back to a CSS custom property token
|
|
180
|
+
Every visual property traces back to a CSS custom property token, in four layers: Tailwind
|
|
181
|
+
utilities → shadcn semantic tokens (`--primary`, `--background`, `--border`) → NSW role tokens
|
|
182
|
+
(`--action-default`, `--text-default`) → the NSW primitive palette.
|
|
183
|
+
|
|
184
|
+
To re-brand, **override the masterbrand ramps at `:root`**, after importing the stylesheet:
|
|
185
|
+
|
|
186
|
+
```css
|
|
187
|
+
:root {
|
|
188
|
+
--primary-800: oklch(0.29 0.12 150);
|
|
189
|
+
/* …the remaining steps of the ramp… */
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Supply the whole ramp — components draw on different steps for fills, borders and hover states.
|
|
194
|
+
|
|
195
|
+
> Overriding tokens in a **scoped** selector mostly does not work, because a `var()` is substituted
|
|
196
|
+
> where it is declared and every layer is declared at `:root`. In particular `Button`'s primary
|
|
197
|
+
> colour resolves to the masterbrand ramp (`--color-primary-800`), not to `--primary`. See
|
|
198
|
+
> [Theme and re-brand](https://github.com/digitalnsw/nswds-ui/blob/main/docs/howto-theme-and-rebrand.md)
|
|
199
|
+
> for the rule and the working escape hatch.
|
|
159
200
|
|
|
160
201
|
## Prefer the source in your repo?
|
|
161
202
|
|
|
@@ -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" | "
|
|
9
|
+
color?: "primary/grey" | "light" | "primary/white" | "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | null | undefined;
|
|
10
10
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
11
11
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
12
12
|
type BadgeProps = VariantProps<typeof badgeVariants> & React__default.ComponentPropsWithoutRef<'span'> & {
|
|
@@ -5,6 +5,16 @@ declare function Breadcrumb({ className, ...props }: React.ComponentProps<'nav'>
|
|
|
5
5
|
declare function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>): React.JSX.Element;
|
|
6
6
|
declare function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>): React.JSX.Element;
|
|
7
7
|
declare function BreadcrumbLink({ className, render, ...props }: useRender.ComponentProps<'a'>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
8
|
+
/**
|
|
9
|
+
* The current page's entry in the trail — plain text, not a link.
|
|
10
|
+
*
|
|
11
|
+
* Carries `aria-current='page'` and nothing else. The upstream shadcn version
|
|
12
|
+
* adds `role='link' aria-disabled='true'` to a `<span>` that has no `href` and
|
|
13
|
+
* no `tabIndex`, which makes AT announce "link, dimmed, current page" for
|
|
14
|
+
* something that is neither a link nor operable, and puts a hand-rolled ARIA
|
|
15
|
+
* role on an element that needs none. axe-core does not flag it, so it
|
|
16
|
+
* survives an a11y gate set to `error`; it is removed deliberately here.
|
|
17
|
+
*/
|
|
8
18
|
declare function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>): React.JSX.Element;
|
|
9
19
|
declare function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>): React.JSX.Element;
|
|
10
20
|
declare function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/breadcrumb.tsx"],"names":[],"mappings":";;;;;;;AAQA,SAAS,UAAA,CAAW,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACxE,EAAA,uBAAO,GAAA,CAAC,KAAA,EAAA,EAAI,YAAA,EAAW,YAAA,EAAa,WAAA,EAAU,YAAA,EAAa,SAAA,EAAW,EAAA,CAAG,SAAS,CAAA,EAAI,GAAG,KAAA,EAAO,CAAA;AAClG;AAEA,SAAS,cAAA,CAAe,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,iBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,2FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,cAAA,CAAe,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,iBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,gCAAA,EAAkC,SAAS,CAAA;AAAA,MACxD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,eAAe,EAAE,SAAA,EAAW,MAAA,EAAQ,GAAG,OAAM,EAAkC;AACtF,EAAA,OAAO,SAAA,CAAU;AAAA,IACf,cAAA,EAAgB,GAAA;AAAA,IAChB,KAAA,EAAO,UAAA;AAAA,MACL;AAAA,QACE,SAAA,EAAW,EAAA,CAAG,yCAAA,EAA2C,SAAS;AAAA,OACpE;AAAA,MACA;AAAA,KACF;AAAA,IACA,MAAA;AAAA,IACA,KAAA,EAAO;AAAA,MACL,IAAA,EAAM;AAAA;AACR,GACD,CAAA;AACH;
|
|
1
|
+
{"version":3,"sources":["../../src/components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IAAA;AAAA,MACC,WAAA,EAAU,iBAAA;AAAA,MACV,cAAA,EAAa,MAAA;AAAA,MACb,SAAA,EAAW,EAAA,CAAG,6BAAA,EAA+B,SAAS,CAAA;AAAA,MACrD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,oBAAoB,EAAE,QAAA,EAAU,SAAA,EAAW,GAAG,OAAM,EAA+B;AAC1F,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,sBAAA;AAAA,MACV,IAAA,EAAK,cAAA;AAAA,MACL,aAAA,EAAY,MAAA;AAAA,MACZ,SAAA,EAAW,EAAA,CAAG,kBAAA,EAAoB,SAAS,CAAA;AAAA,MAC1C,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA,QAAA,oBAAY,GAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,gBAAA,EAAiB;AAAA;AAAA,GAC5D;AAEJ;AAEA,SAAS,kBAAA,CAAmB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAiC;AACjF,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,qBAAA;AAAA,MACV,IAAA,EAAK,cAAA;AAAA,MACL,aAAA,EAAY,MAAA;AAAA,MACZ,SAAA,EAAW,EAAA,CAAG,0DAAA,EAA4D,SAAS,CAAA;AAAA,MAClF,GAAG,KAAA;AAAA,MAEJ,8BAAC,aAAA,EAAA,EAAc;AAAA;AAAA,GACjB;AAEJ","file":"breadcrumb.js","sourcesContent":["import { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\n\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { IconMoreHoriz } from '../icons/more-horiz.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Breadcrumb({ className, ...props }: React.ComponentProps<'nav'>) {\n return <nav aria-label='breadcrumb' data-slot='breadcrumb' className={cn(className)} {...props} />\n}\n\nfunction BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {\n return (\n <ol\n data-slot='breadcrumb-list'\n className={cn(\n 'flex flex-wrap items-center gap-1.5 text-xs/relaxed wrap-break-word text-muted-foreground',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-slot='breadcrumb-item'\n className={cn('inline-flex items-center gap-1', className)}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbLink({ className, render, ...props }: useRender.ComponentProps<'a'>) {\n return useRender({\n defaultTagName: 'a',\n props: mergeProps<'a'>(\n {\n className: cn('transition-colors hover:text-foreground', className),\n },\n props,\n ),\n render,\n state: {\n slot: 'breadcrumb-link',\n },\n })\n}\n\n/**\n * The current page's entry in the trail — plain text, not a link.\n *\n * Carries `aria-current='page'` and nothing else. The upstream shadcn version\n * adds `role='link' aria-disabled='true'` to a `<span>` that has no `href` and\n * no `tabIndex`, which makes AT announce \"link, dimmed, current page\" for\n * something that is neither a link nor operable, and puts a hand-rolled ARIA\n * role on an element that needs none. axe-core does not flag it, so it\n * survives an a11y gate set to `error`; it is removed deliberately here.\n */\nfunction BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-page'\n aria-current='page'\n className={cn('font-normal text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-slot='breadcrumb-separator'\n role='presentation'\n aria-hidden='true'\n className={cn('[&>svg]:size-3.5', className)}\n {...props}\n >\n {children ?? <IconChevronRight className='rtl:rotate-180' />}\n </li>\n )\n}\n\nfunction BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-ellipsis'\n role='presentation'\n aria-hidden='true'\n className={cn('flex size-4 items-center justify-center [&>svg]:size-3.5', className)}\n {...props}\n >\n <IconMoreHoriz />\n </span>\n )\n}\n\nexport {\n Breadcrumb,\n BreadcrumbEllipsis,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n}\n"]}
|
|
@@ -5,8 +5,8 @@ import React__default from 'react';
|
|
|
5
5
|
import { Link } from './link.js';
|
|
6
6
|
|
|
7
7
|
declare const buttonVariants: (props?: ({
|
|
8
|
-
variant?: "
|
|
9
|
-
color?: "
|
|
8
|
+
variant?: "solid" | "soft" | "surface" | "outline" | "link" | "ghost" | null | undefined;
|
|
9
|
+
color?: "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | "danger" | "success" | "warning" | null | undefined;
|
|
10
10
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
11
11
|
iconOnly?: boolean | null | undefined;
|
|
12
12
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
@@ -496,11 +496,21 @@ function ButtonContent({
|
|
|
496
496
|
renderIconSlot(trailingAction)
|
|
497
497
|
] });
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function hasTextChild(children) {
|
|
500
|
+
return React.Children.toArray(children).some((child) => {
|
|
501
|
+
if (typeof child === "string") return child.trim() !== "";
|
|
502
|
+
if (typeof child === "number") return true;
|
|
503
|
+
if (React.isValidElement(child) && child.type === React.Fragment) {
|
|
504
|
+
return hasTextChild(child.props.children);
|
|
505
|
+
}
|
|
506
|
+
return false;
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
function warnIfIconButtonUnlabelled(size, iconOnly, props, children) {
|
|
500
510
|
if (process.env.NODE_ENV === "production") {
|
|
501
511
|
return;
|
|
502
512
|
}
|
|
503
|
-
if ((size === "icon" || iconOnly) && !props["aria-label"] && !props["aria-labelledby"]) {
|
|
513
|
+
if ((size === "icon" || iconOnly) && !props["aria-label"] && !props["aria-labelledby"] && !hasTextChild(children)) {
|
|
504
514
|
console.warn(
|
|
505
515
|
'[nswds/ui] Icon-only buttons (size="icon" or iconOnly) have no visible label \u2014 pass aria-label or aria-labelledby so the control has an accessible name.'
|
|
506
516
|
);
|
|
@@ -534,7 +544,7 @@ function Button({
|
|
|
534
544
|
...props
|
|
535
545
|
}) {
|
|
536
546
|
const effectiveDisabled = disabled || loading;
|
|
537
|
-
warnIfIconButtonUnlabelled(size, iconOnly, props);
|
|
547
|
+
warnIfIconButtonUnlabelled(size, iconOnly, props, children);
|
|
538
548
|
return /* @__PURE__ */ jsx(
|
|
539
549
|
Button$1,
|
|
540
550
|
{
|
|
@@ -591,7 +601,7 @@ function ButtonLink({
|
|
|
591
601
|
...props
|
|
592
602
|
}) {
|
|
593
603
|
const effectiveDisabled = disabled || loading;
|
|
594
|
-
warnIfIconButtonUnlabelled(size, iconOnly, props);
|
|
604
|
+
warnIfIconButtonUnlabelled(size, iconOnly, props, children);
|
|
595
605
|
return /* @__PURE__ */ jsx(
|
|
596
606
|
Link,
|
|
597
607
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/button.tsx"],"names":["ButtonPrimitive"],"mappings":";;;;;;;;;AAYA,MAAM,MAAA,GAAS;AAAA,EACb,IAAA,EAAM;AAAA;AAAA,IAEJ,uIAAA;AAAA;AAAA;AAAA,IAGA,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,sBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,+EAAA;AAAA;AAAA,IAEA,4DAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,yEAAA;AAAA,IACA,0EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,gCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA,GACF;AAAA,EACA,KAAA,EAAO;AAAA;AAAA,IAEL,mBAAA;AAAA;AAAA,IAEA,sCAAA;AAAA;AAAA,IAEA,sBAAA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AAA;AAAA,QACV,aAAA,EAAY;AAAA;AAAA,KACd;AAAA,IACC;AAAA,GAAA,EACH,CAAA;AAEJ","file":"button.js","sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport clsx from 'clsx'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Link } from '../components/link.js'\nimport { Spinner } from '../components/spinner.js'\n\nconst styles = {\n base: [\n // Base\n 'relative isolate inline-flex items-baseline justify-center gap-x-2 rounded-sm border text-base/7 font-bold motion-safe:transition-all',\n // Height floor, published per size step as `--btn-h` (see `styles.size`).\n // A floor rather than a fixed height so a wrapped label can still grow.\n 'min-h-(--btn-h)',\n // Border width, so the size steps can subtract it from their padding and\n // keep the outer box identical across variants. `outline` and `surface`\n // draw a 2px border and raise this to match; everything else stays 1px.\n // Without it the steps subtracted a hard-coded 1px and those two variants\n // came out 2px taller than `solid` at every step and breakpoint.\n '[--btn-border-w:1px]',\n // Focus — deliberately `focus:` (paints on pointer clicks too), unlike\n // Link/Input which use `focus-visible:`. Buttons give click feedback with\n // the ring; links only ring for keyboard/AT focus. Do not \"unify\" this.\n // The ring is offset 2px, so it lands on the *page* rather than on the\n // button. `--btn-bg` is the ink (see the note above `styles.colors`), which\n // flips for dark mode, so the ring follows the theme for every variant —\n // including `solid`, whose ring used to be its own fill colour and so went\n // near-invisible on a dark surface.\n 'focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--btn-bg)',\n // Disabled\n 'data-disabled:opacity-50 data-disabled:pointer-events-none',\n // State overlays, derived from the ink rather than restated per colour.\n // Deriving them means they follow `--btn-bg` wherever it comes from: the\n // colour token, its dark-mode counterpart, or a surface that re-points the\n // ink at its own (`[--btn-bg:var(--footer-ink)]` in footer.tsx and\n // footer-cta.tsx). `solid` overrides both with its white/black pair at\n // `data-[variant=solid]:` — an attribute selector, so it outranks these\n // regardless of source order. `oklab` matches the interpolation space\n // Tailwind's own `/10` alpha modifier emits, so the painted colour is\n // unchanged from when each colour restated these itself.\n '[--btn-hover-overlay:color-mix(in_oklab,var(--btn-bg)_10%,transparent)]',\n '[--btn-active-overlay:color-mix(in_oklab,var(--btn-bg)_20%,transparent)]',\n // Glyph size beside a label: one value for every step and breakpoint.\n // Every step sets `text-base/7`, so the label is 16px whatever the step —\n // only the padding changes. An icon next to it has to match the *text*,\n // not the box, so scaling it per step pairs a growing glyph with type that\n // never moves: at `lg` a 28px icon sat beside a 16px word, two and a half\n // times its cap height. 24px is 1.5x the label at every step, and the same\n // number `size='icon'` uses. `iconOnly` overrides this per step in\n // `compoundVariants` — with no label to match, it scales with its box.\n '[--btn-icon-size:--spacing(6)]',\n // Icon. No vertical margin: the glyph is `self-center` in a baseline-aligned\n // row, so margin buys it nothing optically and only inflates the flex line.\n // It was inert at `sm`/`default` (glyph + margin stayed inside the 1.75rem\n // line box) but pushed `lg` 2px past its own height below `sm:`, so a `lg`\n // button measured 70px with an icon and 68px without.\n '*:data-[slot=icon]:-mx-0.25 *:data-[slot=icon]:size-(--btn-icon-size) *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center *:data-[slot=icon]:text-(--btn-icon) forced-colors:[--btn-icon:ButtonText] forced-colors:hover:[--btn-icon:ButtonText]',\n ],\n solid: [\n // Text color\n 'text-(--btn-text)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-border)',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-fill)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-fill)',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n soft: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-bg)/10',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)/20',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)/10',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:bg-white/5',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n surface: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-(--btn-bg)/50 border-2 bg-(--btn-bg)/5 [--btn-border-w:2px]',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)/30',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)/5',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--btn-bg)/50',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // Border color on hover\n 'active:border-(--btn-bg) hover:border-(--btn-bg)',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n outline: [\n // Text color\n 'border-(--btn-bg) text-(--btn-bg) border-2 [--btn-border-w:2px]',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'bg-transparent',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-transparent',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--btn-bg)',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n ghost: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-transparent)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-transparent)',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n link: [\n // Text color — inherits from color token, no background or border\n 'text-(--btn-bg) border-transparent bg-transparent',\n // Halo tokens derive from the colour token via color-mix, mirroring Link\n '[--link-halo:color-mix(in_oklch,var(--btn-bg)_10%,transparent)]',\n '[--link-halo-active:color-mix(in_oklch,var(--btn-bg)_18%,transparent)]',\n // Resting underline, thickened on interaction — matching Link\n 'underline underline-offset-4 hover:decoration-2 active:decoration-2',\n // Hover / active halos match the GOV.UK-style halo on Link (see link.tsx\n // styledBase): the fill is painted on the `after` layer — consistent with\n // the other variants' hover overlays — and the box-shadow extends it 2px\n // above and 4px below the line box\n 'after:absolute after:inset-0 after:-z-10',\n 'hover:after:bg-(--link-halo) active:after:bg-(--link-halo-active)',\n 'hover:shadow-[0_-2px_0_var(--link-halo),0_4px_0_var(--link-halo)]',\n 'active:shadow-[0_-2px_0_var(--link-halo-active),0_4px_0_var(--link-halo-active)]',\n ],\n // Two variables, deliberately separate.\n //\n // `--btn-fill` is the block of colour `solid` paints behind `--btn-text`.\n // `--btn-bg` is the *ink*: the glyph and label on every non-solid variant\n // (`text-(--btn-bg)`), the border on `outline`/`surface`, the tint on\n // `soft`/`surface`, the `link` halos, the state overlays derived in\n // `styles.base`, and the focus ring. They start life the same colour, and\n // only part company in dark mode.\n //\n // They used to be one variable, which made the ink un-flippable. The values\n // here are masterbrand palette steps, and palette steps are theme-invariant —\n // `styles.css` re-declares only the *semantic* tokens under\n // `[data-theme=dark], .dark`. Design-system surfaces do flip, though\n // (`Header color='white'` is `bg-white dark:bg-grey-900`), so a non-solid\n // button kept its light-mode ink on a dark surface: `primary-800` on\n // `grey-900` measures 1.32:1, far under the 3:1 WCAG 1.4.11 asks of a UI\n // component, with the overlays and focus ring unpainted for the same reason.\n // Splitting the fill off means `--btn-bg` can flip on its own without\n // repainting `solid`, so the dark counterparts below need no variant scoping\n // and stay at single-class specificity — which is what keeps them overridable\n // by a surface that imposes its own ink (`[--btn-bg:var(--footer-ink)]` in\n // footer.tsx and footer-cta.tsx). Raising their specificity would silently\n // win against those, so keep any future dark value a bare `dark:` utility.\n //\n // `-200` is the package's established ink-on-dark (`--link-color`,\n // `--main-nav-panel-ink`) and clears 10:1 against every dark surface token.\n // `white` and `secondary` are already light inks, so they have no counterpart.\n //\n // Dark values use the raw NSW tokens for the tree-shaking reason spelled out\n // above `danger` below.\n colors: {\n grey: [\n // Base\n '[--btn-fill:var(--color-grey-600)] [--btn-bg:var(--color-grey-600)] [--btn-border:var(--color-grey-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--grey-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n white: [\n // No dark counterpart: white is already the maximum-contrast ink on any\n // dark surface. Surface-conditional in the same way as `secondary` — on a\n // light surface a non-solid `white` button is white on white. See the\n // note on the `color` prop.\n // Base\n '[--btn-fill:var(--color-white)] [--btn-bg:var(--color-white)] [--btn-border:var(--color-white)]/90 [--btn-text:var(--color-grey-800)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-black)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n primary: [\n // Base\n '[--btn-fill:var(--color-primary-800)] [--btn-bg:var(--color-primary-800)] [--btn-border:var(--color-primary-800)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--primary-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n secondary: [\n // No dark counterpart: `primary-200` already *is* the ink the other\n // colours flip to. Like `white`, this token is surface-conditional — it\n // is meant for dark surfaces, where it lands at 15.40:1. As a non-solid\n // ink on a light one it measures ~1.2:1, so that pairing is misuse\n // rather than a defect to fix here. See the note on the `color` prop.\n // Base\n '[--btn-fill:var(--color-primary-200)] [--btn-bg:var(--color-primary-200)] [--btn-border:var(--color-primary-200)]/90 [--btn-text:var(--color-primary-800)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/15',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-primary-800)]/10',\n ],\n tertiary: [\n // Base\n '[--btn-fill:var(--color-primary-600)] [--btn-bg:var(--color-primary-600)] [--btn-border:var(--color-primary-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--primary-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n accent: [\n // Base\n '[--btn-fill:var(--color-accent-600)] [--btn-bg:var(--color-accent-600)] [--btn-border:var(--color-accent-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--accent-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n // Semantic colours use the raw NSW token names (--danger-600, --success-600,\n // --warning-600) rather than Tailwind's `--color-*` bridge aliases. The\n // bridge aliases are tree-shaken by Tailwind v4 unless a matching utility\n // class is detected in scanned source, and arbitrary-property usages like\n // `[--btn-bg:var(--color-success-600)]` do NOT count as a usage signal.\n // The raw tokens are defined on :root by @nswds/tokens (a plain CSS import,\n // not a Tailwind theme), so they always resolve.\n danger: [\n // Base\n '[--btn-fill:var(--danger-600)] [--btn-bg:var(--danger-600)] [--btn-border:var(--danger-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--danger-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n success: [\n // Base\n '[--btn-fill:var(--success-600)] [--btn-bg:var(--success-600)] [--btn-border:var(--success-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--success-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n warning: [\n // Base\n '[--btn-fill:var(--warning-600)] [--btn-bg:var(--warning-600)] [--btn-border:var(--warning-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--warning-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n },\n // Each step publishes its own height as `--btn-h`, built from the same two\n // numbers that produce its box: one line box (`text-base/7` — Tailwind's\n // `/7` is `--spacing(7)`, so this is the same token, not a matching literal)\n // plus twice the vertical padding. `styles.base` pins it with `min-h`, and\n // `styles.iconOnly` reads it as both dimensions of the square — so an\n // icon-only button is exactly as tall as the text button beside it by\n // construction, and stays that way if a step is ever retuned.\n //\n // The border cancels out of that sum: padding is `--spacing(n) -\n // --btn-border-w` and the border adds `--btn-border-w` back, so every\n // variant lands on `--btn-h` whether it draws a 1px or 2px edge, and the\n // outer geometry stays put while the label shifts 1px to make room.\n //\n // The steps set padding and height only. Glyph size lives on the base (one\n // value beside a label) and in `compoundVariants` (per step when icon-only).\n size: {\n default:\n 'px-[calc(--spacing(6)-var(--btn-border-w))] py-[calc(--spacing(4)-var(--btn-border-w))] sm:px-[calc(--spacing(5.5)-var(--btn-border-w))] sm:py-[calc(--spacing(3)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(4)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(3)*2)]',\n sm: 'px-[calc(--spacing(5)-var(--btn-border-w))] py-[calc(--spacing(3)-var(--btn-border-w))] sm:px-[calc(--spacing(4.5)-var(--btn-border-w))] sm:py-[calc(--spacing(2)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(3)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(2)*2)]',\n lg: 'px-[calc(--spacing(7)-var(--btn-border-w))] py-[calc(--spacing(5)-var(--btn-border-w))] sm:px-[calc(--spacing(6.5)-var(--btn-border-w))] sm:py-[calc(--spacing(4)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(5)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(4)*2)]',\n // A compact chrome square that deliberately sits below the text steps —\n // header actions, dialog close buttons, footer social links. For an icon\n // button that must line up with text buttons beside it, use `iconOnly`\n // with `sm`/`default`/`lg` instead. Its glyph is the base 24px.\n icon: 'w-10 h-10 flex-none [--btn-h:--spacing(10)]',\n },\n // Square the button at the current step and drop the horizontal padding, so\n // the scale step and \"is this icon-only\" are independent axes. The glyph\n // needs no adjustment — the step already sizes it off the ladder.\n iconOnly: 'size-(--btn-h) flex-none p-0 sm:p-0',\n}\n\nconst buttonVariants = cva(styles.base, {\n variants: {\n variant: {\n solid: styles.solid,\n soft: styles.soft,\n surface: styles.surface,\n outline: styles.outline,\n ghost: styles.ghost,\n link: styles.link,\n },\n color: {\n white: styles.colors.white,\n grey: styles.colors.grey,\n primary: styles.colors.primary,\n secondary: styles.colors.secondary,\n tertiary: styles.colors.tertiary,\n accent: styles.colors.accent,\n danger: styles.colors.danger,\n success: styles.colors.success,\n warning: styles.colors.warning,\n },\n size: {\n default: styles.size.default,\n sm: styles.size.sm,\n lg: styles.size.lg,\n icon: styles.size.icon,\n },\n // Declared after `size` so its `p-0` reaches `cn()` downstream of the\n // step's `px-*`/`py-*` and wins the tailwind-merge conflict.\n iconOnly: {\n true: styles.iconOnly,\n false: '',\n },\n },\n compoundVariants: [\n // ── Icon-only glyph sizes ────────────────────────────────────────────\n //\n // With no label beside it the glyph has nothing to match, so here — and\n // only here — it scales with its box, off the icon ladder: 20 / 24 / 28 /\n // 32 / 36 / 40px, i.e. `--spacing(5)` through `--spacing(10)`. Every level\n // is a multiple of 4, so glyphs share the grid with the padding and\n // heights around them and land on whole device pixels at 1x. A discrete\n // ladder rather than a proportion of the box, because a glyph is only\n // crisp at the sizes it was drawn for — \"40% of the box\" would ask for\n // sizes no glyph exists at.\n //\n // One value per step, not per breakpoint: the square never gets smaller\n // on a wider viewport, so neither should what sits inside it.\n { size: 'sm', iconOnly: true, className: '[--btn-icon-size:--spacing(5)]' },\n { size: 'default', iconOnly: true, className: '[--btn-icon-size:--spacing(6)]' },\n { size: 'lg', iconOnly: true, className: '[--btn-icon-size:--spacing(7)]' },\n // The link variant reads as an inline Link despite the <button> tag:\n // strip the button chrome (padding from `size`, border, radius, bold\n // weight) and adopt Link's typography and 1em icon sizing so the hover\n // halo hugs the text instead of filling a button-shaped box.\n {\n variant: 'link',\n className: [\n 'rounded-none border-0 p-0 sm:p-0',\n // Release the step's height floor too — an inline link hugs its line\n // box, it does not stand a button's worth of space tall.\n 'min-h-0',\n // Hug the label even in stretching grid/flex contexts so the hover\n // halo wraps the text like an inline Link, not the allocated box.\n // `block` still wins — its w-full is applied after this in cn().\n 'w-fit',\n 'text-[length:inherit] font-medium',\n '*:data-[slot=icon]:size-[1em]',\n ],\n },\n ],\n defaultVariants: {\n variant: 'solid',\n color: 'primary',\n size: 'default',\n },\n})\n\n/**\n * An icon slot. Takes either form:\n *\n * - the component itself — `leadingVisual={IconDownload}`\n * - a rendered element — `leadingVisual={<IconDownload />}`\n *\n * **From a React Server Component, use the element form.** `Button` and\n * `ButtonLink` are `'use client'` modules, while the icon modules carry no\n * directive — deliberately, so an icon stays server-renderable and ships no\n * JavaScript. That means in a server component `IconDownload` is an ordinary\n * function value, and functions cannot cross the RSC boundary into a client\n * component (\"Functions cannot be passed directly to Client Components\"). A\n * React element can, because it serialises. Client components can use either.\n */\ntype IconSlot = React.ElementType | React.ReactElement\n\n/**\n * Renders an icon slot in whichever form it arrived, stamping `data-slot='icon'`\n * so the `*:data-[slot=icon]:…` rules above size and colour it. An element that\n * sets its own `data-slot` to an actual value keeps it — a consumer who named one\n * deliberately meant it. `undefined` and `null` count as unset and get the stamp,\n * because forwarding an optional prop that happens to be absent is idiomatic React\n * and must not silently strip the icon's sizing and colour.\n *\n * Passing only the key we intend to set is deliberate: `cloneElement` already seeds\n * its props from `slot.props`, so spreading them back into the config would be a\n * no-op — except that React 19 copies every config key across with no undefined-skip\n * (`defaultProps` having been removed), which is exactly how a forwarded\n * `data-slot={undefined}` would erase the stamp.\n */\nfunction renderIconSlot(slot: IconSlot | undefined | null): React.ReactNode {\n if (!slot) return null\n if (React.isValidElement<{ 'data-slot'?: string }>(slot)) {\n return React.cloneElement(slot, { 'data-slot': slot.props['data-slot'] ?? 'icon' })\n }\n // `isValidElement` is a type guard, but its false branch does not subtract\n // ReactElement from the union — TS keeps both members — so name the remaining\n // case explicitly. Anything that is not a valid element is a component type.\n const Icon = slot as React.ElementType\n return <Icon data-slot='icon' />\n}\n\n/** Visual/content props shared by `Button` and `ButtonLink`. */\ntype ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOnly' | 'color'> & {\n /**\n * Colour token. Most are safe on any surface: the non-solid variants take\n * their ink from the token and it flips for dark mode, so `primary` reads\n * correctly on a light page and on a dark one.\n *\n * `white` and `secondary` are the exceptions — both are\n * **surface-conditional, for dark surfaces only**. Their inks (`white` and\n * `primary-200`) are already light, which is what makes them right on a\n * dark surface and unusable on a light one: a non-solid button in either\n * colour measures around 1.2:1 on white, against the 3:1 WCAG 1.4.11 asks\n * of a UI component. Reach for them the way `Hero` does — over a\n * `primary-800` panel — and use `primary` on a light or theme-flipping\n * surface. `solid` is unaffected either way, since it pairs `--btn-fill`\n * with `--btn-text` rather than painting the ink.\n */\n color?:\n | 'white'\n | 'grey'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'accent'\n | 'danger'\n | 'success'\n | 'warning'\n | null\n /**\n * Scale step. `sm` / `default` / `lg` render 52 / 60 / 68px tall below\n * `sm:` and 44 / 52 / 60px at or above it. The step changes padding only —\n * the label is 16px and an icon beside it 24px at every step.\n *\n * `icon` is not a fourth step on that ramp — it is a flat 40×40 chrome\n * square (header actions, dialog close buttons, footer social links) that\n * lines up with none of them. For an icon-only button that must sit level\n * with text buttons beside it, pair `iconOnly` with `sm`/`default`/`lg`.\n */\n size?: 'sm' | 'default' | 'lg' | 'icon' | null\n /**\n * Render as a square containing only the icon, at the height of the current\n * `size` step — so `iconOnly` beside a `size='default'` button matches it\n * exactly. Supply an `aria-label`, since there is no visible text.\n *\n * With no label to match, the glyph scales with the square instead of\n * holding the 24px used beside text: 20px at `sm`, 24px at `default`, 28px\n * at `lg`, the same at every breakpoint. For a denser icon button that does\n * not line up with the text steps, use `size='icon'` (24px in a 40×40 box).\n */\n iconOnly?: boolean | null\n className?: string\n /** Button label. Optional for icon-only buttons (supply an `aria-label`). */\n children?: React.ReactNode\n /** Stretch button to fill its container width. */\n block?: boolean\n /** Show a spinner and disable interaction. */\n loading?: boolean\n /** Horizontal alignment of button content. */\n alignContent?: 'center' | 'start'\n disabled?: boolean\n /** Icon rendered before the label. Component or element — see `IconSlot`. */\n leadingVisual?: IconSlot\n /** Icon rendered after the label. Component or element — see `IconSlot`. */\n trailingVisual?: IconSlot\n /** Icon rendered as a trailing action (far end). Component or element. */\n trailingAction?: IconSlot\n /** Allow the button label to wrap onto multiple lines. Defaults to true. */\n labelWrap?: boolean\n /** Optional numeric badge rendered after the label. */\n count?: number\n /**\n * Visually-hidden suffix announced after `count`, giving the bare number\n * context for screen readers (e.g. \"unread messages\" → \"Inbox 3 unread\n * messages\").\n */\n countLabel?: string\n}\n\ntype ButtonProps = ButtonOwnProps & Omit<ButtonPrimitive.Props, 'className' | 'disabled'>\n\ntype ButtonLinkProps = ButtonOwnProps &\n Omit<React.ComponentPropsWithoutRef<typeof Link>, 'className' | 'variant'> & {\n ref?: React.Ref<HTMLAnchorElement>\n }\n\nfunction buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n}: ButtonOwnProps & { effectiveDisabled?: boolean }) {\n return clsx(\n cn(\n buttonVariants({ variant, color, size, iconOnly }),\n block && 'w-full',\n alignContent === 'start' && 'justify-start',\n className,\n ),\n effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer',\n )\n}\n\n/** Shared inner layout: spinner, visuals, label, count, touch target. */\nfunction ButtonContent({\n loading,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n children,\n}: Pick<\n ButtonOwnProps,\n | 'loading'\n | 'leadingVisual'\n | 'trailingVisual'\n | 'trailingAction'\n | 'labelWrap'\n | 'count'\n | 'countLabel'\n | 'children'\n>) {\n return (\n <TouchTarget>\n {loading && (\n <Spinner\n data-slot='icon'\n role={undefined}\n aria-hidden\n color='current'\n // The button's own label + aria-busy convey the busy state; the\n // spinner's default \"Loading\" announcement would be redundant.\n label=''\n // `block` overrides Spinner's default `inline` so the svg isn't\n // pushed below centre by the button's line-height; `size-full` fills\n // the icon-sized, self-centred wrapper span.\n svgClassName='block size-full'\n />\n )}\n {renderIconSlot(leadingVisual)}\n {labelWrap === false ? <span className='whitespace-nowrap'>{children}</span> : children}\n {count !== undefined && (\n <span className='rounded-full px-1.5 py-0.5 text-xs font-medium tabular-nums opacity-75'>\n {count}\n {countLabel ? <span className='sr-only'> {countLabel}</span> : null}\n </span>\n )}\n {renderIconSlot(trailingVisual)}\n {renderIconSlot(trailingAction)}\n </TouchTarget>\n )\n}\n\n/**\n * Dev-only guard shared by `Button` and `ButtonLink`: an icon-only button\n * (`size=\"icon\"` or `iconOnly`) renders no visible text, so it must carry an\n * explicit accessible name. Warns in development when one is missing; a no-op\n * in production. A falsy `aria-label` (including `\"\"`) counts as missing.\n */\nfunction warnIfIconButtonUnlabelled(\n size: ButtonOwnProps['size'],\n iconOnly: ButtonOwnProps['iconOnly'],\n props: { 'aria-label'?: unknown; 'aria-labelledby'?: unknown },\n) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if ((size === 'icon' || iconOnly) && !props['aria-label'] && !props['aria-labelledby']) {\n console.warn(\n '[nswds/ui] Icon-only buttons (size=\"icon\" or iconOnly) have no visible label — pass aria-label or aria-labelledby so the control has an accessible name.',\n )\n }\n}\n\n/**\n * Action button on the Base UI button primitive. For button-styled\n * navigation, use `ButtonLink` — the `href` polymorphism that previously\n * lived on this component was removed in v2.\n *\n * Base UI's `render` prop is available for composition (e.g. rendering a\n * framework-specific element while keeping Button behaviour).\n */\nfunction Button({\n className,\n // Defaulted here rather than left to cva's `defaultVariants` so that\n // `data-variant` below is always present in the DOM. cva resolves its own\n // default internally and emits the right classes either way, but the\n // attribute was simply absent — so the `data-[variant=solid]:` state-overlay\n // rules in `styles.colors` never matched a default `<Button>`. It fell\n // through to the derived overlay in `styles.base` and painted `--btn-bg` at\n // 10% over its own fill, which is the same colour: no visible hover at all.\n variant = 'solid',\n color,\n size,\n iconOnly,\n children,\n block,\n loading,\n alignContent = 'center',\n disabled,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n ref,\n ...props\n}: ButtonProps) {\n const effectiveDisabled = disabled || loading\n\n warnIfIconButtonUnlabelled(size, iconOnly, props)\n\n return (\n <ButtonPrimitive\n data-variant={variant}\n aria-busy={loading || undefined}\n {...props}\n disabled={effectiveDisabled}\n className={buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n })}\n ref={ref}\n >\n <ButtonContent\n loading={loading}\n leadingVisual={leadingVisual}\n trailingVisual={trailingVisual}\n trailingAction={trailingAction}\n labelWrap={labelWrap}\n count={count}\n countLabel={countLabel}\n >\n {children}\n </ButtonContent>\n </ButtonPrimitive>\n )\n}\n\n/**\n * Button-styled anchor. Renders through `Link`, so it picks up the\n * framework link component from `LinkProvider` (e.g. next/link) and accepts\n * all anchor props. Disabled/loading states are conveyed with\n * `aria-disabled` and a click guard, since anchors have no `disabled`\n * attribute.\n */\nfunction ButtonLink({\n className,\n // Always emitted as `data-variant` — see the note in `Button`.\n variant = 'solid',\n color,\n size,\n iconOnly,\n children,\n block,\n loading,\n alignContent = 'center',\n disabled,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n ref,\n ...props\n}: ButtonLinkProps) {\n const effectiveDisabled = disabled || loading\n\n warnIfIconButtonUnlabelled(size, iconOnly, props)\n\n return (\n <Link\n // Opt out of Link's built-in styling — ButtonLink supplies its own\n // complete visual treatment (background, border, focus ring, icon\n // sizing) and any Link styling layered on top would conflict.\n variant='unstyled'\n data-variant={variant}\n aria-busy={loading || undefined}\n {...props}\n {...(effectiveDisabled\n ? {\n 'aria-disabled': true,\n 'data-disabled': '',\n tabIndex: -1,\n onClick: (e: React.MouseEvent<HTMLAnchorElement>) => e.preventDefault(),\n }\n : {})}\n className={buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n })}\n ref={ref}\n >\n <ButtonContent\n loading={loading}\n leadingVisual={leadingVisual}\n trailingVisual={trailingVisual}\n trailingAction={trailingAction}\n labelWrap={labelWrap}\n count={count}\n countLabel={countLabel}\n >\n {children}\n </ButtonContent>\n </Link>\n )\n}\n\n/**\n * Expand the hit area to at least 44×44px on touch devices\n */\nfunction TouchTarget({ children }: { children: React.ReactNode }) {\n return (\n <>\n <span\n className='absolute top-1/2 left-1/2 size-[max(100%,2.75rem)] -translate-x-1/2 -translate-y-1/2 rounded-sm bg-transparent [@media(pointer:fine)]:hidden'\n aria-hidden='true'\n />\n {children}\n </>\n )\n}\n\nexport { Button, ButtonLink, buttonVariants, TouchTarget }\nexport type { ButtonLinkProps, ButtonProps, IconSlot }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/button.tsx"],"names":["ButtonPrimitive"],"mappings":";;;;;;;;;AAYA,MAAM,MAAA,GAAS;AAAA,EACb,IAAA,EAAM;AAAA;AAAA,IAEJ,uIAAA;AAAA;AAAA;AAAA,IAGA,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,sBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,+EAAA;AAAA;AAAA,IAEA,4DAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,yEAAA;AAAA,IACA,0EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,gCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA,GACF;AAAA,EACA,KAAA,EAAO;AAAA;AAAA,IAEL,mBAAA;AAAA;AAAA,IAEA,sCAAA;AAAA;AAAA,IAEA,sBAAA;AAAA;AAAA,IAEA,gHAAA;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,wBAA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ACF;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 // The ring is offset 2px, so it lands on the *page* rather than on the\n // button. `--btn-bg` is the ink (see the note above `styles.colors`), which\n // flips for dark mode, so the ring follows the theme for every variant —\n // including `solid`, whose ring used to be its own fill colour and so went\n // near-invisible on a dark surface.\n 'focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--btn-bg)',\n // Disabled\n 'data-disabled:opacity-50 data-disabled:pointer-events-none',\n // State overlays, derived from the ink rather than restated per colour.\n // Deriving them means they follow `--btn-bg` wherever it comes from: the\n // colour token, its dark-mode counterpart, or a surface that re-points the\n // ink at its own (`[--btn-bg:var(--footer-ink)]` in footer.tsx and\n // footer-cta.tsx). `solid` overrides both with its white/black pair at\n // `data-[variant=solid]:` — an attribute selector, so it outranks these\n // regardless of source order. `oklab` matches the interpolation space\n // Tailwind's own `/10` alpha modifier emits, so the painted colour is\n // unchanged from when each colour restated these itself.\n '[--btn-hover-overlay:color-mix(in_oklab,var(--btn-bg)_10%,transparent)]',\n '[--btn-active-overlay:color-mix(in_oklab,var(--btn-bg)_20%,transparent)]',\n // Glyph size beside a label: one value for every step and breakpoint.\n // Every step sets `text-base/7`, so the label is 16px whatever the step —\n // only the padding changes. An icon next to it has to match the *text*,\n // not the box, so scaling it per step pairs a growing glyph with type that\n // never moves: at `lg` a 28px icon sat beside a 16px word, two and a half\n // times its cap height. 24px is 1.5x the label at every step, and the same\n // number `size='icon'` uses. `iconOnly` overrides this per step in\n // `compoundVariants` — with no label to match, it scales with its box.\n '[--btn-icon-size:--spacing(6)]',\n // Icon. No vertical margin: the glyph is `self-center` in a baseline-aligned\n // row, so margin buys it nothing optically and only inflates the flex line.\n // It was inert at `sm`/`default` (glyph + margin stayed inside the 1.75rem\n // line box) but pushed `lg` 2px past its own height below `sm:`, so a `lg`\n // button measured 70px with an icon and 68px without.\n '*:data-[slot=icon]:-mx-0.25 *:data-[slot=icon]:size-(--btn-icon-size) *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center *:data-[slot=icon]:text-(--btn-icon) forced-colors:[--btn-icon:ButtonText] forced-colors:hover:[--btn-icon:ButtonText]',\n ],\n solid: [\n // Text color\n 'text-(--btn-text)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-border)',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-fill)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-fill)',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n soft: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-bg)/10',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)/20',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)/10',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:bg-white/5',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n surface: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-(--btn-bg)/50 border-2 bg-(--btn-bg)/5 [--btn-border-w:2px]',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--btn-bg)/30',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-bg)/5',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--btn-bg)/50',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // Border color on hover\n 'active:border-(--btn-bg) hover:border-(--btn-bg)',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n outline: [\n // Text color\n 'border-(--btn-bg) text-(--btn-bg) border-2 [--btn-border-w:2px]',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'bg-transparent',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-transparent',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--btn-bg)',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n ghost: [\n // Text color\n 'text-(--btn-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--btn-transparent)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--btn-transparent)',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // State overlays\n 'hover:after:bg-(--btn-hover-overlay) active:after:bg-(--btn-active-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n link: [\n // Text color — inherits from color token, no background or border\n 'text-(--btn-bg) border-transparent bg-transparent',\n // Halo tokens derive from the colour token via color-mix, mirroring Link\n '[--link-halo:color-mix(in_oklch,var(--btn-bg)_10%,transparent)]',\n '[--link-halo-active:color-mix(in_oklch,var(--btn-bg)_18%,transparent)]',\n // Resting underline, thickened on interaction — matching Link\n 'underline underline-offset-4 hover:decoration-2 active:decoration-2',\n // Hover / active halos match the GOV.UK-style halo on Link (see link.tsx\n // styledBase): the fill is painted on the `after` layer — consistent with\n // the other variants' hover overlays — and the box-shadow extends it 2px\n // above and 4px below the line box\n 'after:absolute after:inset-0 after:-z-10',\n 'hover:after:bg-(--link-halo) active:after:bg-(--link-halo-active)',\n 'hover:shadow-[0_-2px_0_var(--link-halo),0_4px_0_var(--link-halo)]',\n 'active:shadow-[0_-2px_0_var(--link-halo-active),0_4px_0_var(--link-halo-active)]',\n ],\n // Two variables, deliberately separate.\n //\n // `--btn-fill` is the block of colour `solid` paints behind `--btn-text`.\n // `--btn-bg` is the *ink*: the glyph and label on every non-solid variant\n // (`text-(--btn-bg)`), the border on `outline`/`surface`, the tint on\n // `soft`/`surface`, the `link` halos, the state overlays derived in\n // `styles.base`, and the focus ring. They start life the same colour, and\n // only part company in dark mode.\n //\n // They used to be one variable, which made the ink un-flippable. The values\n // here are masterbrand palette steps, and palette steps are theme-invariant —\n // `styles.css` re-declares only the *semantic* tokens under\n // `[data-theme=dark], .dark`. Design-system surfaces do flip, though\n // (`Header color='white'` is `bg-white dark:bg-grey-900`), so a non-solid\n // button kept its light-mode ink on a dark surface: `primary-800` on\n // `grey-900` measures 1.32:1, far under the 3:1 WCAG 1.4.11 asks of a UI\n // component, with the overlays and focus ring unpainted for the same reason.\n // Splitting the fill off means `--btn-bg` can flip on its own without\n // repainting `solid`, so the dark counterparts below need no variant scoping\n // and stay at single-class specificity — which is what keeps them overridable\n // by a surface that imposes its own ink (`[--btn-bg:var(--footer-ink)]` in\n // footer.tsx and footer-cta.tsx). Raising their specificity would silently\n // win against those, so keep any future dark value a bare `dark:` utility.\n //\n // `-200` is the package's established ink-on-dark (`--link-color`,\n // `--main-nav-panel-ink`) and clears 10:1 against every dark surface token.\n // `white` and `secondary` are already light inks, so they have no counterpart.\n //\n // Dark values use the raw NSW tokens for the tree-shaking reason spelled out\n // above `danger` below.\n colors: {\n grey: [\n // Base\n '[--btn-fill:var(--color-grey-600)] [--btn-bg:var(--color-grey-600)] [--btn-border:var(--color-grey-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--grey-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n white: [\n // No dark counterpart: white is already the maximum-contrast ink on any\n // dark surface. Surface-conditional in the same way as `secondary` — on a\n // light surface a non-solid `white` button is white on white. See the\n // note on the `color` prop.\n // Base\n '[--btn-fill:var(--color-white)] [--btn-bg:var(--color-white)] [--btn-border:var(--color-white)]/90 [--btn-text:var(--color-grey-800)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-black)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n primary: [\n // Base\n '[--btn-fill:var(--color-primary-800)] [--btn-bg:var(--color-primary-800)] [--btn-border:var(--color-primary-800)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--primary-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n secondary: [\n // No dark counterpart: `primary-200` already *is* the ink the other\n // colours flip to. Like `white`, this token is surface-conditional — it\n // is meant for dark surfaces, where it lands at 15.40:1. As a non-solid\n // ink on a light one it measures ~1.2:1, so that pairing is misuse\n // rather than a defect to fix here. See the note on the `color` prop.\n // Base\n '[--btn-fill:var(--color-primary-200)] [--btn-bg:var(--color-primary-200)] [--btn-border:var(--color-primary-200)]/90 [--btn-text:var(--color-primary-800)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/15',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-primary-800)]/10',\n ],\n tertiary: [\n // Base\n '[--btn-fill:var(--color-primary-600)] [--btn-bg:var(--color-primary-600)] [--btn-border:var(--color-primary-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--primary-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n accent: [\n // Base\n '[--btn-fill:var(--color-accent-600)] [--btn-bg:var(--color-accent-600)] [--btn-border:var(--color-accent-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--accent-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n // Semantic colours use the raw NSW token names (--danger-600, --success-600,\n // --warning-600) rather than Tailwind's `--color-*` bridge aliases. The\n // bridge aliases are tree-shaken by Tailwind v4 unless a matching utility\n // class is detected in scanned source, and arbitrary-property usages like\n // `[--btn-bg:var(--color-success-600)]` do NOT count as a usage signal.\n // The raw tokens are defined on :root by @nswds/tokens (a plain CSS import,\n // not a Tailwind theme), so they always resolve.\n danger: [\n // Base\n '[--btn-fill:var(--danger-600)] [--btn-bg:var(--danger-600)] [--btn-border:var(--danger-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--danger-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n success: [\n // Base\n '[--btn-fill:var(--success-600)] [--btn-bg:var(--success-600)] [--btn-border:var(--success-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--success-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n warning: [\n // Base\n '[--btn-fill:var(--warning-600)] [--btn-bg:var(--warning-600)] [--btn-border:var(--warning-600)]/90 [--btn-text:white]',\n // Dark mode: ink\n 'dark:[--btn-bg:var(--warning-200)]',\n // State: Hover\n 'data-[variant=solid]:[--btn-hover-overlay:var(--color-white)]/10',\n // State: Active\n 'data-[variant=solid]:[--btn-active-overlay:var(--color-black)]/15',\n ],\n },\n // Each step publishes its own height as `--btn-h`, built from the same two\n // numbers that produce its box: one line box (`text-base/7` — Tailwind's\n // `/7` is `--spacing(7)`, so this is the same token, not a matching literal)\n // plus twice the vertical padding. `styles.base` pins it with `min-h`, and\n // `styles.iconOnly` reads it as both dimensions of the square — so an\n // icon-only button is exactly as tall as the text button beside it by\n // construction, and stays that way if a step is ever retuned.\n //\n // The border cancels out of that sum: padding is `--spacing(n) -\n // --btn-border-w` and the border adds `--btn-border-w` back, so every\n // variant lands on `--btn-h` whether it draws a 1px or 2px edge, and the\n // outer geometry stays put while the label shifts 1px to make room.\n //\n // The steps set padding and height only. Glyph size lives on the base (one\n // value beside a label) and in `compoundVariants` (per step when icon-only).\n size: {\n default:\n 'px-[calc(--spacing(6)-var(--btn-border-w))] py-[calc(--spacing(4)-var(--btn-border-w))] sm:px-[calc(--spacing(5.5)-var(--btn-border-w))] sm:py-[calc(--spacing(3)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(4)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(3)*2)]',\n sm: 'px-[calc(--spacing(5)-var(--btn-border-w))] py-[calc(--spacing(3)-var(--btn-border-w))] sm:px-[calc(--spacing(4.5)-var(--btn-border-w))] sm:py-[calc(--spacing(2)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(3)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(2)*2)]',\n lg: 'px-[calc(--spacing(7)-var(--btn-border-w))] py-[calc(--spacing(5)-var(--btn-border-w))] sm:px-[calc(--spacing(6.5)-var(--btn-border-w))] sm:py-[calc(--spacing(4)-var(--btn-border-w))] [--btn-h:calc(--spacing(7)+--spacing(5)*2)] sm:[--btn-h:calc(--spacing(7)+--spacing(4)*2)]',\n // A compact chrome square that deliberately sits below the text steps —\n // header actions, dialog close buttons, footer social links. For an icon\n // button that must line up with text buttons beside it, use `iconOnly`\n // with `sm`/`default`/`lg` instead. Its glyph is the base 24px.\n icon: 'w-10 h-10 flex-none [--btn-h:--spacing(10)]',\n },\n // Square the button at the current step and drop the horizontal padding, so\n // the scale step and \"is this icon-only\" are independent axes. The glyph\n // needs no adjustment — the step already sizes it off the ladder.\n iconOnly: 'size-(--btn-h) flex-none p-0 sm:p-0',\n}\n\nconst buttonVariants = cva(styles.base, {\n variants: {\n variant: {\n solid: styles.solid,\n soft: styles.soft,\n surface: styles.surface,\n outline: styles.outline,\n ghost: styles.ghost,\n link: styles.link,\n },\n color: {\n white: styles.colors.white,\n grey: styles.colors.grey,\n primary: styles.colors.primary,\n secondary: styles.colors.secondary,\n tertiary: styles.colors.tertiary,\n accent: styles.colors.accent,\n danger: styles.colors.danger,\n success: styles.colors.success,\n warning: styles.colors.warning,\n },\n size: {\n default: styles.size.default,\n sm: styles.size.sm,\n lg: styles.size.lg,\n icon: styles.size.icon,\n },\n // Declared after `size` so its `p-0` reaches `cn()` downstream of the\n // step's `px-*`/`py-*` and wins the tailwind-merge conflict.\n iconOnly: {\n true: styles.iconOnly,\n false: '',\n },\n },\n compoundVariants: [\n // ── Icon-only glyph sizes ────────────────────────────────────────────\n //\n // With no label beside it the glyph has nothing to match, so here — and\n // only here — it scales with its box, off the icon ladder: 20 / 24 / 28 /\n // 32 / 36 / 40px, i.e. `--spacing(5)` through `--spacing(10)`. Every level\n // is a multiple of 4, so glyphs share the grid with the padding and\n // heights around them and land on whole device pixels at 1x. A discrete\n // ladder rather than a proportion of the box, because a glyph is only\n // crisp at the sizes it was drawn for — \"40% of the box\" would ask for\n // sizes no glyph exists at.\n //\n // One value per step, not per breakpoint: the square never gets smaller\n // on a wider viewport, so neither should what sits inside it.\n { size: 'sm', iconOnly: true, className: '[--btn-icon-size:--spacing(5)]' },\n { size: 'default', iconOnly: true, className: '[--btn-icon-size:--spacing(6)]' },\n { size: 'lg', iconOnly: true, className: '[--btn-icon-size:--spacing(7)]' },\n // The link variant reads as an inline Link despite the <button> tag:\n // strip the button chrome (padding from `size`, border, radius, bold\n // weight) and adopt Link's typography and 1em icon sizing so the hover\n // halo hugs the text instead of filling a button-shaped box.\n {\n variant: 'link',\n className: [\n 'rounded-none border-0 p-0 sm:p-0',\n // Release the step's height floor too — an inline link hugs its line\n // box, it does not stand a button's worth of space tall.\n 'min-h-0',\n // Hug the label even in stretching grid/flex contexts so the hover\n // halo wraps the text like an inline Link, not the allocated box.\n // `block` still wins — its w-full is applied after this in cn().\n 'w-fit',\n 'text-[length:inherit] font-medium',\n '*:data-[slot=icon]:size-[1em]',\n ],\n },\n ],\n defaultVariants: {\n variant: 'solid',\n color: 'primary',\n size: 'default',\n },\n})\n\n/**\n * An icon slot. Takes either form:\n *\n * - the component itself — `leadingVisual={IconDownload}`\n * - a rendered element — `leadingVisual={<IconDownload />}`\n *\n * **From a React Server Component, use the element form.** `Button` and\n * `ButtonLink` are `'use client'` modules, while the icon modules carry no\n * directive — deliberately, so an icon stays server-renderable and ships no\n * JavaScript. That means in a server component `IconDownload` is an ordinary\n * function value, and functions cannot cross the RSC boundary into a client\n * component (\"Functions cannot be passed directly to Client Components\"). A\n * React element can, because it serialises. Client components can use either.\n */\ntype IconSlot = React.ElementType | React.ReactElement\n\n/**\n * Renders an icon slot in whichever form it arrived, stamping `data-slot='icon'`\n * so the `*:data-[slot=icon]:…` rules above size and colour it. An element that\n * sets its own `data-slot` to an actual value keeps it — a consumer who named one\n * deliberately meant it. `undefined` and `null` count as unset and get the stamp,\n * because forwarding an optional prop that happens to be absent is idiomatic React\n * and must not silently strip the icon's sizing and colour.\n *\n * Passing only the key we intend to set is deliberate: `cloneElement` already seeds\n * its props from `slot.props`, so spreading them back into the config would be a\n * no-op — except that React 19 copies every config key across with no undefined-skip\n * (`defaultProps` having been removed), which is exactly how a forwarded\n * `data-slot={undefined}` would erase the stamp.\n */\nfunction renderIconSlot(slot: IconSlot | undefined | null): React.ReactNode {\n if (!slot) return null\n if (React.isValidElement<{ 'data-slot'?: string }>(slot)) {\n return React.cloneElement(slot, { 'data-slot': slot.props['data-slot'] ?? 'icon' })\n }\n // `isValidElement` is a type guard, but its false branch does not subtract\n // ReactElement from the union — TS keeps both members — so name the remaining\n // case explicitly. Anything that is not a valid element is a component type.\n const Icon = slot as React.ElementType\n return <Icon data-slot='icon' />\n}\n\n/** Visual/content props shared by `Button` and `ButtonLink`. */\ntype ButtonOwnProps = Omit<VariantProps<typeof buttonVariants>, 'size' | 'iconOnly' | 'color'> & {\n /**\n * Colour token. Most are safe on any surface: the non-solid variants take\n * their ink from the token and it flips for dark mode, so `primary` reads\n * correctly on a light page and on a dark one.\n *\n * `white` and `secondary` are the exceptions — both are\n * **surface-conditional, for dark surfaces only**. Their inks (`white` and\n * `primary-200`) are already light, which is what makes them right on a\n * dark surface and unusable on a light one: a non-solid button in either\n * colour measures around 1.2:1 on white, against the 3:1 WCAG 1.4.11 asks\n * of a UI component. Reach for them the way `Hero` does — over a\n * `primary-800` panel — and use `primary` on a light or theme-flipping\n * surface. `solid` is unaffected either way, since it pairs `--btn-fill`\n * with `--btn-text` rather than painting the ink.\n */\n color?:\n | 'white'\n | 'grey'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'accent'\n | 'danger'\n | 'success'\n | 'warning'\n | null\n /**\n * Scale step. `sm` / `default` / `lg` render 52 / 60 / 68px tall below\n * `sm:` and 44 / 52 / 60px at or above it. The step changes padding only —\n * the label is 16px and an icon beside it 24px at every step.\n *\n * `icon` is not a fourth step on that ramp — it is a flat 40×40 chrome\n * square (header actions, dialog close buttons, footer social links) that\n * lines up with none of them. For an icon-only button that must sit level\n * with text buttons beside it, pair `iconOnly` with `sm`/`default`/`lg`.\n */\n size?: 'sm' | 'default' | 'lg' | 'icon' | null\n /**\n * Render as a square containing only the icon, at the height of the current\n * `size` step — so `iconOnly` beside a `size='default'` button matches it\n * exactly. Supply an `aria-label`, since there is no visible text.\n *\n * With no label to match, the glyph scales with the square instead of\n * holding the 24px used beside text: 20px at `sm`, 24px at `default`, 28px\n * at `lg`, the same at every breakpoint. For a denser icon button that does\n * not line up with the text steps, use `size='icon'` (24px in a 40×40 box).\n */\n iconOnly?: boolean | null\n className?: string\n /** Button label. Optional for icon-only buttons (supply an `aria-label`). */\n children?: React.ReactNode\n /** Stretch button to fill its container width. */\n block?: boolean\n /** Show a spinner and disable interaction. */\n loading?: boolean\n /** Horizontal alignment of button content. */\n alignContent?: 'center' | 'start'\n disabled?: boolean\n /** Icon rendered before the label. Component or element — see `IconSlot`. */\n leadingVisual?: IconSlot\n /** Icon rendered after the label. Component or element — see `IconSlot`. */\n trailingVisual?: IconSlot\n /** Icon rendered as a trailing action (far end). Component or element. */\n trailingAction?: IconSlot\n /** Allow the button label to wrap onto multiple lines. Defaults to true. */\n labelWrap?: boolean\n /** Optional numeric badge rendered after the label. */\n count?: number\n /**\n * Visually-hidden suffix announced after `count`, giving the bare number\n * context for screen readers (e.g. \"unread messages\" → \"Inbox 3 unread\n * messages\").\n */\n countLabel?: string\n}\n\ntype ButtonProps = ButtonOwnProps & Omit<ButtonPrimitive.Props, 'className' | 'disabled'>\n\ntype ButtonLinkProps = ButtonOwnProps &\n Omit<React.ComponentPropsWithoutRef<typeof Link>, 'className' | 'variant'> & {\n ref?: React.Ref<HTMLAnchorElement>\n }\n\nfunction buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n}: ButtonOwnProps & { effectiveDisabled?: boolean }) {\n return clsx(\n cn(\n buttonVariants({ variant, color, size, iconOnly }),\n block && 'w-full',\n alignContent === 'start' && 'justify-start',\n className,\n ),\n effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer',\n )\n}\n\n/** Shared inner layout: spinner, visuals, label, count, touch target. */\nfunction ButtonContent({\n loading,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n children,\n}: Pick<\n ButtonOwnProps,\n | 'loading'\n | 'leadingVisual'\n | 'trailingVisual'\n | 'trailingAction'\n | 'labelWrap'\n | 'count'\n | 'countLabel'\n | 'children'\n>) {\n return (\n <TouchTarget>\n {loading && (\n <Spinner\n data-slot='icon'\n role={undefined}\n aria-hidden\n color='current'\n // The button's own label + aria-busy convey the busy state; the\n // spinner's default \"Loading\" announcement would be redundant.\n label=''\n // `block` overrides Spinner's default `inline` so the svg isn't\n // pushed below centre by the button's line-height; `size-full` fills\n // the icon-sized, self-centred wrapper span.\n svgClassName='block size-full'\n />\n )}\n {renderIconSlot(leadingVisual)}\n {labelWrap === false ? <span className='whitespace-nowrap'>{children}</span> : children}\n {count !== undefined && (\n <span className='rounded-full px-1.5 py-0.5 text-xs font-medium tabular-nums opacity-75'>\n {count}\n {countLabel ? <span className='sr-only'> {countLabel}</span> : null}\n </span>\n )}\n {renderIconSlot(trailingVisual)}\n {renderIconSlot(trailingAction)}\n </TouchTarget>\n )\n}\n\n/**\n * Whether a child tree carries visible text: a non-empty string or a number,\n * at the top level, in an array, or inside a Fragment however deep. Other\n * elements are not looked into — `Children.toArray` flattens arrays but hands\n * a Fragment back whole, so the Fragment case is walked by hand.\n */\nfunction hasTextChild(children: React.ReactNode): boolean {\n return React.Children.toArray(children).some((child) => {\n if (typeof child === 'string') return child.trim() !== ''\n if (typeof child === 'number') return true\n if (\n React.isValidElement<{ children?: React.ReactNode }>(child) &&\n child.type === React.Fragment\n ) {\n return hasTextChild(child.props.children)\n }\n return false\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 *\n * A text child counts as a label. `size=\"icon\"` is also the square a\n * `PaginationLink` page number sits in, and a bare \"2\" is a visible, readable\n * name — axe accepts it and so does this guard. Only a string or a number\n * qualifies, at the top level or directly inside a fragment or array; an\n * element child is most likely the icon itself, which is the case the guard\n * exists for.\n */\nfunction warnIfIconButtonUnlabelled(\n size: ButtonOwnProps['size'],\n iconOnly: ButtonOwnProps['iconOnly'],\n props: { 'aria-label'?: unknown; 'aria-labelledby'?: unknown },\n children: React.ReactNode,\n) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (\n (size === 'icon' || iconOnly) &&\n !props['aria-label'] &&\n !props['aria-labelledby'] &&\n !hasTextChild(children)\n ) {\n console.warn(\n '[nswds/ui] Icon-only buttons (size=\"icon\" or iconOnly) have no visible label — pass aria-label or aria-labelledby so the control has an accessible name.',\n )\n }\n}\n\n/**\n * Action button on the Base UI button primitive. For button-styled\n * navigation, use `ButtonLink` — the `href` polymorphism that previously\n * lived on this component was removed in v2.\n *\n * Base UI's `render` prop is available for composition (e.g. rendering a\n * framework-specific element while keeping Button behaviour).\n */\nfunction Button({\n className,\n // Defaulted here rather than left to cva's `defaultVariants` so that\n // `data-variant` below is always present in the DOM. cva resolves its own\n // default internally and emits the right classes either way, but the\n // attribute was simply absent — so the `data-[variant=solid]:` state-overlay\n // rules in `styles.colors` never matched a default `<Button>`. It fell\n // through to the derived overlay in `styles.base` and painted `--btn-bg` at\n // 10% over its own fill, which is the same colour: no visible hover at all.\n variant = 'solid',\n color,\n size,\n iconOnly,\n children,\n block,\n loading,\n alignContent = 'center',\n disabled,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n ref,\n ...props\n}: ButtonProps) {\n const effectiveDisabled = disabled || loading\n\n warnIfIconButtonUnlabelled(size, iconOnly, props, children)\n\n return (\n <ButtonPrimitive\n data-variant={variant}\n aria-busy={loading || undefined}\n {...props}\n disabled={effectiveDisabled}\n className={buttonClasses({\n variant,\n color,\n size,\n iconOnly,\n block,\n alignContent,\n className,\n effectiveDisabled,\n })}\n ref={ref}\n >\n <ButtonContent\n loading={loading}\n leadingVisual={leadingVisual}\n trailingVisual={trailingVisual}\n trailingAction={trailingAction}\n labelWrap={labelWrap}\n count={count}\n countLabel={countLabel}\n >\n {children}\n </ButtonContent>\n </ButtonPrimitive>\n )\n}\n\n/**\n * Button-styled anchor. Renders through `Link`, so it picks up the\n * framework link component from `LinkProvider` (e.g. next/link) and accepts\n * all anchor props. Disabled/loading states are conveyed with\n * `aria-disabled` and a click guard, since anchors have no `disabled`\n * attribute.\n */\nfunction ButtonLink({\n className,\n // Always emitted as `data-variant` — see the note in `Button`.\n variant = 'solid',\n color,\n size,\n iconOnly,\n children,\n block,\n loading,\n alignContent = 'center',\n disabled,\n leadingVisual,\n trailingVisual,\n trailingAction,\n labelWrap,\n count,\n countLabel,\n ref,\n ...props\n}: ButtonLinkProps) {\n const effectiveDisabled = disabled || loading\n\n warnIfIconButtonUnlabelled(size, iconOnly, props, children)\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"]}
|
|
@@ -25,10 +25,22 @@ type CarouselContextProps = {
|
|
|
25
25
|
canScrollNext: boolean;
|
|
26
26
|
} & CarouselProps;
|
|
27
27
|
declare function useCarousel(): CarouselContextProps;
|
|
28
|
-
declare function Carousel({ orientation, opts, setApi, plugins, className, children, ...props }: React.ComponentProps<'div'> & CarouselProps): React.JSX.Element;
|
|
28
|
+
declare function Carousel({ orientation, opts, setApi, plugins, className, children, onKeyDown, ...props }: React.ComponentProps<'div'> & CarouselProps): React.JSX.Element;
|
|
29
29
|
declare function CarouselContent({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
30
30
|
declare function CarouselItem({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
31
|
-
declare function CarouselPrevious({ className, variant, size, ...props }: React.ComponentProps<typeof Button>
|
|
32
|
-
|
|
31
|
+
declare function CarouselPrevious({ className, variant, size, label, children, ...props }: React.ComponentProps<typeof Button> & {
|
|
32
|
+
/**
|
|
33
|
+
* Screen-reader name for the control. Override to translate it — the
|
|
34
|
+
* control is icon-only, so this string is the only name AT ever hears.
|
|
35
|
+
*/
|
|
36
|
+
label?: string;
|
|
37
|
+
}): React.JSX.Element;
|
|
38
|
+
declare function CarouselNext({ className, variant, size, label, children, ...props }: React.ComponentProps<typeof Button> & {
|
|
39
|
+
/**
|
|
40
|
+
* Screen-reader name for the control. Override to translate it — the
|
|
41
|
+
* control is icon-only, so this string is the only name AT ever hears.
|
|
42
|
+
*/
|
|
43
|
+
label?: string;
|
|
44
|
+
}): React.JSX.Element;
|
|
33
45
|
|
|
34
46
|
export { Carousel, type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, useCarousel };
|