定制
主题
Chainlit 的主题基于 CSS 变量。
要修改 CSS 变量,请在 /public
目录下创建 theme.json
文件,内容如下。
您可以查阅 Shadcn 的文档 来了解每个变量的作用。
如果 UI 没有更新,请尝试清空浏览器缓存。
theme.json
{
"custom_fonts": [],
"variables": {
"light": {
"--font-sans": "'Inter', sans-serif",
"--font-mono": "source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace",
"--background": "0 0% 100%",
"--foreground": "0 0% 5%",
"--card": "0 0% 100%",
"--card-foreground": "0 0% 5%",
"--popover": "0 0% 100%",
"--popover-foreground": "0 0% 5%",
"--primary": "340 92% 52%",
"--primary-foreground": "0 0% 100%",
"--secondary": "210 40% 96.1%",
"--secondary-foreground": "222.2 47.4% 11.2%",
"--muted": "0 0% 90%",
"--muted-foreground": "0 0% 36%",
"--accent": "0 0% 95%",
"--accent-foreground": "222.2 47.4% 11.2%",
"--destructive": "0 84.2% 60.2%",
"--destructive-foreground": "210 40% 98%",
"--border": "0 0% 90%",
"--input": "0 0% 90%",
"--ring": "340 92% 52%",
"--radius": "0.75rem",
"--sidebar-background": "0 0% 98%",
"--sidebar-foreground": "240 5.3% 26.1%",
"--sidebar-primary": "240 5.9% 10%",
"--sidebar-primary-foreground": "0 0% 98%",
"--sidebar-accent": "240 4.8% 95.9%",
"--sidebar-accent-foreground": "240 5.9% 10%",
"--sidebar-border": "220 13% 91%",
"--sidebar-ring": "217.2 91.2% 59.8%"
},
"dark": {
"--font-sans": "'Inter', sans-serif",
"--font-mono": "source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace",
"--background": "0 0% 13%",
"--foreground": "0 0% 93%",
"--card": "0 0% 18%",
"--card-foreground": "210 40% 98%",
"--popover": "0 0% 18%",
"--popover-foreground": "210 40% 98%",
"--primary": "340 92% 52%",
"--primary-foreground": "0 0% 100%",
"--secondary": "0 0% 19%",
"--secondary-foreground": "210 40% 98%",
"--muted": "0 1% 26%",
"--muted-foreground": "0 0% 71%",
"--accent": "0 0% 26%",
"--accent-foreground": "210 40% 98%",
"--destructive": "0 62.8% 30.6%",
"--destructive-foreground": "210 40% 98%",
"--border": "0 1% 26%",
"--input": "0 1% 26%",
"--ring": "340 92% 52%",
"--sidebar-background": "0 0% 9%",
"--sidebar-foreground": "240 4.8% 95.9%",
"--sidebar-primary": "224.3 76.3% 48%",
"--sidebar-primary-foreground": "0 0% 100%",
"--sidebar-accent": "0 0% 13%",
"--sidebar-accent-foreground": "240 4.8% 95.9%",
"--sidebar-border": "240 3.7% 15.9%",
"--sidebar-ring": "217.2 91.2% 59.8%"
}
}
}
您可能已经注意到,颜色不是用十六进制表示,而是用 HSL 表示。这是强制要求。您可以轻松地 将任何颜色转换为 HSL。
custom_fonts
数组可以接收 URL(通常来自 Google Fonts),例如
custom_fonts: ["https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"]