Skip to Main Content
Mosaic Logo
Mosaic Logo
  • Home
  • Browse components
  • Use in projects
    • Colors
    • Icons
    • Grid
    • Links
    • Typography
    • Spacing Utilities
    • SVG
    • Accordions
    • Alerts
    • Badges
    • Buttons
    • Copy to clipboard
    • Cards
    • Featured Container
    • Filter Bar
    • Lists
    • Loading Spinners
    • Modals
    • Pagination
    • Progress Bars
    • Progress Indicator
    • Site Banner
    • Tables
    • Tabs
    • Toast
    • Toggle Switches
    • Well
    • Wizard
    • Events
    • File Browser
    • File Upload
    • Footer
    • Header
    • Hero
    • Post Item
    • Profile
    • Sidebar Navigation
    • Splash
    • Stack
    • Form Instructions
    • Form Layout
    • Form Validation
    • Form Output
    • Checkboxes
    • Labels
    • Radio Buttons
    • Search Input
    • Select
    • Text Inputs

Copy to clipboard

Definition

The Copy Tooltip Component is a React-based UI element designed to provide users with an intuitive way to copy text values, such as suggestions or entries, to the clipboard with visual feedback.

Description

This component integrates with text input fields, displaying recommended text entries and offering an interactive copy button. When clicked, the button copies the associated text to the user's clipboard and briefly shows a tooltip confirming the action.

Behavior

  • The tooltip automatically adjusts its placement based on the viewport size to ensure visibility.
  • Visual feedback ("Copied to clipboard") is provided immediately after the copy action, disappearing after a short duration.

Accessibility

  • Ensure that the tooltip is open long enough so that users have plenty of time to read the message.

Example





      <label for="copyTextInput" class="form-label">Text to copy:</label>
      <input
        type="text"
        class="form-control"
        id="copyTextInput"
        value="This is the text to copy"
        aria-label="Text input with copy button"
      />
      <br />
      <button
        class="btn btn-outline-secondary"
        type="button"
        id="copyButton"
        data-bs-toggle="tooltip"
        data-bs-placement="bottom"
        title="Copy to clipboard"
        >
          <FontAwesomeIcon icon={faCopy} client:only="react" />Copy text to clipboard
        </button>
        
  • facebook

  • Instagram

  • Twitter

  • LinkedIn

  • YouTube

  • Accessibility
  • Privacy Policy
  • Contact Us
Sign up for our newsletter
ICPSR

© 2025 The Regents of the University of Michigan. ICPSR is part of the Institute for Social Research at the University of Michigan.