> For AI agents: the complete documentation index is available at https://rspress.rs/zh/llms.txt, the full documentation bundle is available at https://rspress.rs/zh/llms-full.txt.

# CSS 变量

Rspress 暴露了一些常用的 CSS 变量，[自定义主题](https://rspress.rs/zh/guide/basic/custom-theme.md) 中最简单也最易维护的方式。你可以在该页面实时编辑和预览，然后复制到你的项目中进行样式覆盖。覆盖方式见 [CSS 变量](https://rspress.rs/zh/guide/basic/custom-theme.md#css-variables)。

覆盖暗黑模式下的 CSS 变量时，`html.rp-dark` 和 `html.dark` 都可以作为暗黑模式选择器。

:::tip

可以使用本页面的 "复制 Markdown" 功能，让你的 AI Agent 帮你修改 CSS 变量。

:::

下面是 Rspress 提供的一些 CSS 变量及其默认值：

## 品牌色


Default

```css
/* Default Rspress brand colors */
:where(:root) {
  --rp-c-brand: #0095ff;
  --rp-c-brand-light: #33adff;
  --rp-c-brand-lighter: #c6e0fd;
  --rp-c-brand-dark: #0077ff;
  --rp-c-brand-darker: #005fcc;
  --rp-c-brand-tint: rgba(127, 163, 255, 0.16);
}

```

## 代码块 - Shiki 主题


DefaultGithub LightGithub DarkGithub Light High ContrastGithub Dark High ContrastLight PlusDark PlusOne LightOne Dark ProNordMaterial ThemeMaterial Theme DarkerMaterial Theme OceanVitesse LightVitesse DarkAndromeedaAyu Dark

```css
/* Light Mode */
:where(html:not(.rp-dark)) {
  --shiki-foreground: inherit; /* Priority higher than var(--rp-code-block-color); */
  --shiki-background: transparent; /* Priority higher than var(--rp-code-block-bg); */

  --shiki-token-constant: #1976d2;
  --shiki-token-string: #032f62;
  --shiki-token-comment: rgb(182, 180, 180);
  --shiki-token-keyword: #cf2727;
  --shiki-token-parameter: #f59403;
  --shiki-token-function: #7041c8;
  --shiki-token-string-expression: #218438;
  --shiki-token-punctuation: #242323;
  --shiki-token-link: #22863a;

  /* diff language */
  --shiki-token-deleted: #d32828;
  --shiki-token-inserted: #22863a;
}

/* Dark Mode */
:where(html.rp-dark) {
  --shiki-foreground: inherit; /* Priority higher than var(--rp-code-block-color); */
  --shiki-background: transparent; /* Priority higher than var(--rp-code-block-bg); */

  --shiki-token-constant: #6fb0fa;
  --shiki-token-string: #f9a86e;
  --shiki-token-comment: #6a727b;
  --shiki-token-keyword: #f47481;
  --shiki-token-parameter: #ff9800;
  --shiki-token-function: #ae8eeb;
  --shiki-token-string-expression: #4fb74d;
  --shiki-token-punctuation: #bbbbbb;
  --shiki-token-link: #f9a76d;

  /* diff language */
  --shiki-token-deleted: #ee6d7a;
  --shiki-token-inserted: #36c47f;
}

```

## 代码块 - 外层标题和容器


```css
/* Light Mode */
:where(html:not(.rp-dark)) {
  --rp-code-font-size: 0.875rem;
  --rp-code-title-bg: #f8f8f9;

  --rp-code-block-color: rgb(46, 52, 64);
  --rp-code-block-bg: var(--rp-c-bg);

  --rp-code-block-border: 1px solid var(--rp-c-divider-light);
  --rp-code-block-shadow: none;
}

/* Dark Mode */
:where(html.rp-dark) {
  --rp-code-font-size: 0.875rem;
  --rp-code-title-bg: #191919;

  --rp-code-block-color: rgb(229, 231, 235);
  --rp-code-block-bg: var(--rp-c-bg);

  --rp-code-block-border: 1px solid var(--rp-c-divider-light);
  --rp-code-block-shadow: none;
}

```

```tsx title="foo.ts"
console.log('This is a code block');
```

## 默认首页


```css
/* This is some variables used in HomeLayout. */
/* Light Mode */
:where(html:not(.rp-dark)) {
  --rp-home-hero-secondary-color: #a673ff;

  /* HomeHero */
  --rp-home-hero-title-color: transparent;
  --rp-home-hero-title-bg: linear-gradient(
    90deg,
    var(--rp-c-brand-dark) 0%,
    var(--rp-c-brand-dark) 30%,
    var(--rp-home-hero-secondary-color) 100%
  );

  /* HomeBackground */
  --rp-home-background-bg:
    radial-gradient(
      42.12% 56.13% at 100% 0%,
      rgba(83, 125, 255, 0.1) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    radial-gradient(
      42.01% 79.63% at 52.86% 0%,
      rgba(83, 125, 255, 0.2) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    radial-gradient(
      79.67% 58.09% at 0% 0%,
      rgba(126, 105, 255, 0.2) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    #fff;

  /* HomeFeature */
  --rp-home-feature-bg: linear-gradient(135deg, #fff, #f9f9f980);
}

/* Dark Mode */
:where(html.rp-dark) {
  --rp-home-hero-secondary-color: #a673ff;

  /* HomeHero */
  --rp-home-hero-title-color: transparent;
  --rp-home-hero-title-bg: linear-gradient(
    90deg,
    var(--rp-c-brand-dark) 0%,
    var(--rp-c-brand-dark) 30%,
    var(--rp-home-hero-secondary-color) 100%
  );

  /* HomeBackground */
  --rp-home-background-bg:
    radial-gradient(
      42.12% 56.13% at 100% 0%,
      #0c1d48 0%,
      rgba(18, 18, 18, 0) 100%
    ),
    radial-gradient(
      55.81% 87.78% at 48.37% 0%,
      #000000 0%,
      rgba(18, 18, 18, 0) 89.55%
    ),
    radial-gradient(
      122.65% 88.24% at 0% 0%,
      #34268a 0%,
      rgba(18, 18, 18, 0) 100%
    ),
    #121212;

  /* HomeFeature */
  --rp-home-feature-bg: linear-gradient(135deg, #ffffff00, #ffffff08);
}

```

## 基础变量


```css
/* Light Mode */
:where(html:not(.rp-dark)) {
  --rp-c-bg: #ffffff;
  --rp-c-bg-soft: #f8f8f9;
  --rp-c-bg-mute: #f1f1f1;
  --rp-c-bg-alt: #fff;

  --rp-c-divider: rgba(0, 0, 0, 0.25);
  --rp-c-divider-light: rgba(0, 0, 0, 0.12);

  --rp-c-text-0: #000000;
  --rp-c-text-1: #242424;
  --rp-c-text-2: rgba(0, 0, 0, 0.7);
  --rp-c-text-3: rgba(60, 60, 60, 0.33);
  --rp-c-text-4: rgba(60, 60, 60, 0.18);

  --rp-c-text-code: #476582; /* inline code */
  --rp-c-text-code-bg: rgba(153, 161, 179, 0.06); /* inline code bg */
  --rp-c-text-code-border: rgba(0, 0, 0, 0.035); /* inline code border */

  --rp-c-link: var(--rp-c-brand-dark);
}

/* Dark Mode */
:where(html.rp-dark) {
  --rp-c-bg: #121212;
  --rp-c-bg-soft: #292e37;
  --rp-c-bg-mute: #343a46;
  --rp-c-bg-alt: #000;

  --rp-c-divider: rgba(84, 84, 84, 0.65);
  --rp-c-divider-light: rgba(84, 84, 84, 0.48);

  --rp-c-text-0: #ffffff;
  --rp-c-text-1: rgba(255, 255, 245, 0.93);
  --rp-c-text-2: rgba(255, 255, 245, 0.65);
  --rp-c-text-3: rgba(235, 235, 235, 0.38);
  --rp-c-text-4: rgba(235, 235, 235, 0.18);

  --rp-c-text-code: #c9def1; /* inline code */
  --rp-c-text-code-bg: rgba(255, 255, 255, 0.06); /* inline code bg */
  --rp-c-text-code-border: rgba(255, 255, 255, 0.04); /* inline code border */

  --rp-c-link: var(--rp-c-brand-light);
}

:where(:root) {
  --rp-c-gray: #8e8e8e;
  --rp-c-gray-light-1: #aeaeae;
  --rp-c-gray-light-2: #c7c7c7;
  --rp-c-gray-light-3: #d1d1d1;
  --rp-c-gray-light-4: #e5e5e5;
  --rp-c-gray-light-5: #f2f2f2;

  --rp-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.02), 0 1px 0 rgba(0, 0, 0, 0.06);
  --rp-shadow-2: 0 3px 12px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.07);
  --rp-shadow-3: 0 12px 32px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.08);
  --rp-shadow-4: 0 14px 44px rgba(0, 0, 0, 0.12), 0 3px 9px rgba(0, 0, 0, 0.12);
  --rp-shadow-5:
    0 18px 56px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.16);

  --rp-radius: 1rem;
  --rp-radius-small: 0.5rem;
  --rp-radius-large: 1.5rem;
}

```
