1# UI Appearance 2 3The **uiAppearance** module provides basic capabilities for managing the system appearance. It allows for color mode configuration currently, and will introduce more features over time. 4 5> **NOTE** 6> 7> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. 8> 9> The APIs provided by this module are system APIs. 10 11 12## Modules to Import 13 14```ts 15import uiAppearance from '@ohos.uiAppearance' 16``` 17 18 19## DarkMode 20 21Enumerates the color modes. 22 23 24**System capability**: SystemCapability.ArkUI.UiAppearance 25 26| Name| Value| Description| 27| -- | -- | -- | 28| ALWAYS_DARK | 0 | The system is always in dark mode. | 29| ALWAYS_LIGHT | 1 | The system is always in light mode.| 30 31 32## uiAppearance.setDarkMode 33 34setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void 35 36Sets the system color mode. This API uses an asynchronous callback to return the result. 37 38**Permission required**: ohos.permission.UPDATE_CONFIGURATION 39 40**System capability**: SystemCapability.ArkUI.UiAppearance 41 42**Parameters** 43| Name| Type| Mandatory| Description| 44| -- | -- | -- | -- | 45| mode | [DarkMode](#darkmode) | Yes| Color mode to set.| 46| callback | AsyncCallback\<void>| Yes| Callback used to return the result.| 47 48**Example** 49 ```ts 50uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (err) => { 51 console.info(`${err}`); 52}) 53 ``` 54 55 56## uiAppearance.setDarkMode 57 58setDarkMode(mode: DarkMode): Promise\<void>; 59 60Sets the system color mode. This API uses a promise to return the result. 61 62**Permission required**: ohos.permission.UPDATE_CONFIGURATION 63 64**System capability**: SystemCapability.ArkUI.UiAppearance 65 66**Parameters** 67| Name| Type| Mandatory| Description| 68| -- | -- | -- | -- | 69| mode | [DarkMode](#darkmode) | Yes| Color mode to set.| 70 71**Return value** 72 73| Type | Description | 74| ------ | ------------------------------ | 75| Promise\<void> | Promise that returns no value.| 76 77**Example** 78 ```ts 79uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => { 80 console.log('Set dark-mode successfully.'); 81}).catch((err) => { 82 console.log(`Set dark-mode failed, ${err}`); 83}); 84 ``` 85 86 87## uiAppearance.getDarkMode 88 89getDarkMode(): DarkMode; 90 91Obtains the system color mode. 92 93**Permission required**: ohos.permission.UPDATE_CONFIGURATION 94 95**System capability**: SystemCapability.ArkUI.UiAppearance 96 97**Return value** 98| Type| Description| 99| -- | -- | 100|[DarkMode](#darkmode) | Color mode obtained.| 101 102**Example** 103 ```ts 104let darkMode = uiAppearance.getDarkMode(); 105console.log(`Get dark-mode ${darkMode}`); 106 ``` 107