Dark Light
System
Default LBBW Jira Confluence Source Code
Share
Playground

Button

<afp-button> Since 1.0.0 stable This component uses the light DOM, so its markup and styles are part of the regular document flow.

A button component to trigger an action. Can also be used as a link.

Click me

Examples #

Variants #

Use the variant attribute to set the button's semantic variant.

Neutral Brand Accent Info Error Success Warning

Appearance #

Use the appearance attribute to change the button's visual appearance.

Default Filled Outlined Outlined filled Plain
Default Filled Outlined Outlined filled Plain
Default Filled Outlined Outlined filled Plain
Default Filled Outlined Outlined filled Plain
Default Filled Outlined Outlined filled Plain
Default Filled Outlined Outlined filled Plain
Default Filled Outlined Outlined filled Plain

Shapes #

Use the shape attribute to change a button's shape.

Pill Rounded Soft Square

Sizes #

Use the size attribute to change a button's size.

Small Medium Large

Caret #

Use the caret attribute to add a caret icon to the end of the button.

Caret

It's often helpful to have a button that works like a link. This is possible by setting the href attribute, which will make the component render an <a> under the hood.

Link New Window Download

Icon Buttons #

Use the <afp-icon> component inside a button to create an icon button. You can use the aria-label attribute to provide an accessible label for screen readers.

Decorations #

Use the default slots to add custom decorations to the start or end of a button.

John Doe

Disabled #

Use the disabled attribute to disable a button.

Neutral Brand Accent Info Error Success Warning

Loading #

Use the loading attribute to make a button busy. The width will remain the same as before, preventing adjacent elements from moving around.

Load Load Load Load Load Load Load

Properties

Learn more about properties.

Name Description Reflects
variant
variant of button
Type
AfpVariant
Name Description
NEUTRAL
The main call-to-action.
BRAND
Less prominent than primary.
ACCENT
Secondary highlight for emphasis.
ERROR
Used for destructive or critical actions.
INFO
Conveys general information.
SUCCESS
Indicates a successful or positive action.
WARNING
Communicates cautionary actions.
AfpVariant
Default AfpVariant.NEUTRAL
type
button type
Type
AfpButtonType
Name Description
BUTTON
Standard button.
SUBMIT
Submits a form.
RESET
Resets all fields in a form.
LINK
Navigates to another resource.
AfpButtonType
Default AfpButtonType.BUTTON
value
value which is displayed as button text
Type string
size
size of the button.
Type
AfpSize
Name Description
SMALL
Small size with compact dimensions.
MEDIUM
Medium size with standard dimensions.
LARGE
Large size with expanded dimensions.
AfpSize
Default AfpSize.MEDIUM
title
html title attribute of button
Type string
appearance
appearance of button
Type
AfpAppearance
Name Description
DEFAULT
Highlighted, primary action (default).
OUTLINED
Transparent background with a visible border.
PLAIN
Minimal, no border or background.
FILLED
Solid background, no border.
OUTLINED_FILLED
Solid background with a visible border.
AfpAppearance
Default AfpAppearance.DEFAULT
name
html name attribute of button
Type string
tabIndex
tabindex
html tabIndex property of button
Type number
Default 0
rel
When using `href`, this attribute will map to the underlying link's `rel` attribute.
Type string | undefined
disabled
disabled property of button
Type boolean
Default false
caret
enables caret icon
Type boolean
Default false
loading
enables loading style and disables button
Type boolean
Default false
shape
shape of the button
Type
AfpShape
Name Description
PILL
Makes the component circular.
ROUNDED
Makes the component rounded.
SOFT
Makes the component have soft edges.
SQUARE
Makes the component square.
AfpShape
Default AfpShape.ROUNDED
href
href for link button
Type string
target
target of link type button
Type AfpTarget
download
enables download option for type link with the specified filename
Type string

Dynamic Attributes

Dynamic Attributes reflect a component’s current state and change automatically in response to internal logic or user interaction.

They can be used for conditional styling in combination with CSS Attributes.

Name Description
icon
Applied when the button contains only an icon in the default slot.

Methods

Learn more about using methods.

Name Description Arguments
doClick
This method retrieves the associated action element and simulates a user click on it. It can be used to trigger interactive behavior without requiring direct user interaction.
-
doFocus
This method retrieves the associated action element and sets focus on it. It can be used to programmatically move the focus to the element without user interaction.
-
doBlur
This method retrieves the associated action element and removes focus from it. It can be used to programmatically blur the element without user interaction.
-

Events

Learn more about events.

Name Return Description
afp-click void
Emitted when the button is clicked.
afp-focus void
Emitted when the button gains focus.
afp-blur void
Emitted when the button loses focus.

Slots

Learn more about slots.

Name Description
default
The default slot.
spinner
Used to pass in a custom spinner.
caret-icon
Used to pass in a custom caret icon.

CSS Parts

Learn more about CSS Parts.

Name Description Selector
button
The button element when the component is rendered as a button.
::part(button)
link
The link element when the component is rendered as a link.
::part(link)
reset
The element representing a reset action when `type="reset"`.
::part(reset)
submit
The element representing a submit action when `type="submit"`.
::part(submit)
label
The container wrapping the button’s label and default slot content.
::part(label)
spinner
The container for the loading spinner, visible when loading is true.
::part(spinner)
caret
The container for the caret icon, visible when caret is true.
::part(caret)

CSS Custom Properties

Name Description Default
--afp-button-disabled-opacity
The opacity of the button when disabled.
0.5
--afp-button-width
The width of a button.
auto

Dependencies

The component automatically brings in the listed items, including any nested dependencies that may exist.

afp-icon afp-spinner

Importing

Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.

import '@afp-design-system/core/dist/components/button/button.js';
Share
Create a link with a predefined theme that is automatically applied when the generated link is opened. Default LBBW Presentation Mode
Abort Copy Link