@utilitywarehouse/hearth-react 0.28.6 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +34 -20
  2. package/SKILL.md +355 -0
  3. package/dist/{chunk-O7RBVBMN.cjs → chunk-LWHIBSW2.cjs} +2 -2
  4. package/dist/{chunk-O7RBVBMN.cjs.map → chunk-LWHIBSW2.cjs.map} +1 -1
  5. package/dist/{chunk-JRVYOIXR.js → chunk-MIVYZGEV.js} +2 -2
  6. package/dist/components/CardAccordion/CardAccordion.context.d.ts.map +1 -1
  7. package/dist/components/Combobox/Combobox.cjs +1 -1
  8. package/dist/components/Combobox/Combobox.js +1 -1
  9. package/dist/components/ExpandableCard/ExpandableCard.cjs +1 -1
  10. package/dist/components/ExpandableCard/ExpandableCard.js +1 -1
  11. package/dist/helpers/get-classname-styles.d.ts.map +1 -1
  12. package/dist/helpers/logger.d.ts.map +1 -1
  13. package/dist/helpers/merge-ids.d.ts.map +1 -1
  14. package/dist/hooks/use-ids.d.ts.map +1 -1
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.js +1 -1
  18. package/package.json +18 -12
  19. package/public/llms/components/accordion.md +321 -0
  20. package/public/llms/components/alert.md +217 -0
  21. package/public/llms/components/avatar.md +112 -0
  22. package/public/llms/components/badge.md +158 -0
  23. package/public/llms/components/body-text.md +200 -0
  24. package/public/llms/components/box.md +148 -0
  25. package/public/llms/components/breadcrumbs.md +97 -0
  26. package/public/llms/components/button.md +595 -0
  27. package/public/llms/components/card-accordion.md +277 -0
  28. package/public/llms/components/card.md +985 -0
  29. package/public/llms/components/checkbox-group.md +193 -0
  30. package/public/llms/components/checkbox-tile.md +116 -0
  31. package/public/llms/components/checkbox.md +108 -0
  32. package/public/llms/components/combobox.md +360 -0
  33. package/public/llms/components/container.md +162 -0
  34. package/public/llms/components/currency-input.md +85 -0
  35. package/public/llms/components/date-input.md +90 -0
  36. package/public/llms/components/date-picker.md +159 -0
  37. package/public/llms/components/description-list.md +149 -0
  38. package/public/llms/components/detail-text.md +89 -0
  39. package/public/llms/components/divider.md +88 -0
  40. package/public/llms/components/em.md +43 -0
  41. package/public/llms/components/expandable-card.md +231 -0
  42. package/public/llms/components/flex.md +197 -0
  43. package/public/llms/components/grid.md +244 -0
  44. package/public/llms/components/heading.md +65 -0
  45. package/public/llms/components/helper-text.md +27 -0
  46. package/public/llms/components/highlight-banner.md +94 -0
  47. package/public/llms/components/icon-button.md +516 -0
  48. package/public/llms/components/icon-container.md +247 -0
  49. package/public/llms/components/inline-link.md +190 -0
  50. package/public/llms/components/label.md +28 -0
  51. package/public/llms/components/link.md +236 -0
  52. package/public/llms/components/list.md +715 -0
  53. package/public/llms/components/menu.md +270 -0
  54. package/public/llms/components/modal.md +328 -0
  55. package/public/llms/components/pagination.md +138 -0
  56. package/public/llms/components/password-input.md +93 -0
  57. package/public/llms/components/progress-bar.md +139 -0
  58. package/public/llms/components/progress-stepper.md +147 -0
  59. package/public/llms/components/radio-group.md +487 -0
  60. package/public/llms/components/search-input.md +132 -0
  61. package/public/llms/components/section-header.md +82 -0
  62. package/public/llms/components/select.md +148 -0
  63. package/public/llms/components/skeleton.md +282 -0
  64. package/public/llms/components/spinner.md +59 -0
  65. package/public/llms/components/strong.md +49 -0
  66. package/public/llms/components/switch.md +106 -0
  67. package/public/llms/components/table.md +230 -0
  68. package/public/llms/components/tabs.md +320 -0
  69. package/public/llms/components/text-area.md +141 -0
  70. package/public/llms/components/text-input.md +228 -0
  71. package/public/llms/components/toast.md +323 -0
  72. package/public/llms/components/toggle-button-card.md +513 -0
  73. package/public/llms/components/tooltip.md +188 -0
  74. package/public/llms/components/unstyled-icon-button.md +175 -0
  75. package/public/llms/components/validation-text.md +29 -0
  76. package/public/llms/components/verification-input.md +96 -0
  77. package/public/llms/docs/changelog.md +1430 -0
  78. package/public/llms/docs/common-props/align-self.md +90 -0
  79. package/public/llms/docs/common-props/border.md +308 -0
  80. package/public/llms/docs/common-props/colour.md +221 -0
  81. package/public/llms/docs/common-props/flex-items.md +91 -0
  82. package/public/llms/docs/common-props/gap.md +111 -0
  83. package/public/llms/docs/common-props/grid-items.md +96 -0
  84. package/public/llms/docs/common-props/margin.md +105 -0
  85. package/public/llms/docs/common-props/opacity.md +100 -0
  86. package/public/llms/docs/common-props/order.md +90 -0
  87. package/public/llms/docs/common-props/overflow.md +89 -0
  88. package/public/llms/docs/common-props/padding.md +102 -0
  89. package/public/llms/docs/common-props/position.md +92 -0
  90. package/public/llms/docs/common-props/size.md +93 -0
  91. package/public/llms/docs/common-props/spacing.md +97 -0
  92. package/public/llms/docs/common-props/text.md +35 -0
  93. package/public/llms/docs/common-props/z-index.md +88 -0
  94. package/public/llms/docs/design-tokens.md +72 -0
  95. package/public/llms/docs/getting-started.md +117 -0
  96. package/public/llms/docs/layout.md +135 -0
  97. package/public/llms/docs/migrating.md +302 -0
  98. package/public/llms/docs/responsive-design/breakpoints.md +119 -0
  99. package/public/llms/docs/responsive-design/media-queries.md +89 -0
  100. package/public/llms/docs/responsive-design/responsive-props.md +37 -0
  101. package/public/llms.txt +97 -0
  102. package/scripts/init-ai.js +142 -0
  103. package/styles.css +2 -2
  104. /package/dist/{chunk-JRVYOIXR.js.map → chunk-MIVYZGEV.js.map} +0 -0
@@ -0,0 +1,595 @@
1
+ # Button
2
+
3
+ Trigger an action or event, such as submitting a form or displaying a dialog.
4
+
5
+ ```tsx
6
+ <Flex direction="column" gap="600">
7
+ <Flex gap="200" direction="column">
8
+ <Heading>Emphasis</Heading>
9
+ <Flex gap="400" alignItems="center">
10
+ {sizes.map(size => (
11
+ <Flex key={size} gap="100">
12
+ <Button variant="emphasis" colorScheme="highlight" size={size}>
13
+ Button
14
+ </Button>
15
+ </Flex>
16
+ ))}
17
+ </Flex>
18
+ <Flex gap="400" alignItems="center">
19
+ {sizes.map(size => (
20
+ <Flex key={size} gap="100">
21
+ <Button disabled variant="emphasis" colorScheme="highlight" size={size}>
22
+ Button
23
+ </Button>
24
+ </Flex>
25
+ ))}
26
+ </Flex>
27
+ <Flex gap="400" alignItems="center">
28
+ {sizes.map(size => (
29
+ <Flex key={size} gap="100">
30
+ <Button loading variant="emphasis" colorScheme="highlight" size={size}>
31
+ Button
32
+ </Button>
33
+ </Flex>
34
+ ))}
35
+ </Flex>
36
+ </Flex>
37
+ <Flex gap="200" direction="column">
38
+ <Heading>Solid</Heading>
39
+ <Flex gap="400" alignItems="center">
40
+ {sizes.map(size => (
41
+ <Flex key={size} gap="100">
42
+ {solidColorSchemes.map(colorScheme => (
43
+ <Button key={colorScheme} variant="solid" colorScheme={colorScheme} size={size}>
44
+ Button
45
+ </Button>
46
+ ))}
47
+ </Flex>
48
+ ))}
49
+ </Flex>
50
+ <Flex gap="400" alignItems="center">
51
+ {sizes.map(size => (
52
+ <Flex key={size} gap="100">
53
+ {solidColorSchemes.map(colorScheme => (
54
+ <Button
55
+ disabled
56
+ key={colorScheme}
57
+ variant="solid"
58
+ colorScheme={colorScheme}
59
+ size={size}
60
+ >
61
+ Button
62
+ </Button>
63
+ ))}
64
+ </Flex>
65
+ ))}
66
+ </Flex>
67
+ <Flex gap="400" alignItems="center">
68
+ {sizes.map(size => (
69
+ <Flex key={size} gap="100">
70
+ {solidColorSchemes.map(colorScheme => (
71
+ <Button loading key={colorScheme} variant="solid" colorScheme={colorScheme} size={size}>
72
+ Button
73
+ </Button>
74
+ ))}
75
+ </Flex>
76
+ ))}
77
+ </Flex>
78
+ </Flex>
79
+ {(['outline', 'ghost'] as const).map(variant => (
80
+ <Flex key={variant} gap="200" direction="column">
81
+ <Heading style={{ textTransform: 'capitalize' }}>{variant}</Heading>
82
+ <Flex gap="400" alignItems="center">
83
+ {sizes.map(size => (
84
+ <Flex key={size} gap="100">
85
+ {otherColorSchemes.map(colorScheme => (
86
+ <Button key={colorScheme} variant={variant} colorScheme={colorScheme} size={size}>
87
+ Button
88
+ </Button>
89
+ ))}
90
+ </Flex>
91
+ ))}
92
+ </Flex>
93
+ <Flex gap="400" alignItems="center">
94
+ {sizes.map(size => (
95
+ <Flex key={size} gap="100">
96
+ {otherColorSchemes.map(colorScheme => (
97
+ <Button
98
+ disabled
99
+ key={colorScheme}
100
+ variant={variant}
101
+ colorScheme={colorScheme}
102
+ size={size}
103
+ >
104
+ Button
105
+ </Button>
106
+ ))}
107
+ </Flex>
108
+ ))}
109
+ </Flex>
110
+ <Flex gap="400" alignItems="center">
111
+ {sizes.map(size => (
112
+ <Flex key={size} gap="100">
113
+ {otherColorSchemes.map(colorScheme => (
114
+ <Button
115
+ loading
116
+ key={colorScheme}
117
+ variant={variant}
118
+ colorScheme={colorScheme}
119
+ size={size}
120
+ >
121
+ Button
122
+ </Button>
123
+ ))}
124
+ </Flex>
125
+ ))}
126
+ </Flex>
127
+ </Flex>
128
+ ))}
129
+ </Flex>
130
+ ```
131
+
132
+ - [Accessibility](#accessibility)
133
+ - [Disabled buttons](#disabled-buttons)
134
+ - [Variants](#variants)
135
+ - [Colour schemes](#colour-schemes)
136
+ - [Inverted](#inverted)
137
+ - [Size](#size)
138
+ - [Dead prop combinations](#dead-prop-combinations)
139
+ - [With icons](#with-icons)
140
+ - [Semantic HTML](#semantic-html)
141
+ - [Full width button](#full-width-button)
142
+ - [Padding none](#padding-none)
143
+ - [Usage with Next.js](#usage-with-next.js)
144
+ - [API](#api)
145
+
146
+ ```tsx
147
+ <Button variant="solid" colorScheme="highlight">
148
+ Button
149
+ </Button>
150
+ ```
151
+
152
+ ## Accessibility
153
+
154
+ Uses a native `<button>` element under the hood, with support for the <kbd>Space</kbd> and <kbd>Enter</kbd> keys.
155
+
156
+ ### Disabled buttons
157
+
158
+ Disabled buttons use `aria-disabled`, rather than `disabled`, so that they are
159
+ still focusable when using the keyboard. This means that screen readers are
160
+ still able to find the button, with the insight that it is disabled and that
161
+ there is perhaps an action which needs to be taken, rather than not knowing
162
+ there is a button there at all. The `onClick` handler will be disabled, however
163
+ you will need to make sure you disable any other expected actions, including
164
+ when using `type="submit"`.
165
+
166
+ ## Variants
167
+
168
+ The variant prop controls the visual appearance of the Button.
169
+
170
+ ```tsx
171
+ <Flex gap={2} alignItems="center">
172
+ <Button variant="emphasis">Button</Button>
173
+ <Button variant="solid">Button</Button>
174
+ <Button variant="outline">Button</Button>
175
+ <Button variant="ghost">Button</Button>
176
+ </Flex>
177
+ ```
178
+
179
+ - The Emphasis variant of the Button is used for high emphasis actions where there will be no compromise to functionality.
180
+ - Solid Buttons are typically used for actions that require high emphasis and are considered primary actions.
181
+ - Outline Buttons typically have a medium level of emphasis. They are best suited for non-critical actions.
182
+ - Ghost buttons are designed to have a lower prominence compared to other button variants. This makes them suitable for actions that are not as important and also allows them to be used as building blocks for other components.
183
+
184
+ ```tsx
185
+ <Flex direction="column" gap="200" alignItems="start">
186
+ <Button variant="emphasis">Emphasis Button</Button>
187
+
188
+ <Flex gap="100">
189
+ {solidColorSchemes.map(colorScheme => (
190
+ <Button key={colorScheme} variant="solid" colorScheme={colorScheme}>
191
+ Solid Button
192
+ </Button>
193
+ ))}
194
+ </Flex>
195
+
196
+ <Flex gap="100">
197
+ {otherColorSchemes.map(colorScheme => (
198
+ <Button key={colorScheme} variant="outline" colorScheme={colorScheme}>
199
+ Outline Button
200
+ </Button>
201
+ ))}
202
+ </Flex>
203
+ <Flex gap="100">
204
+ {otherColorSchemes.map(colorScheme => (
205
+ <Button key={colorScheme} variant="ghost" colorScheme={colorScheme}>
206
+ Ghost Button
207
+ </Button>
208
+ ))}
209
+ </Flex>
210
+ </Flex>
211
+ ```
212
+
213
+ ## Colour schemes
214
+
215
+ The `colorScheme` prop will change the button colours.
216
+
217
+ ```tsx
218
+ <Button colorScheme="highlight">
219
+ ```
220
+
221
+ ### Highlight
222
+
223
+ The Highlight colour scheme serves as the default color scheme for primary actions,
224
+ therefore is only available for Emphasis and Solid Buttons variants.
225
+
226
+ ```tsx
227
+ <Flex gap="400">
228
+ <Button variant="emphasis" colorScheme="highlight">
229
+ Emphasis
230
+ </Button>
231
+ <Button variant="solid" colorScheme="highlight">
232
+ Solid
233
+ </Button>
234
+ </Flex>
235
+ ```
236
+
237
+ ### Functional
238
+
239
+ The Functional colour scheme is best suited for situations that have lower prominence,
240
+ which is why it is only available for Outline and Ghost Button variants.
241
+
242
+ ```tsx
243
+ <Flex gap="400">
244
+ <Button variant="outline" colorScheme="functional">
245
+ Outline
246
+ </Button>
247
+ <Button variant="ghost" colorScheme="functional">
248
+ Ghost
249
+ </Button>
250
+ </Flex>
251
+ ```
252
+
253
+ ### Destructive
254
+
255
+ The Destructive colour scheme is suitable for destructive actions that are irreversible,
256
+ or will have significant and negative consequences for the user.
257
+
258
+ ```tsx
259
+ <Flex gap="400">
260
+ <Button variant="solid" colorScheme="destructive">
261
+ Solid
262
+ </Button>
263
+ <Button variant="outline" colorScheme="destructive">
264
+ Outline
265
+ </Button>
266
+ <Button variant="ghost" colorScheme="destructive">
267
+ Ghost
268
+ </Button>
269
+ </Flex>
270
+ ```
271
+
272
+ ### Affirmative
273
+
274
+ The Affirmative colour scheme is ideal for indicating positive or affirmative
275
+ actions.
276
+
277
+ ```tsx
278
+ <Flex gap="400">
279
+ <Button variant="solid" colorScheme="affirmative">
280
+ Solid
281
+ </Button>
282
+ <Button variant="outline" colorScheme="affirmative">
283
+ Outline
284
+ </Button>
285
+ <Button variant="ghost" colorScheme="affirmative">
286
+ Ghost
287
+ </Button>
288
+ </Flex>
289
+ ```
290
+
291
+ ## Inverted
292
+
293
+ The `inverted` prop should be used when using a `Button` on darker surface
294
+ colours, specifically the UW Purple and Dark Purple colours. It only affects
295
+ the following buttons:

296
+
297
+ - Emphasis/Highlight
298
+ - Solid/Highlight
299
+ - Outline/Functional
300
+ - Ghost/Functional
301
+
302
+ **It is very important to remember to use the `inverted` prop when using the
303
+ Emphasis button on darker backgrounds. While the button itself doesn't change
304
+ colours, the focus ring colour does change, and omitting the `inverted` prop
305
+ will indermine the accessibility of the button.**
306
+
307
+ ```tsx
308
+ <Flex gap="400" backgroundColor="brand" padding="400">
309
+ <Button variant="emphasis" inverted>
310
+ Emphasis
311
+ </Button>
312
+ <Button variant="solid" colorScheme="highlight" inverted>
313
+ Solid
314
+ </Button>
315
+ <Button variant="outline" colorScheme="functional" inverted>
316
+ Outline
317
+ </Button>
318
+ <Button variant="ghost" colorScheme="functional" inverted>
319
+ Ghost
320
+ </Button>
321
+ </Flex>
322
+ ```
323
+
324
+ ## Size
325
+
326
+ The size prop controls the size of the `Button`. This is a responsive prop and
327
+ can be used to display different sizes at different breakpoints.
328
+
329
+ ```tsx
330
+ <Button
331
+ size={{
332
+ mobile: 'md',
333
+ tablet: 'sm',
334
+ desktop: 'md',
335
+ wide: 'sm',
336
+ }}
337
+ />
338
+ ```
339
+
340
+ ```tsx
341
+ <Flex gap="400" direction="column">
342
+ <Flex gap="400">
343
+ <Button variant="emphasis" size="md">
344
+ Emphasis
345
+ </Button>
346
+ <Button variant="solid" size="md">
347
+ Solid
348
+ </Button>
349
+ <Button variant="outline" size="md">
350
+ Outline
351
+ </Button>
352
+ <Button variant="ghost" size="md">
353
+ Ghost
354
+ </Button>
355
+ </Flex>
356
+ <Flex gap="400">
357
+ <Button variant="emphasis" size="sm">
358
+ Emphasis
359
+ </Button>
360
+ <Button variant="solid" size="sm">
361
+ Solid
362
+ </Button>
363
+ <Button variant="outline" size="sm">
364
+ Outline
365
+ </Button>
366
+ <Button variant="ghost" size="sm">
367
+ Ghost
368
+ </Button>
369
+ </Flex>
370
+ </Flex>
371
+ ```
372
+
373
+ ## Dead prop combinations
374
+
375
+ Be aware there are some combinations of `colorScheme` & `variant` that do not work together (ie. `emphasis` &
376
+ `functional`), and if used will render a button with no colours at all.
377
+
378
+ ```tsx
379
+ <Button variant="emphasis" colorScheme="grey">
380
+ Invalid Button
381
+ </Button>
382
+ ```
383
+
384
+ You will also see a TypeScript error:
385
+
386
+ ```console
387
+ Type '{ children: string; variant: "emphasis"; colorScheme: "functional"; }' is not
388
+ assignable to type 'IntrinsicAttributes & (ButtonProps &
389
+ RefAttributes<HTMLButtonElement>)'.
390
+ Types of property 'colorScheme' are incompatible.
391
+ Type '"functional"' is not assignable to type '"highlight"'. (tsserver 2322)
392
+ ```
393
+
394
+ ## With icons
395
+
396
+ You can nest icons directly inside the `Button`. An appropriate gap is provided
397
+ automatically, and the icon will inherit the appropriate colours.
398
+
399
+ ```tsx
400
+ <Button variant="solid" size="md">
401
+ Continue
402
+ <ChevronRight01SmallIcon />
403
+ </Button>
404
+ ```
405
+
406
+ ```tsx
407
+ <Flex gap="200">
408
+ <Button {...args} variant="solid" colorScheme="destructive">
409
+ <TrashSmallIcon />
410
+ Delete
411
+ </Button>
412
+ <Button {...args} variant="solid" colorScheme="highlight">
413
+ Account
414
+ <UserSmallIcon />
415
+ </Button>
416
+ <Button {...args} variant="outline" colorScheme="functional">
417
+ <SettingsSmallIcon />
418
+ Settings
419
+ </Button>
420
+ </Flex>
421
+ ```
422
+
423
+ Icons from the Hearth Icons packages have `aria-hidden="true"` set by default. If
424
+ you are using an icon from outside these packages, and for purely decorative
425
+ reasons, please ensure it has this attribute set so that the icon is hidden
426
+ from screen readers.
427
+
428
+ Please also add the `data-icon` attribute to your icon so that it renders the
429
+ appropriate styles.
430
+
431
+ ```tsx
432
+ <Button>
433
+ <MyFontIcon aria-hidden="true" data-icon />
434
+ Edit account
435
+ </Button>
436
+ ```
437
+
438
+ ## Semantic HTML
439
+
440
+ > If it goes somewhere it's a link, if it does something it's a button.
441
+
442
+ A semantic HTML `button` is rendered by default, however you can change the
443
+ underlying HTML element by using the `asChild` prop.
444
+
445
+ **NOTE:** Be aware that you cannot currently use `asChild` with the `emphasis` variant.
446
+
447
+ When `asChild` is set to true, we will not render a default DOM element,
448
+ instead cloning the child and passing it the props and behaviour required to
449
+ make it functional.
450
+
451
+ Read more about this idea in the [Radix UI composition docs](https://www.radix-ui.com/primitives/docs/guides/composition).
452
+
453
+ ```tsx
454
+ <Flex gap="200">
455
+ <Button asChild>
456
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
457
+ <a href={args.disabled ? undefined : 'https://uw.co.uk/services'}>View UW services</a>
458
+ </Button>
459
+ <Button asChild loading>
460
+ {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
461
+ <a href={args.disabled ? undefined : 'https://uw.co.uk/services'}>View UW services</a>
462
+ </Button>
463
+ </Flex>
464
+ ```
465
+
466
+ ```tsx
467
+ <Button asChild>
468
+ <a href="https://uw.co.uk/services">View UW services</a>
469
+ </Button>
470
+ ```
471
+
472
+ ## Full width button
473
+
474
+ Use layout components, like `Flex`, to define your UI layouts, which can also be responsive.
475
+
476
+ ```tsx
477
+ <Flex direction="column" gap="200">
478
+ <Flex direction="column" gap="100">
479
+ <Button>
480
+ Full width button with icon
481
+ <ChevronRightSmallIcon />
482
+ </Button>
483
+ <Button variant="emphasis">Full width emphasis button</Button>
484
+ </Flex>
485
+ <Flex direction="column" alignItems={{ mobile: 'stretch', desktop: 'start' }}>
486
+ <Button>Responsive full width button</Button>
487
+ </Flex>
488
+ </Flex>
489
+ ```
490
+
491
+ ```tsx
492
+ <Flex direction="column">
493
+ <Button>Full width button</Button>
494
+ </Flex>
495
+
496
+ <Flex direction="column" alignItems={{ mobile: 'stretch', desktop: 'start' }}>
497
+ <Button>Responsive full width button</Button>
498
+ </Flex>
499
+ ```
500
+
501
+ ## Padding none
502
+
503
+ If you need to better align a button with another element you can use the
504
+ `paddingNone` prop to remove the horizontal padding. This only affects the
505
+ `ghost` variant button.
506
+
507
+ ```tsx
508
+ <Flex direction="column" alignItems="start" gap="100" padding="200">
509
+ <TextInput label="Postcode" required />
510
+ <Button variant="ghost" colorScheme="functional" size="sm" paddingNone>
511
+ Add address manually
512
+ </Button>
513
+ </Flex>
514
+ ```
515
+
516
+ ### Next.js v13
517
+
518
+ The Next.js `Link` component behaviour has changed in v13, so that an `<a>` is
519
+ no longer required as a child. You can render the Hearth React `Button` component as a
520
+ Next.js `Link` component using `asChild`:
521
+
522
+ ```tsx
523
+ import NextLink from 'next/link';
524
+ import { Button } from '@utilitywarehouse/hearth-react';
525
+
526
+ [...]
527
+
528
+ <Button asChild onClick={onClick}>
529
+ <NextLink href={href}>{title}</NextLink>
530
+ </Button>
531
+ ```
532
+
533
+ You can also use the `legacyBehavior` prop directly on the Next.js Link component:
534
+
535
+ ```tsx
536
+ import NextLink from 'next/link';
537
+ import { Button } from '@utilitywarehouse/hearth-react';
538
+
539
+ [...]
540
+
541
+ <NextLink href={href} passHref legacyBehavior>
542
+ <Button {...props} asChild onClick={onClick}>
543
+ <a href={href as string}>{title}</a>
544
+ </Button>
545
+ </NextLink>
546
+ ```
547
+
548
+ And if you want to set this behavior globally you can use the following Next.js
549
+ configuration:
550
+
551
+ ```
552
+ {
553
+ experimental: {
554
+ newNextLinkBehavior: false
555
+ }
556
+ }
557
+ ```
558
+
559
+ ### Next.js before v13
560
+
561
+ ```tsx
562
+ import NextLink from 'next/link';
563
+ import { Button } from '@utilitywarehouse/hearth-react';
564
+
565
+ [...]
566
+
567
+ <NextLink href={href} passHref>
568
+ <Button {...props} asChild onClick={onClick}>
569
+ <a href={href as string}>{title}</a>
570
+ </Button>
571
+ </NextLink>
572
+ ```
573
+
574
+ ## API
575
+
576
+ This component is based on the `button` element and supports the following common props:
577
+
578
+ - Margin
579
+
580
+ | Prop | Type | Default | Description |
581
+ | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
582
+ | `margin` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
583
+ | `marginTop` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
584
+ | `marginRight` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
585
+ | `marginBottom` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
586
+ | `marginLeft` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
587
+ | `marginX` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
588
+ | `marginY` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
589
+ | `variant` | `"emphasis" \| "solid" \| "outline" \| "ghost"` | — | Sets the button's visual variant |
590
+ | `colorScheme` | `"highlight" \| "affirmative" \| "destructive" \| "functional"` | — | Sets the button's colour scheme |
591
+ | `asChild` | `boolean` | — | Change the default rendered element for the one passed as a child, merging their props and behavior. |
592
+ | `loading` | `boolean` | — | Indicate when the button is in a loading state, will also disable the button. |
593
+ | `inverted` | `boolean` | — | Inverts the component colours, for use on darker surface colours. |
594
+ | `size` | `Responsive<"sm" \| "md">` | `md` | Sets the button height. |
595
+ | `paddingNone` | `boolean` | — | Remove the inline padding for better alignment with other elements. Only affects the `ghost` variant. |