Skip to content

Commit 73c1439

Browse files
authored
fix: add anchor element attribute types to Button (#18598)
* fix: add anchor element attribute types to Button * fix: update public api
1 parent 9d0c15e commit 73c1439

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ Map {
439439
"onMouseLeave": Object {
440440
"type": "func",
441441
},
442+
"rel": Object {
443+
"type": "string",
444+
},
442445
"renderIcon": Object {
443446
"args": Array [
444447
Array [
@@ -470,6 +473,9 @@ Map {
470473
"tabIndex": Object {
471474
"type": "number",
472475
},
476+
"target": Object {
477+
"type": "string",
478+
},
473479
"tooltipAlignment": Object {
474480
"args": Array [
475481
Array [

packages/react/src/components/Button/Button.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export interface ButtonBaseProps
5757
/**
5858
* Optionally specify an href for your Button to become an `<a>` element
5959
*/
60-
href?: string;
60+
href?: React.AnchorHTMLAttributes<HTMLAnchorElement>['href'];
6161

6262
/**
6363
* If specifying the `renderIcon` prop, provide a description for that icon that can
@@ -82,6 +82,11 @@ export interface ButtonBaseProps
8282
? IconButtonKind
8383
: ButtonKind;
8484

85+
/**
86+
* Optionally specify a `rel` when using an `<a>` element.
87+
*/
88+
rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
89+
8590
/**
8691
* Optional prop to allow overriding the icon rendering.
8792
* Can be a React component class
@@ -93,6 +98,11 @@ export interface ButtonBaseProps
9398
*/
9499
size?: ButtonSize;
95100

101+
/**
102+
* Optionally specify a `target` when using an `<a>` element.
103+
*/
104+
target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
105+
96106
/**
97107
* Specify the alignment of the tooltip to the icon-only button.
98108
* Can be one of: start, center, or end.
@@ -328,6 +338,11 @@ const Button: ButtonComponent = React.forwardRef(
328338
*/
329339
onMouseLeave: PropTypes.func,
330340

341+
/**
342+
* Optionally specify a `rel` when using an `<a>` element.
343+
*/
344+
rel: PropTypes.string,
345+
331346
/**
332347
* Optional prop to allow overriding the icon rendering.
333348
* Can be a React component class
@@ -349,6 +364,11 @@ const Button: ButtonComponent = React.forwardRef(
349364
*/
350365
tabIndex: PropTypes.number,
351366

367+
/**
368+
* Optionally specify a `target` when using an `<a>` element.
369+
*/
370+
target: PropTypes.string,
371+
352372
/**
353373
* Specify the alignment of the tooltip to the icon-only button.
354374
* Can be one of: start, center, or end.

0 commit comments

Comments
 (0)