惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

AstroPaper

AstroPaper 6.0 | AstroPaper AstroPaper 5.0 | AstroPaper How to add LaTeX Equations in Astro blog posts | AstroPaper How to integrate Giscus comments into AstroPaper | AstroPaper AstroPaper 4.0 | AstroPaper How to use Git Hooks to set Created and Modified Dates | AstroPaper AstroPaper 3.0 | AstroPaper How to update dependencies of AstroPaper | AstroPaper AstroPaper 2.0 | AstroPaper Dynamic OG image generation in AstroPaper blog posts | AstroPaper Predefined color schemes | AstroPaper Adding new posts in AstroPaper theme | AstroPaper How to configure AstroPaper theme | AstroPaper Tailwind Typography Plugin | AstroPaper How Do I Develop My Terminal Portfolio Website with React | AstroPaper How Do I Develop My Portfolio Website & Blog | AstroPaper
Customizing AstroPaper theme color schemes | AstroPaper
Sat Naing · 2022-09-25 · via AstroPaper

This guide covers how to enable or disable light and dark mode, and how to customize the color scheme for the entire site.

Table of contents

Open Table of contents
  • Enable/disable light & dark mode
  • Customize color schemes

Enable/disable light & dark mode

AstroPaper theme includes light and dark mode by default. This default behavior can be disabled in astro-paper.config.ts:

export default defineAstroPaperConfig({
  // ...
  features: {
    lightAndDarkMode: true,
    // ...
  },
});astro-paper.config.ts

To disable light & dark mode, set features.lightAndDarkMode to false. When disabled, the site will use only the light color scheme defined in src/styles/theme.css.

Customize color schemes

Both light and dark color schemes of AstroPaper theme are defined in src/styles/theme.css.

/* Light theme values */
:root,
[data-theme="light"] {
  --background: #fdfdfd;
  --foreground: #282728;
  --accent: #006cac;
  --accent-foreground: #ffffff;
  --muted: #e6e6e6;
  --muted-foreground: #6b7280;
  --border: #ece9e9;
}

/* Dark theme values */
[data-theme="dark"] {
  --background: #212737;
  --foreground: #eaedf3;
  --accent: #ff6b01;
  --accent-foreground: #ffffff;
  --muted: #343f60;
  --muted-foreground: #afb9ca;
  --border: #ab4b08;
}src/styles/theme.css

The :root and [data-theme="light"] selectors define the light color scheme, while [data-theme="dark"] defines the dark color scheme.

To customize your own color scheme, specify your light colors inside :root, [data-theme="light"], and your dark colors inside [data-theme="dark"].

Here is a detailed explanation of each color property:

Color PropertyDefinition & Usage
--backgroundPrimary color of the website. Usually the main background.
--foregroundSecondary color of the website. Usually the text color.
--accentAccent color. Used for links, hover states, and interactive elements.
--accent-foregroundForeground color displayed on top of --accent backgrounds.
--mutedMuted background color. Used for cards, tags, and hover states.
--muted-foregroundText color displayed on top of --muted backgrounds.
--borderBorder color. Used for dividers and visual separation.

Here is an example of changing the light color scheme:

/* ... */
:root,
[data-theme="light"] {
  --background: #f6eee1;
  --foreground: #012c56;
  --accent: #e14a39;
  --accent-foreground: #ffffff;
  --muted: #efd8b0;
  --muted-foreground: #6b7280;
  --border: #dc9891;
}
/* ... */src/styles/theme.css

Check out some predefined color schemes AstroPaper has already crafted for you.