Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
React Native docs
ActionsReact Native

Toggle button

Turn one option on or off with a pressed-state button.

Public APILumenToggleButtonReact Native

Native example

Use Toggle button

Use it for formatting or view options. Use a toggle switch for settings.

Toggle button rendered in the Expo web renderer Lumen playground

Captured exampleExpo web renderer

Open interactive preview
Open the Toggle button demo
tsx
import { LumenToggleButton } from '@santi020k/lumen-react-native'
import { useState } from 'react'
import { View } from 'react-native'

export function FormattingToolbar() {
  const [italic, setItalic] = useState(false)
  const [underline, setUnderline] = useState(true)

  return (
    <View style={{ flexDirection: 'row', gap: 8 }}>
      <LumenToggleButton label="Italic" icon="italic" pressed={italic} onPressedChange={setItalic} />
      <LumenToggleButton
        label="Underline"
        icon="underline"
        iconOnly
        pressed={underline}
        onPressedChange={setUnderline}
      />
    </View>
  )
}
React Native
Two controlled formatting toggles, one with a visible label and one icon-only button that keeps its label as the accessible name.

Reference

Public API

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

APIValues or typeDefaultDescription
pressed / label / iconcontrolled state / name / leading iconrequired / required / noneUse it for formatting or view options.

Native behavior

Design and accessibility

When to use it

Use it for formatting or view options. Use a toggle switch for settings.

Accessibility

Exposes pressed state; icon-only buttons keep the label as their name.

Shared component

Available on other platforms

Apple / SwiftUIAndroid / Compose
React Native docsNative primitives