Buttons

Confirm button

For actions worth a second thought. The first press turns it red and asks; a second press within a few seconds goes ahead. Otherwise it quietly goes back.

Installation

npx sinaui add confirm-button

Examples

Withdraw a loan

Press once to be asked, again to confirm. Wait, press Escape or move away and it goes back.

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

	let status = $state('');
</script>

<ConfirmButton onconfirm={() => (status = 'The loan of the Canon of Medicine was withdrawn.')}
	>Withdraw loan</ConfirmButton
>
<p role="status">{status}</p>

<style>
	p {
		margin: 0;
		color: var(--ui-muted);
	}
</style>

Deleting something

When onconfirm returns a promise, it works, then shows it’s done. This one waits five seconds for an answer.

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

	const remove = () => new Promise((resolve) => setTimeout(resolve, 1000));
</script>

<ConfirmButton onconfirm={remove} confirm="Delete for everyone?" done="Deleted" timeout={5000}
	>Delete the draft</ConfirmButton
>

Props

PropTypeDefault
onconfirm() => Promise | void (required)
confirmstring'Are you sure?'
donestring'Done'
timeoutnumber (ms)3000
variant'danger' | 'primary': a light tint at rest, solid once it asks'danger'
size'sm' | 'md' | 'lg''md'

Keyboard

KeyDoes
Enter SpaceAsk, then confirm
EscapeChange your mind

Accessibility

  • The question is announced with how to confirm it.
  • Moving focus away, Escape or waiting cancels it.
  • With reduced motion, labels fade without sliding.
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