Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
React Native docs
ActionsReact Native

Theme toggle

Switch between the light and dark scheme with one round button.

Public APILumenThemeToggleReact Native

Native example

Use Theme toggle

The host owns the scheme and applies it. Use a segmented control when people also need a system option.

Theme toggle rendered in the Expo web renderer Lumen playground

Captured exampleExpo web renderer

Open interactive preview
Open the Theme toggle demo
tsx
import { useState } from 'react'
import { LumenProvider, LumenThemeToggle } from '@santi020k/lumen-react-native'

export const AppearanceSwitch = () => {
  const [scheme, setScheme] = useState<'dark' | 'light'>('light')

  return (
    <LumenProvider scheme={scheme}>
      <LumenThemeToggle onSchemeChange={setScheme} scheme={scheme} />
    </LumenProvider>
  )
}
React Native
A round button that asks the host to switch between the light and dark scheme.

Reference

Public API

The primary shared and platform-specific options exposed by LumenThemeToggle.

APIValues or typeDefaultDescription
scheme / onSchemeChange / labelcurrent scheme / change callback / accessible namerequired / required / Toggle color themeThe host owns the scheme and applies it.

Native behavior

Design and accessibility

When to use it

The host owns the scheme and applies it. Use a segmented control when people also need a system option.

Accessibility

Named Toggle color theme; the dark scheme reads as pressed.

Shared component

Available on other platforms

Apple / SwiftUIAndroid / Compose Web
React Native docsNative primitives