@capacitor-community/screen-brightness

中文文档
8.0.0发布于 2025/12/26MITTypeScriptESM + CJS零依赖近 30 天下载 13.2万

control screen brightness on ios and android

原始使用文档
文档目录9 节
  1. Screen Brightness
  2. Versions
  3. Installation
  4. Configuration
  5. Usage
  6. API
  7. setBrightness(...)
  8. getBrightness()
  9. Interfaces


Screen Brightness

@capacitor-community/screen-brightness

Capacitor community plugin for controlling screen brightness on iOS and Android devices.


Versions

PluginCapacitorDocumentation
8.x8.xREADME
7.x7.xREADME
6.x6.xREADME
5.x5.xREADME
4.x4.xREADME
1.x3.xREADME

Installation

npm install @capacitor-community/screen-brightness
npx cap sync

Configuration

No configuration required for this plugin

Usage

import { ScreenBrightness } from '@capacitor-community/screen-brightness';

// Set the brightness:
const brightness = 0.5;
await ScreenBrightness.setBrightness({ brightness });

// Get the current brightness:
const {brightness: currentBrightness} = await ScreenBrightness.getBrightness();

API

setBrightness(...)

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

Sets the brightness level. On iOS, it sets the system level brightness, and on Android it sets the brightness for the current view.

ParamTypeDescription
optionsSetBrightnessOptionsOptions to set brightness

Since: 1.0.0


getBrightness()

getBrightness() => Promise<GetBrightnessReturnValue>

Returns info than contains the current brightness level

  • @since 1.0.0

Returns: Promise<GetBrightnessReturnValue>


Interfaces

SetBrightnessOptions

PropTypeDescriptionSince
brightnessnumberThe level to set the brightness to, from 0.0 (very dim) to 1.0 (full brightness) On Android, setting the value to -1 restores the user configured brightness.1.0.0

GetBrightnessReturnValue

PropTypeDescriptionSince
brightnessnumberThe current brightness level, from 0.0 (very dim) to 1.0 (full brightness) On Android it returns -1 if the value has not been changed by the app.1.0.0

版本与发布记录

@capacitor-community/screen-brightness 共发布 9 个版本,首次发布于 2021/02/25;过去 12 个月发布了 1 个版本。

版本发布日期距今
8.0.0latest2025/12/2610 个月前
7.0.02025/01/241.8 年前
6.0.02024/04/182 年前
5.0.02023/05/053 年前
4.0.02022/10/224 年前
2.0.0-0next2022/08/054 年前

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

@capacitor-community/screen-brightness 是什么?

control screen brightness on ios and android

如何安装 @capacitor-community/screen-brightness?

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

@capacitor-community/screen-brightness 支持 TypeScript 吗?

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

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

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

@capacitor-community/screen-brightness 可以商用吗?

@capacitor-community/screen-brightness 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@capacitor-community/screen-brightness 还在维护吗?

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