[react] Add commandFor and command attributes to ButtonHTMLAttributes
Author: tirtza-weinfeldCreated Mar 10, 2026Updated Sep 16, 2026
Summary
The Invoker Commands API adds commandfor and command attributes to <button>. These are missing from ButtonHTMLAttributes in @types/react.
HTML spec
- whatwg/html PR: https://github.com/whatwg/html/pull/9841
- MDN: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/commandForElement
Browser support
- Chrome/Edge 135+
- Safari Technology Preview
- Firefox Nightly (behind flag)
Expected types
interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
commandFor?: string | undefined
command?: string | undefined
}command accepts built-in values (toggle-popover, show-popover, hide-popover, show-modal, close, request-close) and custom strings (prefixed with --).
Current workaround
Projects augment the module locally:
import 'react'
declare module 'react' {
interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
commandFor?: string
command?: string
}
}React already ships popoverTarget and popoverTargetAction on button — commandFor/command is the successor API from the same spec space.
Source: DefinitelyTyped/DefinitelyTyped