# button-has-type

Rule `react/button-has-type`. Disallow usage of `button` elements without an explicit `type` attribute

- Source: react
- Technologies: React
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 33.9M weekly downloads of presets that enable it
- Trend: +89.5% last quarter
- Rank: #458 by reach, #296 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react/button-has-type` | no | no | package `eslint-plugin-react` | [docs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/button-has-type.md) |
| Oxlint | `react/button-has-type` | no | no | plugin `react`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/react/button-has-type.html) |
| Biome | `a11y/useButtonType` | yes | no | group a11y, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/use-button-type/) |

## Code examples

### Incorrect: the rule reports this

```jsx
var Hello = <button>Hello</button>
var Hello = <button type="foo">Hello</button>
var Hello = <button type={foo}>Hello</button>

var Hello = React.createElement('button', {}, 'Hello')
var Hello = React.createElement('button', {type: 'foo'}, 'Hello')
```

### Correct: the rule accepts this

```jsx
var Hello = <span>Hello</span>
var Hello = <span type="foo">Hello</span>
var Hello = <button type="button">Hello</button>
var Hello = <button type="submit">Hello</button>
var Hello = <button type="reset">Hello</button>
var Hello = <button type={condition ? "button" : "submit"}>Hello</button>

var Hello = React.createElement('span', {}, 'Hello')
var Hello = React.createElement('span', {type: 'foo'}, 'Hello')
var Hello = React.createElement('button', {type: 'button'}, 'Hello')
var Hello = React.createElement('button', {type: 'submit'}, 'Hello')
var Hello = React.createElement('button', {type: 'reset'}, 'Hello')
var Hello = React.createElement('button', {type: condition ? 'button' : 'submit'}, 'Hello')
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import react from "eslint-plugin-react";

export default [
  {
    plugins: { react },
    rules: {
      "react/button-has-type": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "react"
  ],
  "rules": {
    "react/button-has-type": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "a11y": {
        "useButtonType": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |

## Related rules

- [react/void-dom-elements-no-children](https://lintradar.dev/rules/react/void-dom-elements-no-children.md): Disallow void DOM elements (e.g. `<img />`, `<br />`) from receiving children
- [react/no-array-index-key](https://lintradar.dev/rules/react/no-array-index-key.md): Disallow usage of Array index in keys
- [react/jsx-no-useless-fragment](https://lintradar.dev/rules/react/jsx-no-useless-fragment.md): Disallow unnecessary fragments
- [react/no-danger](https://lintradar.dev/rules/react/no-danger.md): Disallow usage of dangerous JSX properties
- [react/no-object-type-as-default-prop](https://lintradar.dev/rules/react/no-object-type-as-default-prop.md): Disallow usage of referential-type variables as default param in functional component
- [react/prop-types](https://lintradar.dev/rules/react/prop-types.md): Disallow missing props validation in a React component definition

---

Web page: https://lintradar.dev/rules/react/button-has-type. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
