Sun and Moon Toggle

UI ElementsData BindingIn a set
Live
Tap to switch

Dark and light mode. The moon spins away and the sun pops in, its rays turning slowly.

Get the file

This one comes with the Toggle Icon Set: all 10 icons, the .riv and the .rev of each.

The whole set

.rev + .riv

All 10 files in one zip. Open the .rev in the Rive editor and change anything, or use the .riv as it is.

Use it on your site

import { useRive } from '@rive-app/react-canvas';

export function ToggleSunMoon() {
  const { rive, RiveComponent } = useRive({
    src: '/toggle-theme.riv',
    artboard: 'Toggle Sun Moon',
    stateMachines: 'State Machine',
    autoplay: true,
    autoBind: true,
  });

  // every input on this page is a view model property
  const vm = rive?.viewModelInstance;
  if (vm) vm.color('onColor').value = 0xFFFC800C;

  return <RiveComponent style={{ width: '100%', height: 400 }} />;
}

Inputs: on, onColor, offColor, outline. All on the ToggleTheme view model.

Also in the Toggle Icon Set

More ui elements

See all →