@capgo/capacitor-brightness

中文文档
8.0.24发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4.1万

Control screen brightness on iOS and Android

原始使用文档
文档目录24 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Capacitor Brightness?
  4. Documentation
  5. Compatibility
  6. Install
  7. Android Configuration
  8. Requirements
  9. API
  10. getBrightness()
  11. setBrightness(...)
  12. getSystemBrightness()
  13. setSystemBrightness(...)
  14. getSystemBrightnessMode()
  15. setSystemBrightnessMode(...)
  16. isUsingSystemBrightness()
  17. restoreSystemBrightness()
  18. isAvailable()
  19. checkPermissions()
  20. requestPermissions()
  21. getPluginVersion()
  22. Interfaces
  23. Type Aliases
  24. Enums

@capgo/capacitor-brightness

Read and set screen brightness from your Capacitor app, for example to brighten the screen while a QR code or ticket is shown. On Android you can also control system brightness and its automatic mode.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-brightness in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-brightness to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-brightness for Capacitor apps

Key features

  • App brightness: getBrightness() and setBrightness() for the current screen on iOS and Android.
  • System brightness: getSystemBrightness() and setSystemBrightness() on Android.
  • Brightness mode: getSystemBrightnessMode() and setSystemBrightnessMode() switch between automatic and manual on Android.
  • Restore: restoreSystemBrightness() hands control back to the system, isUsingSystemBrightness() checks the current state.
  • Permissions: checkPermissions() and requestPermissions() for Android system settings access.
  • Platforms: iOS and Android. System brightness and mode are Android only. Not available on web.

Why Capacitor Brightness?

The only Capacitor plugin providing complete brightness control for both iOS and Android:

  • App-level brightness - Control brightness for your activity without affecting system settings
  • System-level brightness - Modify the global device brightness (Android)
  • Auto/Manual mode - Switch between automatic and manual brightness modes (Android)
  • Permission handling - Built-in support for WRITE_SETTINGS permission flow
  • Cross-platform - Consistent API across iOS and Android

Essential for reading apps, video players, camera apps, and any app needing screen brightness control.

Documentation

Full documentation available at: https://capgo.app/docs/plugins/brightness/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-brightness` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-brightness
npx cap sync

Android Configuration

For Android, if you want to modify the system brightness (not just the app brightness), you need to add the WRITE_SETTINGS permission to your AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_SETTINGS" />

Note: This permission requires user confirmation through system settings on Android 6.0+.

Requirements

  • iOS: iOS 15+ (uses UIScreen.brightness)
  • Android: API 24+ (uses WindowManager for app brightness, Settings.System for system brightness)

API

getBrightness()

getBrightness() => Promise<GetBrightnessResult>

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

Returns: Promise<GetBrightnessResult>

Since: 8.0.0


setBrightness(...)

setBrightness(options: SetBrightnessOptions) => Promise<void>

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

On iOS, the brightness will persist until the device is locked. On Android, the brightness only applies to the current activity.

ParamTypeDescription
optionsSetBrightnessOptions- The brightness options.

Since: 8.0.0


getSystemBrightness()

getSystemBrightness() => Promise<GetBrightnessResult>

Get the system-wide screen brightness.

Returns: Promise<GetBrightnessResult>

Since: 8.0.0


setSystemBrightness(...)

setSystemBrightness(options: SetBrightnessOptions) => Promise<void>

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

ParamTypeDescription
optionsSetBrightnessOptions- The brightness options.

Since: 8.0.0


getSystemBrightnessMode()

getSystemBrightnessMode() => Promise<GetBrightnessModeResult>

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

Returns: Promise<GetBrightnessModeResult>

Since: 8.0.0


setSystemBrightnessMode(...)

setSystemBrightnessMode(options: SetBrightnessModeOptions) => Promise<void>

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

ParamTypeDescription
optionsSetBrightnessModeOptions- The brightness mode options.

Since: 8.0.0


isUsingSystemBrightness()

isUsingSystemBrightness() => Promise<IsUsingSystemBrightnessResult>

Check if the current activity is using the system-wide brightness value.

Returns: Promise<IsUsingSystemBrightnessResult>

Since: 8.0.0


restoreSystemBrightness()

restoreSystemBrightness() => Promise<void>

Reset the brightness setting of the current activity to use the system-wide value.

Since: 8.0.0


isAvailable()

isAvailable() => Promise<IsAvailableResult>

Check if the Brightness API is available on the current device.

Returns: Promise<IsAvailableResult>

Since: 8.0.0


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Check user's permissions for accessing system brightness.

Returns: Promise<PermissionStatus>

Since: 8.0.0


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Request permissions for accessing system brightness. On Android, this opens the system settings to grant WRITE_SETTINGS permission.

Returns: Promise<PermissionStatus>

Since: 8.0.0


getPluginVersion()

getPluginVersion() => Promise<GetPluginVersionResult>

Get the native plugin version.

Returns: Promise<GetPluginVersionResult>

Since: 8.0.0


Interfaces

GetBrightnessResult

Result of getBrightness or getSystemBrightness.

PropTypeDescriptionSince
brightnessnumberThe brightness value from 0 to 1. 0 is the minimum brightness, 1 is the maximum brightness.8.0.0

SetBrightnessOptions

Options for setBrightness or setSystemBrightness.

PropTypeDescriptionSince
brightnessnumberThe brightness value from 0 to 1. 0 is the minimum brightness, 1 is the maximum brightness.8.0.0

GetBrightnessModeResult

Result of getSystemBrightnessMode.

PropTypeDescriptionSince
modeBrightnessModeThe current brightness mode.8.0.0

SetBrightnessModeOptions

Options for setSystemBrightnessMode.

PropTypeDescriptionSince
modeBrightnessModeThe brightness mode to set. Cannot be set to UNKNOWN.8.0.0

IsUsingSystemBrightnessResult

Result of isUsingSystemBrightness.

PropTypeDescriptionSince
isUsingbooleanWhether the current activity is using the system-wide brightness value.8.0.0

IsAvailableResult

Result of isAvailable.

PropTypeDescriptionSince
availablebooleanWhether the Brightness API is available on the current device.8.0.0

PermissionStatus

Permission status result.

PropTypeDescriptionSince
brightnessPermissionStateWhether the permission to modify system brightness is granted.8.0.0

GetPluginVersionResult

Result of getPluginVersion.

PropTypeDescriptionSince
versionstringThe native plugin version.8.0.0

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

Enums

BrightnessMode

MembersValueDescriptionSince
UNKNOWN0The brightness mode is unknown.8.0.0
AUTOMATIC1The brightness is automatically adjusted by the system.8.0.0
MANUAL2The brightness is manually set by the user.8.0.0

版本与发布记录

@capgo/capacitor-brightness 共发布 24 个版本,首次发布于 2026/01/05;过去 12 个月发布了 24 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.0.24latest2026/10/1525 天前
8.0.232026/10/1327 天前
8.0.222026/10/091 个月前
8.0.212026/10/081 个月前
8.0.202026/09/161 个月前
8.0.192026/08/202 个月前

关于 @capgo/capacitor-brightness 的常见问题

@capgo/capacitor-brightness 是什么?

Control screen brightness on iOS and Android

如何安装 @capgo/capacitor-brightness?

在项目目录运行 npm install @capgo/capacitor-brightness,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-brightness 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-brightness 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-brightness 可以商用吗?

@capgo/capacitor-brightness 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-brightness 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-brightness 在 2026/10/09 – 2026/11/07 这 30 天内被下载 40,942 次,日均约 1,365 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-brightness 还在维护吗?

最新版本 8.0.24 发布于 2026/10/15(25 天前);至今共发布 24 个版本,其中过去 12 个月发布了 24 个;首次发布于 2026/01/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。