ValyroUI Русская версия

Tear-off Ticket

A ticket whose stub tears off along the perforation. Free, MIT · Animated components › Stickers, tickets and boards

A ticket with a perforated stub: pull the stub away from the perforation and release past the threshold to tear it off and reveal the rest; a regular button does the same in one press. The stub follows the finger, springs back when let go too early and, once torn, flies off from where it was released while the ticket opens up. The gesture starts only on the stub, so links on the ticket stay plain links. Revealing does not register, redeem or send anything: the app does that.

Installation

npx valyro-cli@latest add tear-off-ticket
npx shadcn@latest add https://valyro.xyz/r/tear-off-ticket.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { TearOffTicket } from 'valyro-ui';

Props

PropTypeDefault
front *ReactNodeThe visible face of the closed ticket.
revealedContent *ReactNodeWhat tearing the stub off reveals: a code, an invitation, event details. Not a secret: it is in the page.
stubReactNodeContent of the stub; default labels.stub.
openbooleanControlled open; use with onOpenChange.
defaultOpenbooleanfalseInitial open when uncontrolled.
onOpenChange(open: boolean, reason: TearOffTicketReason) => voidA request to change the state, with what caused it. Controlled tickets open once open turns true.
onReveal() => voidOnce per real opening (the accepted open going from false to true); not for a ticket that starts open.
tearThresholdnumber0.65Share of the stub's size it must be pulled before release tears it off (a quick flick needs less). Default 0.65.
orientation'horizontal' | 'vertical''vertical'Direction of the perforation: vertical (default, the stub at the inline end, pulled sideways) or horizontal (the stub at the bottom, pulled down).
variant'plain' | 'paper' | 'game''plain'Look: plain (default) quiet surfaces and a thin dashed line, paper printed card with notches, game a pass in the theme's accent.
labelsPartial<TearOffTicketLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

Previous: Scratch Reveal · Next: Split-Flap Board · All Animated components