Copy inline API
Import
Section titled “Import”import { CopyInline } from '@cimpress-ui/react';Accessibility notes
Section titled “Accessibility notes”CopyInline can be activated by pressing Enter or Space, similar to a native HTML button.
Style inheritance
Section titled “Style inheritance”CopyInline rendered within the text component will inherit the style of the surrounding text.
Certain styles like color and text decoration will not be inherited, so that CopyInline can remain visually distinct.
The example below renders two paragraphs of text with nested CopyInline. Notice that the CopyInline components match the style of the containing paragraph, even though their markup doesn’t change.
This paragraph contains a that inherits its style.
This paragraph also contains a that inherits its style.
import { CopyInline, Stack, Text } from '@cimpress-ui/react';
export default function Demo() { return ( <Stack gap={16}> <Text as="p" variant="title-5" tone="base"> This paragraph contains a <CopyInline>copyable text</CopyInline> that inherits its style. </Text>
<Text as="p" variant="medium" tone="subtle" fontStyle="italic"> This paragraph also contains a <CopyInline>copyable text</CopyInline> that inherits its style. </Text> </Stack> );}API reference
Section titled “API reference”CopyInline
Section titled “CopyInline”Allows copying an inline value to clipboard.
- Ref<HTMLButtonElement>
-
The
reftype for this component.
CopyInlineProps
- StringLikeChildren
children *
Section titled “ children * ” -
The content to be copied.
- () => void
onCopy
Section titled “ onCopy ” -
A handler that gets called when the user triggers the copying.
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
- string
aria-label
Section titled “ aria-label ” -
Defines a string value that labels the current element.
- string
aria-labelledby
Section titled “ aria-labelledby ” -
Identifies the element (or elements) that labels the current element.
- string
aria-describedby
Section titled “ aria-describedby ” -
Identifies the element (or elements) that describes the object.
- string
aria-details
Section titled “ aria-details ” -
Identifies the element (or elements) that provide a detailed, extended description for the object.
- 'small' | 'medium' | 'title-1' | 'title-2' | 'title-3' | 'title-4' | 'title-5' | 'title-6' | 'body' | 'body-semibold' | 'medium-semibold' | 'small-semibold'
variant
Section titled “ variant ” -
Determines the visual variant of text.
- boolean
isDisabled
Section titled “ isDisabled ” -
Whether the button is disabled.
- (e: HoverEvent) => void
onHoverStart
Section titled “ onHoverStart ” -
Handler that is called when a hover interaction starts.
- (e: HoverEvent) => void
onHoverEnd
Section titled “ onHoverEnd ” -
Handler that is called when a hover interaction ends.
StyleProps
- Responsive<Spacing | "auto">
margin
Section titled “ margin ” -
The amount of margin applied to all edges of this component.
- Responsive<Spacing | "auto">
marginX
Section titled “ marginX ” -
The amount of margin applied to the left and right edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginY
Section titled “ marginY ” -
The amount of margin applied to the top and bottom edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginTop
Section titled “ marginTop ” -
The amount of margin applied to the top edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginRight
Section titled “ marginRight ” -
The amount of margin applied to the right edge of this component. Takes priority over
marginXandmargin. - Responsive<Spacing | "auto">
marginBottom
Section titled “ marginBottom ” -
The amount of margin applied to the bottom edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginLeft
Section titled “ marginLeft ” -
The amount of margin applied to the left edge of this component. Takes priority over
marginXandmargin.