Kinetik UI

Theme Switch

.md

A light and dark switch drawn as a sun whose rays turn and draw in while a shadow slides across to leave a moon.

v1.0.0Live on web@shopify/react-native-skiareact-native-reanimatedreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add theme-switch

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/theme-switch.json

Install manually

  1. Install dependencies
    npx expo install @shopify/react-native-skia react-native-reanimated react-native-worklets
  2. Copy the source files
    • components/kinetik/theme-switch.tsx
    View source files

Usage

import { ThemeSwitch } from '@/components/kinetik/theme-switch';

<ThemeSwitch value={scheme} onValueChange={setScheme} label="Dark mode" />;

// Pass the same value to the provider to switch the whole app:
<KinetikProvider scheme={scheme}>{app}</KinetikProvider>;

When to use

  • A settings row or a header button that switches the app between light and dark.
  • Anywhere a plain switch would need an extra icon to explain itself.

When not to use

  • Three choices (light, dark, follow the system). Use Glide Radio or a segmented control.
  • Settings unrelated to appearance. Use Pulse Toggle.

Notes

  • It is a switch for screen readers: "Dark mode", on or off. With label the words sit beside the icon and name it.
  • The icon is one small Skia canvas: the crescent is a circle cut out of the core in an offscreen layer.
  • With reduced motion the sun becomes the moon at once.

Props

ThemeSwitchProps

PropTypeDefaultDescription
valuerequiredThemeMode—
onValueChangerequired(value: ThemeMode) => void—
labelstring—Words beside the icon, e.g. "Dark mode". Leave out for an icon-only button.
accessibilityLabelstring'Dark mode'Read by screen readers when there is no visible label. Defaults to "Dark mode".
hapticsbooleantrueA tap as it switches. Defaults to true.
testIDstring—
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
A 28 pt Skia canvas driven by one shared value: two circles in a layer and one path of eight rays. Nothing runs at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 1.29× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 153 MB app memory. Steady 22 ms on this emulator for a small Skia canvas; the same run measured Reveal Field (also Skia) at 17 ms.

Real-device measurement pending.

Accessibility

Reduced motion
The icon changes at once.
Screen readers
A switch named "Dark mode" (or by its label) that is on in dark mode.
Touch target
48 by 48 pt, or the whole row with a label.

Source files

components/kinetik/theme-switch.tsx is in the Code tab of the preview above.