ValyroUI English version

Theme Toggler

Смена светлой и тёмной темы с раскрытием через View Transitions. Pro · Анимированные компоненты › Кнопки

Установка

npx valyro-cli@latest login
npx valyro-cli@latest add theme-toggler
npm install valyro-ui-pro

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

Пропсы

PropTypeDefault
mode'light' | 'dark' | 'system'The chosen mode. Applying it (ThemeProvider, a class on <html>) is up to the app, in onModeChange.
defaultMode'light' | 'dark' | 'system''light'Initial mode when uncontrolled.
onModeChange(mode: ThemeTogglerMode) => voidCalled inside the view transition, so the new theme is painted into the sweep.
modesThemeTogglerMode[]['light', 'dark']Modes the button cycles through, in order (default light, dark).
direction'ltr' | 'rtl' | 'ttb' | 'btt' | 'circle''ltr'How the new theme sweeps over the page (default ltr).
onImmediateChange(mode: ThemeTogglerMode) => voidCalled on click with the next mode before the sweep starts (e.g. to save the choice).
labelsPartial<ThemeTogglerLabels>Overrides for the built-in English text; keys left out keep their defaults.
roundbooleanCircle instead of the theme's default button radius.
variant'primary' | 'secondary' | 'ghost' | 'accent' | 'danger' | 'link'Solid primary/accent/danger fill, outlined secondary, transparent ghost, or unpadded text link.
size'sm' | 'md' | 'lg'Control height, padding and text size.
loadingbooleanShows a spinner and blocks activation without changing the button's width: the spinner takes the left icon's place, or covers the label when there is no left icon. The button stays focusable and gets aria-busy.
pillbooleanFully rounded ends, regardless of theme.
hoverScalenumberScale 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.
tapScalenumberScale while pressed, e.g. 0.95, instead of the theme's press transform; springs back on release.

Похожие компоненты

  • Toggle — Кнопка-переключатель с пружинным откликом
  • Flip Button — Кнопка с двумя сторонами, переворачивается на пружине
  • Liquid Button — Кнопка, которая заполняется «жидкостью» при наведении
  • GitHub Stars Button — Ссылка на репозиторий с прокручивающимся числом звёзд
  • Share Button — Кнопка, раскрывающая иконки соцсетей
  • Code Tabs — Варианты кода во вкладках: npm, pnpm, bun — с копированием
  • Number Wheel — Число на вращающемся барабане с соседними значениями
  • Pin List — Список с закреплением: элементы плавно переезжают между группами
  • Notification Stack — Стопка уведомлений, раскрывающаяся в список
  • Todo List — Чек-лист с волнистым зачёркиванием выполненных пунктов
  • Presence Avatars — Кто онлайн: аватары перестраиваются при смене статуса
  • Radial Menu — Кольцевое контекстное меню по правому клику

Назад: Liquid Button · Далее: GitHub Stars Button · Весь раздел «Анимированные компоненты»