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#

size sets the height, padding and icon size: xs (24px), sm (28px), default (32px) and lg (36px). Icon-only buttons use the same sizes.

Button xs Button sm Button Button lg

Variants#

Default Outline Secondary Ghost Destructive Link

Disabled#

Disabled Disabled

Icon#

icon makes a square, icon-only button of the given size; the button sets the icon size too. An icon-only button needs a label: it becomes its accessible name. Your own <svg> or <wds-icon> as the only content gives the same square.

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. icon-start and icon-end add a registered icon before or after the text (e.g. icon-start="lucide-plus"). icon makes a square, icon-only button in any size (set label then); content made only of <svg> or <wds-icon> elements does the same. An icon-only button matches wds-button:state(icon-only) in CSS.

Attributes

AttributeTypeDefaultDescription
variantWdsButtonVariant'default'Visual variant.
sizeWdsButtonSize'default'Height, padding and icon size: xs (24px), sm (28px), default (32px) or lg (36px).
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 an icon-only button.
iconstring | undefinedIcon-only button: the name of a registered icon, e.g. lucide-x (after import '@wds/core/icons/lucide/x'). The button becomes a square of its size; set label. While loading the spinner takes its place.
icon-start.iconStartstring | undefinedIcon before the content: the name of a registered icon, e.g. lucide-plus (after import '@wds/core/icons/lucide/plus'). While loading the spinner takes its place.
icon-end.iconEndstring | undefinedIcon after the content, e.g. lucide-chevron-down on a menu trigger.
icon-flip-rtl.iconFlipRtlWdsIconFlip | undefinedMirrors icons in right-to-left layouts (arrows such as "back" and "next"): start, end or both. The icon of an icon-only button is mirrored by any value, also by the attribute without a value.
hrefstring | undefinedURL: the button renders as a link.
targetstring | undefined

Slots

SlotDescription
(default)Button content: text, or your own <svg> or <wds-icon> when an icon attribute is not enough.

CSS parts (::part)

PartDescription
buttonThe native <button> or <a>.
iconThe icon of an icon-only button (icon).
icon-startThe icon before the content (icon-start).
icon-endThe icon after the content (icon-end).

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 (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