# Copy button API

> Explore the API of Cimpress UI's copy button component.

Source: https://ui.cimpress.io/components/copy-button/api/

## Import

```tsx
import { CopyButton } from '@cimpress-ui/react';
```

## Accessibility notes

`CopyButton` can be activated by pressing Enter or Space, similar to a native HTML button.

Icon-only copy button should have an `aria-label` prop defined to identify the function of the button to assistive technologies. See our [accessibility guide](/dev-guides/accessibility#labelling) for more details.

## API reference

### CopyButton

Displays a button that allows users to copy a specific value to clipboard.

See [copy button usage guidelines](https://ui.cimpress.io/components/copy-button/).

- `ref`: `Ref<HTMLButtonElement>`

  The `ref` type for this component.

**Props: `CopyButtonProps`**

- `value` (required): `string`

  The content to be copied.

- `size`: `'small' | 'medium' | 'large'`

  The size of the button.

  Defaults to `'medium'`.

- `children`: `StringLikeChildren`

  The text displayed on the button.

- `variant`: `'secondary' | 'tertiary'`

  Determines the visual appearance of the button.

  Defaults to `'secondary'`.

- `description`: `string`

  The description that appears in a tooltip when the user hovers or focuses the button.

- `onCopy`: `() => void`

  A handler that gets called when the user triggers the copying.

- `id`: `string`

  The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

- `data-cim-style-root`: `boolean`

  Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.

- `UNSAFE_className`: `string`

  Sets the CSS className for the element. Only use as a **last resort**. Use style props instead.

  See [styling guide](https://ui.cimpress.io/dev-guides/styling/).

- `UNSAFE_style`: `CSSProperties`

  Sets the CSS style for the element. Only use as a **last resort**. Use style props instead.

  See [styling guide](https://ui.cimpress.io/dev-guides/styling/).

- `aria-label`: `string`

  Defines a string value that labels the current element.

- `aria-labelledby`: `string`

  Identifies the element (or elements) that labels the current element.

- `aria-describedby`: `string`

  Identifies the element (or elements) that describes the object.

- `aria-details`: `string`

  Identifies the element (or elements) that provide a detailed, extended description for the object.

- `onHoverStart`: `(e: HoverEvent) => void`

  Handler that is called when a hover interaction starts.

- `onHoverEnd`: `(e: HoverEvent) => void`

  Handler that is called when a hover interaction ends.

- `isDisabled`: `boolean`

  Whether the button is disabled.

**Props: `StyleProps`**

- `margin`: `Responsive<Spacing | "auto">`

  The amount of margin applied to all edges of this component.

- `marginX`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the left and right edges of this component. Takes priority over `margin`.

- `marginY`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the top and bottom edges of this component. Takes priority over `margin`.

- `marginTop`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the top edge of this component. Takes priority over `marginY` and `margin`.

- `marginRight`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the right edge of this component. Takes priority over `marginX` and `margin`.

- `marginBottom`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the bottom edge of this component. Takes priority over `marginY` and `margin`.

- `marginLeft`: `Responsive<Spacing | "auto">`

  The amount of margin applied to the left edge of this component. Takes priority over `marginX` and `margin`.
