Create

General

Button

Copy page View as Markdown Open in ChatGPT Open in Claude

Displays a button or a link that looks like a button.

Usage#

app.component.ts
import { WdsButtonComponent } from '@wds/angular/button';

Examples#

Size#

Button xs Button sm Button Button lg

Variants#

Default Outline Secondary Ghost Destructive Link

Disabled#

Disabled Disabled

Icon#

An icon-only button needs a label: it becomes its accessible name.

With icon#

New branch

Rounded#

Rounded Square

Loading#

Sending

Spinner#

Loading state after a click. This example has logic, so each framework has its own code.

Save

Z href przycisk renderuje natywny <a>.

Open documentation Link as button

API References#

wds-button#

Button. Renders a native <button>, or with href a native <a> that looks like a button. aria-expanded, aria-haspopup, aria-pressed, aria-current, aria-keyshortcuts, aria-description and aria-label on the host are forwarded to the native element.

Attributes

AttributeTypeDefaultDescription
variantWdsButtonVariant'default'Visual variant.
sizeWdsButtonSize'default'Size. icon* is a square, icon-only button (set label then).
shapeWdsButtonShape'default'Shape: default (radius md), circle or square.
typeWdsButtonType'button'
disabledbooleanfalseDisables the button; clicks do not reach click listeners, as with a native disabled button.
loadingbooleanfalseLoading state: spinner before the content, button inactive, aria-busy.
labelstring | undefinedAccessible label (aria-label), required for icon* sizes.
hrefstring | undefinedURL: the button renders as a link.
targetstring | undefined

Slots

SlotDescription
(default)Button content (text, <svg> icon).

CSS parts (::part)

PartDescription
buttonThe native <button> or <a>.

Accessibility#

Screen reader#

wds-button renders a native <button>, or with href a native <a>, so it has the matching role and behavior.

The content is the accessible name. An icon-only button (size="icon*") needs a label: it becomes the aria-label.

disabled disables the native button; a disabled link loses its href and gets role="link" and aria-disabled="true". loading sets aria-busy="true" and makes the button inactive.

aria-expanded, aria-haspopup, aria-pressed, aria-current and aria-label set on wds-button are forwarded to the native element.

Keyboard support#

KeyFunction
TabMoves focus to the button.
EnterActivates the button or follows the link.
SpaceActivates the button (links are activated only with Enter).
Footer