Default
Pull the stub away, tap it, or focus it and press Enter. The scissors have already started.
A coupon, ticket or raffle strip with a stub you tear off along a perforated line. Pull the stub and it swings off its far corner, tap it or press Enter and it comes away; the ticket keeps a torn edge. Calls onTear once.
npx shadcn@latest add @wobko/tear-off第一次使用?先把 registry 加进 components.json。 如何安装
Pull the stub away, tap it, or focus it and press Enter. The scissors have already started.
orientation="vertical" hangs the stub under the ticket, like the free coffee on a punch card. Kraft stock, and it is pulled down.
A real use: onTear redeems the coupon, and a controlled torn state lets the book be reset. The confetti stays inside the ticket.
The ticket: an inline flex box holding the body and the stub. Keeps the state (attached or torn), announces the tear politely, and lays the stub beside the ticket or below it.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| onTear | () => void | - | Called once when a person tears the stub off (drag, tap or keyboard). |
| torn / defaultTorn / onTornChange | boolean | - | Controlled or uncontrolled. Setting a controlled `torn` back to false puts a fresh stub on, dropping onto the ticket. |
| orientation | "horizontal" | "vertical" | "horizontal" | The stub is at the end of the line (start side in right-to-left) or below the ticket. |
| disabled | boolean | false | The stub cannot be pulled or torn. |
| tornMessage | string | "Torn off." | What the status line says when the stub comes off. |
The stub: a Paper (index card by default) that is a button. The perforation bites are the paper's own perf edge; on top of it are printed dashes, a pair of scissors at the start of the line, and a curled pencil arrow that says which way to pull.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| label | string | - | Accessible name. Default: the stub's own text. |
| stock | StockName | "index-card" | What it is made of. |
CLI 会复制进你项目的文件。
正在加载源码