Toggle
Кнопка-переключатель с пружинным откликом. Pro · Анимированные компоненты › Кнопки
Установка
npx valyro-cli@latest login
npx valyro-cli@latest add toggle
npm install valyro-ui-pro
import 'valyro-ui-pro/styles.css';
import { Toggle } from 'valyro-ui-pro';
Пропсы
| Prop | Type | Default | |
|---|---|---|---|
pressed | boolean | On (aria-pressed) state. | |
defaultPressed | boolean | false | Initial pressed when uncontrolled. |
onPressedChange | (pressed: boolean) => void | Called with the new pressed when it changes. | |
tone | 'neutral' | 'accent' | 'neutral' | Colour of the on state: a neutral fill or the accent tint. |
fillIcon | boolean | false | Fills an outline icon (a star, a heart) while on. |
animation | 'spring' | 'none' | 'spring' | spring (default): the button presses in while held and springs back with a bounce, and the icon pops in when turned on (and settles when turned off). none: no motion. |
variant | 'primary' | 'secondary' | 'ghost' | 'accent' | 'danger' | 'link' | 'ghost' | Solid primary/accent/danger fill, outlined secondary, transparent ghost, or unpadded text link. |
size | 'sm' | 'md' | 'lg' | Control height, padding and text size. | |
leftIcon | ReactNode | Icon or element before the label. | |
rightIcon | ReactNode | Icon or element after the label. | |
fullWidth | boolean | Stretch to the full width of the container. | |
pill | boolean | Fully rounded ends, regardless of theme. | |
hoverScale | number | Scale under a hovering mouse, e.g. 1.05; it springs back with a slight bounce. Off by default (the theme's own hover). Skipped on touch and under reduced motion. | |
tapScale | number | Scale while pressed, e.g. 0.95, instead of the theme's press transform; springs back on release. |
Похожие компоненты
- Flip Button — Кнопка с двумя сторонами, переворачивается на пружине
- Liquid Button — Кнопка, которая заполняется «жидкостью» при наведении
- Theme Toggler — Смена светлой и тёмной темы с раскрытием через View Transitions
- GitHub Stars Button — Ссылка на репозиторий с прокручивающимся числом звёзд
- Share Button — Кнопка, раскрывающая иконки соцсетей
- Code Tabs — Варианты кода во вкладках: npm, pnpm, bun — с копированием
- Number Wheel — Число на вращающемся барабане с соседними значениями
- Pin List — Список с закреплением: элементы плавно переезжают между группами
- Notification Stack — Стопка уведомлений, раскрывающаяся в список
- Todo List — Чек-лист с волнистым зачёркиванием выполненных пунктов
- Presence Avatars — Кто онлайн: аватары перестраиваются при смене статуса
- Radial Menu — Кольцевое контекстное меню по правому клику
Назад: Patch Notes · Далее: Flip Button · Весь раздел «Анимированные компоненты»