Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Hooks & Utilities

useClipboard

Hooks & Utilities

useClipboard React hook in TypeScript

UIProvideruseConsent
Live props
Options
timeout2000ms
  1. Home
  2. Components
  3. Hooks & Utilities
  4. useClipboard
Free

useClipboard React hook in TypeScript

v1.0.0·Added in 1.0.0

A React copy-to-clipboard hook with a copied flag that resets itself, and a fallback for pages without the Clipboard API.

Press Copy next to an IBAN, a tax ID or an invoice link: the icon turns into a check for the timeout and the last copied text shows below. Paste it anywhere to check. Set the timeout to 0 and the check stays until the next copy.

useClipboard is a free React hook in the React hooks and utilities category, written in TypeScript for React 19. It installs as source with npx wingo-ui@latest add use-clipboard.

Add to a project

Requirements: React 19, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add use-clipboard

Usage

Import useClipboard from @/hooks/use-clipboard.

import { Check, Copy } from "lucide-react"
import { useClipboard } from "@/hooks/use-clipboard"

export function CopyIban({ iban }: { iban: string }) {
  const { copy, copied } = useClipboard()
  return (
    <button type="button" onClick={() => copy(iban)} aria-label={copied ? "Copied" : "Copy IBAN"}>
      {copied ? <Check /> : <Copy />}
    </button>
  )
}

API

  • timeoutdefault 2000
    number

    How long copied stays true after a copy, in ms. 0 keeps it until reset() or the next copy.

  • onCopy / onError
    (text: string) => void / (error: Error) => void

    Called after each copy; the latest callbacks are always used, so there is nothing to memoize.

  • useClipboard
    (options?: { timeout?: number; onCopy?; onError? }) => { copy(source: string | (() => string | Promise<string>), options?: { html?: string }): Promise<boolean>; copied: boolean; error: Error | null; text: string | null; reset(): void }

    copy takes a string or a function read at click time (the latest form value, a link fetched on demand) and resolves true on success. Pass html to put a rich version next to the plain text.

Parts

  • copyToClipboard

    function

    The same copy without state, for event handlers: navigator.clipboard where it exists, a hidden textarea with execCommand on plain http and old webviews. Focus returns to where it was. Signature: (text: string, options?: { html?: string }) => Promise<boolean>.

Examples

Share link

copy takes a function, read at click time. The button label flips to Copied and a live region announces it.

Dependencies

No dependencies beyond React.

Files

  • hooks/use-clipboard.ts

FAQ

Is the useClipboard hook free?

Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.

How do I install useClipboard?

Run npx wingo-ui@latest add use-clipboard. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/use-clipboard.json.

See also

Code BlockuseShortcuthook

Used in

QR CodeCopy ButtonComment ThreadDiff ViewerJSON ViewerLog ViewerFile System

More React hooks and utilities

useConsenthookuseControllableStatehookuseCooldownhookuseDebouncehookuseKeyboardInsethookuseLocalehook
All 36 React hooks and utilities

Articles using this component

  • React QR Code with Logo: Rounded Modules, PNG and SVG

    Component guides · Oct 19, 2026 · 9 min read

PreviousUIProviderNext useConsent

Payment details

IBANGB29 NWBK 6016 1331 9268 19
Tax ID12-3456789
Invoice linkhttps://northwind.example/i/2026-0412

timeout: 2000 ms