@capacitor-community/screen-brightness

control screen brightness on ios and android

Usage no npm install needed!

<script type="module">
  import capacitorCommunityScreenBrightness from 'https://cdn.skypack.dev/@capacitor-community/screen-brightness';
</script>

README


Screen Brightness

@capacitor-community/screen-brightness

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


Maintainers

Maintainer GitHub Social
Ely Lucas elylucas @elylucas

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 halfBright = 0.5;
await ScreenBrightness.setBrightness({ halfBright });

// Get the current brightness:
const {brigthness: 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.

Param Type Description
options SetBrightnessOptions Options 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

Prop Type Description Since
brightness number The level to set the brightness to, from 0.0 (very dim) to 1.0 (full brightness) 1.0.0

GetBrightnessReturnValue

Prop Type Description Since
brightness number The current brightness level, from 0.0 (very dim) to 1.0 (full brightness) 1.0.0