Scratch Reveal
Стираемое покрытие над текстом или картинкой. Бесплатно, MIT · Анимированные компоненты › Наклейки, билеты и табло
Установка
npx valyro-cli@latest add scratch-reveal
npx shadcn@latest add https://valyro.xyz/r/scratch-reveal.json
npm install valyro-ui
import 'valyro-ui/styles.css';
import { ScratchReveal } from 'valyro-ui';
Пропсы
| Prop | Type | Default | |
|---|---|---|---|
children * | ReactNode | What the cover hides: text, a picture or a card. It cannot be focused until revealed. | |
cover | ScratchCover | Look of the coat. | |
brushSize | number | 36 | Brush diameter in CSS px. Default 36. |
threshold | number | 0.6 | Share of the card that must be cleared to reveal it all. Default 0.6. |
revealed | boolean | Controlled revealed; use with onRevealedChange. | |
defaultRevealed | boolean | false | Initial revealed when uncontrolled. |
onRevealedChange | (revealed: boolean, reason: ScratchRevealReason) => void | A request to reveal (scratch, button) or cover again (reset). Controlled cards follow revealed. | |
onReveal | (reason: 'scratch' | 'button') => void | Once per cycle, when the threshold is reached or the button is pressed; not when revealed is set from outside. | |
onProgressChange | (progress: number) => void | Cleared share 0…1 while scratching, at most about ten times a second. | |
resetKey | string | number | 0 | A new key clears the scratches of a covered card. It does not cover a revealed one (revealed={false} does). |
resettable | boolean | false | Offer a button that covers the card again once revealed. Default false. |
disabled | boolean | false | No scratching and no button. |
labels | Partial<ScratchRevealLabels> | Overrides for the built-in English text; keys left out keep their defaults. |
Похожие компоненты
- Peel Sticker — Наклейка отклеивается за угол и открывает содержимое
- Tear-off Ticket — Билет с корешком, который отрывается по перфорации
- Split-Flap Board — Механическое табло: перелистываются только изменившиеся символы
- Swipe Action Card — Горизонтальный свайп открывает действия карточки
- Toggle — Кнопка-переключатель с пружинным откликом
- Flip Button — Кнопка с двумя сторонами, переворачивается на пружине
- Liquid Button — Кнопка, которая заполняется «жидкостью» при наведении
- Theme Toggler — Смена светлой и тёмной темы с раскрытием через View Transitions
- GitHub Stars Button — Ссылка на репозиторий с прокручивающимся числом звёзд
- Share Button — Кнопка, раскрывающая иконки соцсетей
- Code Tabs — Варианты кода во вкладках: npm, pnpm, bun — с копированием
- Number Wheel — Число на вращающемся барабане с соседними значениями
Назад: Peel Sticker · Далее: Tear-off Ticket · Весь раздел «Анимированные компоненты»