Dark Light
System
Default LBBW Jira Confluence Source Code
Share
Playground

Copy Button

<afp-copy-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 that copies a specified text value to the clipboard when clicked.

Examples #

Variants #

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

Appearance #

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

Shapes #

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

Sizes #

Use --afp-copy-button-size CSS variable to change a button's size.

Tooltip text #

Use the tooltip attribute to change the tooltip text.

Without Tooltip #

Use the noTooltip (notooltip) attribute to disable the tooltip.

Disabled #

Use the disabled attribute to disable the copy button.

Duration #

Use the duration attribute to set how long the success state lasts (in milliseconds).

Custom Icons #

Use the icon and icon-success slots to provide custom icons for the copy and success states.

Properties

Learn more about properties.

Name Description Reflects
tooltip
Tooltip text displayed on hover.
Type string
Default 'Copy'
noTooltip
notooltip
If true, the tooltip is not displayed.
Type boolean
Default false
value
The text value to be copied to the clipboard when the button is clicked.
Type string
duration
Duration in milliseconds for which the success state is shown after copying.
Type number
Default 1000
disabled
If true, the copy button is disabled.
Type boolean
open
Whether the tooltip is currently open.
Type boolean
Default false
variant
Variant of the copy 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
shape
Shape of the copy 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
appearance
Appearance of the copy 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.FILLED

Events

Learn more about events.

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

Slots

Learn more about slots.

Name Description
icon
Used to pass in a custom icon for the copy action.
icon-success
Used to pass in a custom icon for the success state after copying.

Internationalization

Learn more about internationalization.

Key Description
copy-button.aria-label
Aria label for the copy button.
copy-button.success
Text announced when the copy action is successful. Used for screen readers.

CSS Parts

Learn more about CSS Parts.

Name Description Selector
base
The button element.
::part(base)
icon-wrapper
The wrapper for the copy icon.
::part(icon-wrapper)
icon
The copy icon.
::part(icon)
icon-success-wrapper
The wrapper for the success icon.
::part(icon-success-wrapper)
icon-success
The success icon.
::part(icon-success)
tooltip
The tooltip element.
::part(tooltip)

CSS Custom Properties

Name Description Default
--afp-copy-button-disabled-opacity
The opacity of the copy button when disabled.
0.5
--afp-copy-button-size
The size of the copy button.
--afp-size-s

Dependencies

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

afp-icon afp-tooltip

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/copy-button/copy-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