Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/src/button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ An accessible description for the button.

#### `disabled`: `boolean`

Whether the button is disabled. If `true`, this will force a `button` element to be rendered.
Whether the button is disabled. If `true`, this will force a `button` element to be rendered, even when an `href` is given.

- Required: No

Expand Down
10 changes: 7 additions & 3 deletions packages/components/src/button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,27 @@ type BaseButtonProps = {
*/
variant?: 'primary' | 'secondary' | 'tertiary' | 'link';
/**
* Whether this is focusable.
* Whether to keep the button focusable when disabled.
*
* @default false
*/
__experimentalIsFocusable?: boolean;
};

type _ButtonProps = {
/**
* Whether the button is disabled.
* If `true`, this will force a `button` element to be rendered.
*
* If `true`, this will force a `button` element to be rendered, even when an `href` is given.
*/
disabled?: boolean;
};

type AnchorProps = {
/**
* Whether the button is disabled.
* If `true`, this will force a `button` element to be rendered.
*
* If `true`, this will force a `button` element to be rendered, even when an `href` is given.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this even be true, given that the type is false? Feels like this entire line is redundant here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. In theory, yes it seems a bit wrong. In reality, the props types/descriptions for the <a> case and the <button> case are union-ed into a polymorphic type, and in most scenarios where this description can be shown to a developer I think this extra clarification is always relevant. For example, in the Storybook props table, or in IntelliSense (including parts of a codebase that are not type checked).

Basically even in an instance like <Button href="foo" disabled={ false }>, it's still useful to know that flipping the disabled to true would force the Button into a <button> element.

*/
disabled?: false;
/**
Expand Down