Getting StartedComponentsDesign TokensThemingTheme SynthesizerFrameworksAccessibilityUtilitiesServer RenderingBrowser SupportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting StartedFrameworksServer RenderingDesign TokensThemingTheme SynthesizerTypographyUtilitiesAll ComponentsAccessibilityBrowser SupportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Copy Button

One-click copy-to-clipboard button with confirmation.

ComponentsCopy Button
inputinteractive
<arc-copy-button>

Overview

CopyButton copies a text value to the system clipboard in one click. It renders as a compact button with a clipboard icon and a "Copy" label. When clicked, it calls the Clipboard API to write the `value` property to the clipboard, then transitions to a green checkmark "Copied!" confirmation state for two seconds before reverting to its default appearance. It is commonly paired with code blocks, API keys, URLs, and other text users need to paste elsewhere. Because it uses the async Clipboard API (`navigator.clipboard.writeText`), it requires a secure context (HTTPS or localhost). If the clipboard write fails, for example in a non-secure iframe, the error is caught silently and the button stays in its default state. CopyButton dispatches an `arc-copy` event on successful copy, carrying the copied value in the event detail. Parent components can react to the copy, for example by showing a toast or logging the event. The `disabled` attribute reduces opacity and prevents interaction, and all states (default, hover, focus, copied) are styled through ARC design tokens.

Guidelines

When to use

  • Place CopyButton adjacent to the content it copies, such as a code snippet, URL, or API key
  • Set the value property to the exact string the user expects to paste, not a formatted or truncated version
  • Use the arc-copy event to trigger a toast or analytics event confirming the copy action
  • Ensure the page is served over HTTPS so the Clipboard API is available
  • Use the disabled attribute when the value is not yet available (e.g. while loading)

When not to use

  • Do not use CopyButton for general-purpose actions; it is for clipboard copy only
  • Do not set the value to empty string and expect the button to be useful; always provide meaningful content
  • Do not override the 2-second confirmation timeout; two seconds is long enough to notice
  • Do not nest CopyButton inside another button or interactive element, as this creates invalid HTML nesting
  • Do not rely solely on the confirmation state for feedback; pair with a toast for users who look away

Features

  • One-click copy to clipboard using the async Clipboard API
  • Visual confirmation state with green checkmark icon and "Copied!" label for 2 seconds
  • `arc-copy` custom event fired on successful copy with the value in the detail payload
  • Disabled state with reduced opacity and pointer-events: none
  • Focus-visible ring via var(`--focus-glow`) for keyboard accessibility
  • Hover state with elevated border and background color shift
  • Fails silently when the Clipboard API is unavailable (non-secure contexts)
  • Compact inline-flex layout that sits next to code blocks and input fields

Preview

npm install @arclux/arc-ui

Usage

This component requires JavaScript. No pure HTML/CSS version is available. Use the Web Component directly or a framework wrapper.

<arc-copy-button value="npm install @arclux/arc-ui"></arc-copy-button>

API

valuestring''
The text string to copy to the clipboard when the button is clicked.
labelstring''
Accessible name before copying, such as "Copy code". Defaults to "Copy to clipboard". After copying the name is "Copied".
disabledbooleanfalse
Disables the button, preventing clicks and reducing visual opacity.
iconOnlybooleanfalse
Shows the icon alone in a round, borderless 30px button, for a toolbar or a header bar. The icon turns into a check for 1.4 seconds after copying.

Events

arc-copydetail:{ value: string }
Fired when text is successfully copied to the clipboard. event.detail.value contains the copied string.

See Also