Skip to content
# AiCopyButton **Also known as:** CopyToClipboard ## Description BitAiCopyButton copies a text to the clipboard and confirms it, because a copy button that gives no feedback leaves the user guessing whether it worked: for a moment after the copy its glyph is a check mark, its name says Copied, and a polite live region announces it. It is an icon button by default, with its label beside the icon on request, and is disabled while it has no Content. ## Parameters | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Classes | `BitAiCopyButtonClassStyles?` | null | Custom CSS classes for different parts of the copy button. | | ConfirmationDuration | `TimeSpan` | TimeSpan.FromSeconds(2) | How long the confirmation - the check mark and the Copied name - stays on the button after a copy. Another copy while it shows starts it over. | | Content | `string?` | null | The text to copy, read when the button is pressed. A null value disables the button; an empty text is copied like any other. | | Label | `string?` | null | The name of the button: its tooltip, its accessible name, and its text when ShowLabel is set. While the confirmation lasts the Copied text of the strings in force takes its place. When null, the Copy text of the strings in force is used (BitAiStrings.Copy, "Copy"). | | OnCopied | `EventCallback` | | Raised after the text has been put on the clipboard - never for a copy the browser refused. | | ShowLabel | `bool` | false | Shows the name of the button beside its icon. | | Styles | `BitAiCopyButtonClassStyles?` | null | Custom CSS styles for different parts of the copy button. | | AriaLabel | `string?` | null | Gets or sets the accessible label for the component, used by assistive technologies. | | Class | `string?` | null | Gets or sets the CSS class name(s) to apply to the rendered element. | | Dir | `BitDir?` | null | Gets or sets the text directionality for the component's content. | | Disabled | `bool` | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. | | ForceAnimation | `bool` | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. | | HtmlAttributes | `Dictionary<string, object>` | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. An attribute written on the component wins over an entry of the same name. | | Id | `string?` | null | Gets or sets the unique identifier for the component's root element. | | Style | `string?` | null | Gets or sets the CSS style string to apply to the rendered element. | | TabIndex | `string?` | null | Gets or sets the tab order index for the component when navigating with the keyboard. | | Visibility | `BitVisibility` | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. | ## Public Members | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | UniqueId | `Guid` | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. | | RootElement | `ElementReference` | | Gets the reference to the root HTML element associated with this component. | ## Enums ### BitVisibility Enum | Name | Value | Description | | :--- | :--- | :---------- | | Visible | 0 | The content of the component is visible. | | Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). | | Collapsed | 2 | The component is hidden (display:none). | ### BitDir Enum | Name | Value | Description | | :--- | :--- | :---------- | | Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). | | Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). | | Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. | ## Sub Classes ### BitAiCopyButtonClassStyles Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Root | `string?` | null | Custom CSS classes/styles for the root element of the BitAiCopyButton. | | Button | `BitButtonClassStyles?` | null | Custom CSS classes/styles for the BitButton of the BitAiCopyButton. | | LiveRegion | `string?` | null | Custom CSS classes/styles for the visually hidden live region of the BitAiCopyButton, which announces the copy. | ## Examples \n**Basic**: ```razor
dotnet add package Bit.BlazorUI.AI
``` \n**Label & ShowLabel**: ```razor ``` \n**ConfirmationDuration & OnCopied**: ```razor
Copied @copyCount time(s)
``` ```csharp private int copyCount; private void HandleCopied() { copyCount++; } ``` \n**Content**: ```razor
``` ```csharp private string? draft; ``` \n**Disabled**: ```razor ``` \n**Cascading parameters**: ```razor ``` ```csharp private readonly BitAiCopyButtonParams[] copyButtonParams = [ new() { ShowLabel = true, ConfirmationDuration = TimeSpan.FromSeconds(4) } ]; ``` \n**Style & Class**: ```razor ``` ```csharp private const string cssVariablesStyle = "--bit-Button-text-color:var(--bit-clr-pri);" + "--bit-Button-text-hover-background:var(--bit-clr-pri-light);" + "--bit-Button-radius:2rem;"; ``` \n**RTL**: ```razor
```