This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Expo Brightness iconExpo Brightness

A library that provides access to an API for getting and setting the screen brightness.

Android
iOS
Included in Expo Go
Recommended version:
~56.0.5

An API to get and set screen brightness.

On Android, there is a global system-wide brightness setting, and each app has its own brightness setting that can optionally override the global setting. It is possible to set either of these values with this API. On iOS, the system brightness setting cannot be changed programmatically; instead, any changes to the screen brightness will persist until the device is locked or powered off.

Installation

Terminal
- npx expo install expo-brightness
- yarn expo install expo-brightness
- pnpm expo install expo-brightness
- bun expo install expo-brightness

If you are installing this in an existing React Native app, make sure to install expo in your project.

Configuration

Are you using this library in an existing React Native app?

If you're not using Continuous Native Generation (CNG) or you're using a native android project manually, then you need to add the android.permission.WRITE_SETTINGS permission to the AndroidManifest.xml file:

android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_SETTINGS" />

Usage

Basic Brightness Usage
import { useEffect } from 'react'; import { StyleSheet, View, Text } from 'react-native'; import * as Brightness from 'expo-brightness'; export default function App() { useEffect(() => { (async () => { const { status } = await Brightness.requestPermissionsAsync(); if (status === 'granted') { Brightness.setSystemBrightnessAsync(1); } })(); }, []); return ( <View style={styles.container}> <Text>Brightness Module Example</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, });

API

import * as Brightness from 'expo-brightness';

No API data file found, sorry!

Error codes

ERR_BRIGHTNESS

An error occurred when getting or setting the app brightness.

ERR_BRIGHTNESS_MODE

An error occurred when getting or setting the system brightness mode. See the nativeError property of the thrown error for more information.

ERR_BRIGHTNESS_PERMISSIONS_DENIED

An attempt to set the system brightness was made without the proper permissions from the user. The user did not grant SYSTEM_BRIGHTNESS permissions.

ERR_BRIGHTNESS_SYSTEM

An error occurred when getting or setting the system brightness.

ERR_INVALID_ARGUMENT

An invalid argument was passed. Only BrightnessMode.MANUAL or BrightnessMode.AUTOMATIC are allowed.

Permissions

Android

You must add the following permissions to your app.json inside the expo.android.permissions array.

Android permissionDescription

WRITE_SETTINGS

Allows an application to read or write the system settings.

iOS

No permissions required.