Skip to main content
@capgo/capacitor-brightness Device APIs Open source

Brightness Capacitor plugin

Control device screen brightness programmatically with support for app-specific and system-wide control

Install

bun add @capgo/capacitor-brightness bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-brightness
  • pnpm add @capgo/capacitor-brightness
  • yarn add @capgo/capacitor-brightness

Guide

How to use Brightness in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

Brightness plugin preview QR code

Using @capgo/capacitor-brightness

Control screen brightness on iOS and Android.

Install

bun add @capgo/capacitor-brightness
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { CapgoBrightness } from '@capgo/capacitor-brightness';

API at a glance

Method Description
getBrightness Get the current brightness level of the device's main screen.
setBrightness Set the brightness level of the device's main screen.
getSystemBrightness Get the system-wide screen brightness.
setSystemBrightness Set the system-wide screen brightness. Requires WRITE_SETTINGS permission on Android. This also changes the brightness mode to MANUAL.
getSystemBrightnessMode Get the current system brightness mode (automatic or manual). Requires WRITE_SETTINGS permission on Android.
setSystemBrightnessMode Set the system brightness mode (automatic or manual). Requires WRITE_SETTINGS permission on Android.
isUsingSystemBrightness Check if the current activity is using the system-wide brightness value.
restoreSystemBrightness Reset the brightness setting of the current activity to use the system-wide value.
isAvailable Check if the Brightness API is available on the current device.
checkPermissions Check user's permissions for accessing system brightness.
requestPermissions Request permissions for accessing system brightness. On Android, this opens the system settings to grant WRITE_SETTINGS permission.

Examples

getBrightness()

Get the current brightness level of the device's main screen.

import { CapgoBrightness } from '@capgo/capacitor-brightness';

const result = await CapgoBrightness.getBrightness();
console.log(result);

setBrightness()

Set the brightness level of the device's main screen.

import { CapgoBrightness } from '@capgo/capacitor-brightness';

await CapgoBrightness.setBrightness({ brightness: 0.5 });

getSystemBrightness()

Get the system-wide screen brightness.

import { CapgoBrightness } from '@capgo/capacitor-brightness';

const result = await CapgoBrightness.getSystemBrightness();
console.log(result);

setSystemBrightness()

Set the system-wide screen brightness. Requires WRITE_SETTINGS permission on Android. This also changes the brightness mode to MANUAL.

import { CapgoBrightness } from '@capgo/capacitor-brightness';

await CapgoBrightness.setSystemBrightness({ brightness: 0.5 });

getSystemBrightnessMode()

Get the current system brightness mode (automatic or manual). Requires WRITE_SETTINGS permission on Android.

import { CapgoBrightness } from '@capgo/capacitor-brightness';

const result = await CapgoBrightness.getSystemBrightnessMode();
console.log(result);

setSystemBrightnessMode()

Set the system brightness mode (automatic or manual). Requires WRITE_SETTINGS permission on Android.

import { CapgoBrightness, BrightnessMode } from '@capgo/capacitor-brightness';

await CapgoBrightness.setSystemBrightnessMode({ mode: BrightnessMode.AUTOMATIC });

The table above lists the 11 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.

Full reference

Keep going from Using @capgo/capacitor-brightness

If you are using Using @capgo/capacitor-brightness to plan native media and interface behavior, connect it with @capgo/capacitor-brightness for the implementation detail in @capgo/capacitor-brightness, Getting Started for the implementation detail in Getting Started, Using @capgo/capacitor-live-activities for the native capability in Using @capgo/capacitor-live-activities, @capgo/capacitor-live-activities for the implementation detail in @capgo/capacitor-live-activities, and Using @capgo/capacitor-video-player for the native capability in Using @capgo/capacitor-video-player.

FAQ

Brightness plugin FAQ

How do I install the Brightness plugin in a Capacitor app?

Run "bun add @capgo/capacitor-brightness" (or "npm install @capgo/capacitor-brightness"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-brightness" in your app code.

Does @capgo/capacitor-brightness work with React, Vue and Angular?

Yes. Brightness is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-brightness support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-brightness free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-brightness/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Brightness without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Brightness changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo