Button
Render actions and links with loading, icons, and semantic roots.
Use Button for actions and explicit navigation. Choose the underlying element with as according to the action: a button for commands and an anchor for destinations.
Basic usage#
Playground#
Anatomy#
Usage#
Loading#
Use loading when application state owns the pending operation. loadingAuto is opt-in: when enabled, a promise returned by onClick drives the visual loading state. Loading suppresses additional activation without applying native disabled, so a focused button keeps its keyboard position. Explicit disabled still uses native disabled semantics where available.
Icons and polymorphism#
Leading and trailing content can be icons or custom elements. Icon-only buttons need aria-label or another accessible name. Polymorphic roots without native link semantics receive button role and keyboard activation; anchors with href keep native link behavior. When a custom component forwards its root ref, Moraine resolves native button semantics from the rendered DOM element.
Examples#
Icon action with a hint#
Attributes#
data-disabledSlot: buttonDescription: Present when the component, slot, or item is disabled.data-loadingSlot: buttonDescription: Present when the component or async operation is loading.Props#
Props for the Button component. Renders a <button> element by default.