Tear-off Ticket, animated React component
- Pro
- Cards
- Spring
Tear-off Ticket
An event ticket whose stub you pull away along the perforation. Let go early and it snaps back; pull through and it hangs on the last tooth, swings, then drops. Also includes the Motion Kit Ticket CTA variant: an event call to action printed as a ticket, with a button that tears the stub for you.
Ticket CTA
Swishes when the stub tears free and taps on New ticket. Sound is off on this site until you switch it on.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| title | string | "Light & Matter" | Event name. |
| venue | string | "Hall 3 · North Gallery" | First detail line. |
| date | string | "Sat 14 Nov · 11:00" | Second detail line. |
| seat | string | "Row C · Seat 12" | Seat shown on the stub. |
| autoplay | boolean | false | Tugs, tears and resets on a loop until someone grabs the stub. |
| TicketCta.event | Partial<TicketCtaEvent> | — | Event details: title, host, date, time, start and end (calendar stamps), row, seat, serial and going. Any field left out keeps its default. |
| TicketCta.ctaLabel | string | "Claim my seat" | Label of the primary button, which tears the stub for people who cannot or would rather not drag. |
| TicketCta.href | string | — | Where the follow-up link goes once the stub has come away. Without it the follow-up is Add to calendar. |
| TicketCta.doneLabel | string | "Continue" | Label of the follow-up link that href produces. |
| TicketCta.onClaim | () => void | — | Called once when the stub comes away, by pull, key or button. Not called by autoplay. |
| TicketCta.accent | string | "#0071e3" | Accent for the stamp, the print and the follow-up button in light mode. |
| TicketCta.accentDark | string | "#2997ff" | The same, in dark mode. |
| TicketCta.enableSound | boolean | true | Plays interface sounds on interaction; they follow the site-wide sound switch. |
| TicketCta.autoplay | boolean | false | Tugs at the stub now and then, tears it, resets and repeats until the visitor touches the ticket. |
| enableSound | boolean | true | Plays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry with your API key
Tear-off Ticket is a Pro item, so the CLI has to send your API key. Do this once per project:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand add this entry inside the outermost braces, next to"aliases". Leave{name}and${NEXUS_API_KEY}exactly as written; the CLI fills them in:"registries": { "@nexus-labs": { "url": "https://www.nexus-ui.com/api/registry/{name}", "headers": { "Authorization": "Bearer ${NEXUS_API_KEY}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
How Tear-off Ticket works
Pull the stub away from the ticket. The perforation gives way from the top pull far enough and it hangs for a beat, then drops.
The source, the install command and the build prompt come with Pro.
Tear-off Ticket questions
How do I install Tear-off Ticket?
Run `npx shadcn@latest add @nexus-labs/tear-off-ticket`. It installs framer-motion. Tear-off Ticket is a Pro component, so it needs a Pro plan and an API key; key setup is on the CLI docs page (/docs/cli).
How do I change the ticket text?
Use `title`, `venue`, `date` and `seat`; `seat` appears on the stub. The "Exhibition" and "Admit one" labels are fixed text in the source file, so edit the copied component to change them.
How far do I pull to tear it?
Drag the stub right, with downward movement counting at 0.6, until you reach about 150px of pull. Let go earlier and it springs back. Past that it tears, swings on its last tooth and drops. A New ticket button then resets it.
Can I tear it without dragging?
Yes. The stub is a focusable `role="button"`, and Enter or Space tears it. The `autoplay` prop (default `false`) tugs, tears and resets on a loop until someone grabs the stub.
Can I run code when the stub tears off?
There is no callback prop; the props are `title`, `venue`, `date`, `seat` and `autoplay`. To react to a tear, add your handler to the `tear` function in the copied source file.
Does it make sound, and how do I turn it off?
Swishes when the stub tears free and taps on New ticket. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.

