Skip to content

Commit 3c06809

Browse files
committed
Document button type attr
1 parent ceb6c4b commit 3c06809

6 files changed

Lines changed: 14 additions & 5 deletions

File tree

docs/pages/material-ui/api/button-base.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"name": "union",
2727
"description": "func<br>&#124;&nbsp;{ current?: { pulsate: func, start: func, stop: func } }"
2828
}
29-
}
29+
},
30+
"type": { "type": { "name": "string" }, "default": "'button'" }
3031
},
3132
"name": "ButtonBase",
3233
"imports": [

docs/translations/api-docs/button-base/button-base.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"TouchRippleProps": { "description": "Props applied to the <code>TouchRipple</code> element." },
4242
"touchRippleRef": {
4343
"description": "A ref that points to the <code>TouchRipple</code> element."
44+
},
45+
"type": {
46+
"description": "The <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type\">type</a> attribute applied to the <code>button</code> element."
4447
}
4548
},
4649
"classDescriptions": {

packages/mui-material/src/Button/Button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ Button.propTypes /* remove-proptypes */ = {
723723
/**
724724
* @ignore
725725
*/
726-
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string]),
726+
type: PropTypes.string,
727727
/**
728728
* The variant to use.
729729
* @default 'text'

packages/mui-material/src/ButtonBase/ButtonBase.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ export interface ButtonBaseOwnProps {
9090
* A ref that points to the `TouchRipple` element.
9191
*/
9292
touchRippleRef?: React.Ref<TouchRippleActions> | undefined;
93+
/**
94+
* The [type](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type) attribute applied to the `button` element.
95+
* @default 'button'
96+
*/
97+
type?: string | undefined;
9398
}
9499

95100
export interface ButtonBaseTypeMap<

packages/mui-material/src/ButtonBase/ButtonBase.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,10 @@ ButtonBase.propTypes /* remove-proptypes */ = {
486486
}),
487487
]),
488488
/**
489-
* @ignore
489+
* The [type](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type) attribute applied to the `button` element.
490+
* @default 'button'
490491
*/
491-
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string]),
492+
type: PropTypes.string,
492493
};
493494

494495
export default ButtonBase;

packages/mui-material/src/ButtonBase/ButtonBase.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,6 @@ describe('<ButtonBase />', () => {
15001500
});
15011501

15021502
it('allows non-standard values', () => {
1503-
// @ts-expect-error `@types/react` only lists standard values
15041503
render(<ButtonBase type="fictional-type" />);
15051504

15061505
expect(screen.getByRole('button')).to.have.attribute('type', 'fictional-type');

0 commit comments

Comments
 (0)