Blossom UI

Timer button

Timer button component, a button with a bar that fills while time passes and calls a function when it is full, for autoplay, tours and undo actions, and a hold to confirm button.

How to use it

Run npx @blossomui/react add timer-button, or copy src/components/UI/TimerButton/TimerButton.tsx into your React project and import it.

import { TimerButton, HoldButton } from './components/ui/TimerButton'

Props

TimerButtonLabels

PropTypeDescription
pause (required)stringAccessible name of the button while it counts.
play (required)stringAccessible name of the button while it is paused.
remaining (required)(seconds: number) => stringText with the time that is left, for example "4s".

TimerButtonProps

PropTypeDescription
labelsPartial<TimerButtonLabels>Texts of the component. Pass only the ones you want to change, for example to translate it.
durationnumberMilliseconds the bar takes to fill.
onComplete() => voidCalled every time the bar is full. Use it to go to the next slide, the next step, to submit...
loopbooleanStart again after it is full. With `false` it stops and waits for the user.
runningbooleanControlled state. Use together with `onRunningChange`.
defaultRunningbooleanInitial state when the button is not controlled. Autoplay should not start by itself for people who asked for less motion, so check `prefers-reduced-motion` before you pass `true`.
onRunningChange(running: boolean) => void
resetKeyunknownWhen this value changes the bar starts from zero, for example the number of the current slide.
showTimebooleanShow the seconds that are left.
childrenReactNodeText of the button, for example "Auto".
size'sm' | 'md' | 'lg'
colorstringAccent color of the bar: any CSS color. Without it the component uses `--blossom-accent`, which is pink by default.
classNamestring

HoldButtonProps

PropTypeDescription
children (required)ReactNodeText of the button, for example "Hold to delete".
onComplete() => voidCalled once, when the button was held for the whole `duration`.
durationnumberMilliseconds the button has to be held.
hintstringExplains the gesture to screen readers.
disabledboolean
size'sm' | 'md' | 'lg'
colorstringAccent color of the bar: any CSS color. Without it the component uses `--blossom-accent`, which is pink by default.
classNamestring

Getting started

  • Introduction
  • Installation
  • Changelog

Customization

  • Colors
  • Brand color
  • Texts and translation

Components

  • Accordion
  • Alert dialog
  • Alerts
  • Avatar
  • Badges
  • Banner
  • Breadcrumb
  • Buttons
  • Calendar
  • Cards
  • Carousel
  • Charts
  • Chip input
  • Collapsible
  • Color picker
  • Combobox
  • Command palette
  • Context menu
  • Copy button
  • Date picker
  • Drawer
  • Dropdown
  • Empty state
  • File upload
  • Footer
  • Forms
  • Hover card
  • Jumbotron
  • KBD
  • Menubar
  • Modal
  • Navbar
  • Navigation menu
  • Number input
  • OTP input
  • Pagination
  • Popover
  • Pricing
  • Progress
  • Rating
  • Resizable panels
  • Scroll area
  • Segmented control
  • Separator
  • Sidebar
  • Skeleton
  • Slider
  • Spinners
  • Stats
  • Stepper
  • Survey
  • Table
  • Tabs
  • Time picker
  • Timeline
  • Timer button
  • Toasts
  • Tooltip
  • Transfer list
  • Tree