Skip to content
Draft
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
5 changes: 5 additions & 0 deletions packages/react/src/use-button/useButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from 'react';
import { isHTMLElement } from '@floating-ui/utils/dom';
import { useStableCallback } from '@base-ui-components/utils/useStableCallback';
import { error } from '@base-ui-components/utils/error';
import { warn } from '@base-ui-components/utils/warn';
import { useIsoLayoutEffect } from '@base-ui-components/utils/useIsoLayoutEffect';
import { makeEventPreventable, mergeProps } from '../merge-props';
import { useCompositeRootContext } from '../composite/root/CompositeRootContext';
Expand Down Expand Up @@ -53,6 +54,10 @@ export function useButton(parameters: useButton.Parameters = {}): useButton.Retu
error(
'A component that acts as a button was rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is not a real <button>, or set the `nativeButton` prop on the component to `true`.',
);
} else if (elementRef.current.tagName === 'A') {
warn(
Copy link
Member

Choose a reason for hiding this comment

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

WDYT, would error work here as well? 🤔

'A component that acts as a button was rendered as an <a> tag, which could cause usability issues for keyboard and assistive tech users. Prefer using `<a>` directly.',
);
}
}, [isNativeButton]);
}
Expand Down
22 changes: 11 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading