Skip to content

Button

Button renders a native button whose only state attribute is data-disabled. Its one mechanism beyond the native element is FocusableWhenDisabled: instead of setting the native disabled attribute (which drops the element out of the tab order), it sets aria-disabled="true" and suppresses activation, so focus and tab position survive a button that becomes disabled mid-interaction. NativeButton exists for Base UI parity; rendering as a non-button element is the Slot path, not a prop.

@using Navius.Primitives.Components.Button
<NaviusButton>
Submit
</NaviusButton>

Renders a button.

Prop Type Default Description
Type string "button" The native type attribute ("button", "submit", "reset").
Disabled bool false Disables the button. Sets the native disabled attribute unless FocusableWhenDisabled is set.
FocusableWhenDisabled bool false Keeps the button focusable while disabled: renders aria-disabled="true" instead of disabled, and suppresses activation.
NativeButton bool true Base UI parity flag. Non-native (role="button") rendering is the Slot path in Blazor.
OnClick EventCallback<MouseEventArgs> - Fires on activation. Not invoked while Disabled, including when focusable-while-disabled.
ChildContent RenderFragment? - Button content.
Attributes IDictionary<string, object>? - Forwarded to the rendered button.
Part Attribute Description
Root data-disabled Present when Disabled, whether or not the button is focusable while disabled.
Key Behavior
Space Activates the button, invoking OnClick.
Enter Activates the button, invoking OnClick.

Implements the button WAI-ARIA APG pattern on a native button, so the role, name and keyboard activation come from the element itself. When Disabled and FocusableWhenDisabled, it renders aria-disabled="true" rather than the native disabled attribute and cancels the click (with preventDefault), so the button keeps its accessible name and tab position while refusing activation. This mechanism is covered by the Playwright browser test suite and gated by axe-core in CI.