search
HomeWeChat AppletMini Program DevelopmentWeChat Mini Program Dark Mode

WeChat Mini Program Dark Mode

Jul 04, 2020 am 09:27 AM
WeChat applet

1. Turn on dark mode

Configure "darkmode": true<pre class="brush:php;toolbar:false">// app.json {     ...     &quot;darkmode&quot;: true }</pre> in

app.json

2. Configure theme file

Create a new theme configuration file theme.json in the root directory, and configure the path in app.json to import

// app.json
{
    ...
    "themeLocation": "theme.json"
}

theme.json The configuration file is divided into two attributes, light and dark, which are normal mode and dark mode respectively.

theme.json The example is as follows (for reference only):

// theme.json
{
  "light": {
    "navBackgroundColor": "#ffffff",
    "navTextStyle": "black"
  },
  "dark": {
    "navBackgroundColor": "#000000",
    "navTextStyle": "white"
  }
}

must exist light and dark two attributes , the inner layer naming is customized and there are no strict requirements.

3. Apply configuration attributes in app.json

Splice the configuration attributes starting with @theme.json Write the custom name in the configuration, the example is as follows

// app.json
{
  ...
  "window": {
    "navigationBarBackgroundColor": "@navBackgroundColor",
    "navigationBarTitleText": "小书包大梦想",
    "navigationBarTextStyle": "@navTextStyle"
  },
  "darkmode": true,
  "themeLocation": "theme.json"
}

After the configuration is completed, and then the phone turns on the dark mode (dark mode), the applet will convert according to the color you configured.

4. wxss style adaptation to dark mode

wxss supports media query prefers-color-scheme to adapt to different themes.

The following style will make the page background gray-white in normal mode and black in dark mode.

/* 正常模式下应用的样式 */
page{
    background: #f1f1f1;
}
 
 
/* 暗黑模式下应用的样式 */
@media (prefers-color-scheme: dark) {
  page{
    background: #000000;
  }
}

5. Rendering

WeChat Mini Program Dark Mode

Recommended tutorial: "WeChat Mini Program"

The above is the detailed content of WeChat Mini Program Dark Mode. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:简书. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor