Button

Buttons prompt most actions in a UI.

Usage

Button triggers an action or navigates to a destination. Import Button from @udixio/ui-react, @udixio/ui-angular or @udixio/ui-svelte. Provide visible text with React children, Angular projected content, a Svelte children snippet, or the shared label property. React accepts exactly one of label and children, which keeps the visible and accessible labels from contradicting each other.

Action buttons render a native <button> and default to type="button". Providing href renders a native <a> instead.

Variants

The canonical variants are filled, elevated, tonal, outlined, and text. The compatibility aliases primary and secondary resolve to filled and tonal.

Toggle buttons

toggleable enables toggle-button semantics. pressed is the controlled value; defaultPressed is captured once for uncontrolled usage. React emits onPressedChange, Angular emits pressedChange, and Svelte exposes bind:pressed next to onPressedChange — reject a change with a function binding whose setter decides. onClick, (click) and onclick remain independent action events.

The visible label stays stable while aria-pressed communicates the state. Navigation links ignore toggle state; mark the current destination with aria-current instead.

Sizes

Sizes range from xSmall to xLarge. Every size includes a 48px pointer target, including compact visual treatments.

States and shapes

disabled and loading block actions and pressed-state changes. Loading also sets aria-busy while keeping the label available as the accessible name. shape selects the rounded or squared resting shape.

By default, the shared Motion controller transforms the button shape on press. Set shapeFeedback="none" in any framework to keep a static shape, or pass a Motion transition to customize the morph feedback. Reduced-motion preferences keep the feedback but remove the movement.

Text buttons keep their full layout box by default. Set edgeAligned / [edgeAligned]="true" when the button should align to the surrounding inline edge with negative inline margins.

Icons

iconPosition uses the logical values start and end, so placement follows the page direction in RTL layouts. The historical left and right aliases remain supported. Button icons are decorative; the text label names the action.

React forwards native button or anchor attributes. Angular exposes the common link attributes target, rel, tabIndex, aria-label, aria-describedby, and aria-current on the inner interactive element. Svelte spreads the attributes a button and a link share onto the root element, plus target and rel. A disabled or loading link has no href, receives aria-disabled="true", and leaves the tab order.

No action yet

Accessibility

Button relies on native button and link keyboard behavior. Toggle buttons expose aria-pressed; loading buttons expose aria-busy; and keyboard focus receives a visible two-pixel outline. Always provide a concise accessible name. When custom visual content has no accessible text, provide aria-label in every framework. Never provide a label that contradicts visible text.

Migration to the next major

Button’s stable contract intentionally has no compatibility aliases. Update consumers before adopting the next major release:

Previous APIStable API
disableTextMarginsedgeAligned with inverted polarity
allowShapeTransformation={false}shapeFeedback="none"
activatedpressed or defaultPressed
onToggletoggleable plus onPressedChange / pressedChange
React label together with childrenChoose one; add aria-label for non-text children

edgeAligned defaults to false and shapeFeedback to morph. Toggle state now follows the controlled and uncontrolled contract described above, and action events remain independent.