Buttons

Copy button

Copies text to the clipboard and says so: the icon turns into a tick and the label into “Copied”, then both come back. The button never changes width.

Installation

npx sinaui add copy-button

Examples

With a label

<script lang="ts">
	import CopyButton from '#lib/ui/CopyButton.svelte';
</script>

<CopyButton value="https://bayt-al-hikma.org/manuscripts/optics-1021">Copy link</CopyButton>

Icon only

Next to the thing it copies. The tooltip names it, and says “Copied” after.

Catalog reference BH-MS-0873
<script lang="ts">
	import CopyButton from '#lib/ui/CopyButton.svelte';

	const reference = 'BH-MS-0873';
</script>

<div class="ref">
	Catalog reference <code>{reference}</code>
	<CopyButton value={reference} square variant="ghost" size="sm" />
</div>

<style>
	.ref {
		display: flex;
		align-items: center;
		gap: 0.5rem;
	}
</style>

Props

PropTypeDefault
valuestring | () => string | Promise<string> (required)
variant'primary' | 'secondary' | 'ghost''secondary'
size'sm' | 'md' | 'lg''md'
squareboolean: icon onlyfalse
copiedstring'Copied'
childrenthe label“Copy”

Keyboard

KeyDoes
Enter SpaceCopies

Accessibility

  • “Copied”, or “Couldn't copy” if the browser refuses, is announced to screen readers.
  • The icon-only button is named by its tooltip.
  • With reduced motion, the icons and labels crossfade without scaling.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme