Clipboard

A ghost icon button that copies its text and shows a check mark afterwards.

New control
InteractiveClipboard demo
<StackPanel Orientation="Horizontal" Spacing="4" HorizontalAlignment="Left">
  <TextBlock Text="dotnet add package AvaloniaUIKit" VerticalAlignment="Center" />
  <gpui:Clipboard Text="dotnet add package AvaloniaUIKit" />
</StackPanel>

Usage

gpui:Clipboard is a Button (so Click and Command work) drawn as a ghost icon-only button with the copy icon. Set Text to what it copies; a click writes it to the clipboard, raises Copied, and shows the check icon for two seconds (the :copied pseudo-class and IsCopied), during which another click does nothing. Sizes are the Button's: xsmall, small, large (medium is the default).

Examples

The four sizes.

Sizes
InteractiveClipboard demo: Sizes
<WrapPanel ItemSpacing="8" LineSpacing="8">
  <gpui:Clipboard Classes="xsmall" Text="Copied text" />
  <gpui:Clipboard Classes="small" Text="Copied text" />
  <gpui:Clipboard Text="Copied text" />
  <gpui:Clipboard Classes="large" Text="Copied text" />
</WrapPanel>

Not covered

  • Computing the value at click time (GPUI's value_fn): set Text before the click instead.