配置网站的主题

由于我的网站只用 antd 组件,配置主题变得相当的容易。只要几行代码,就大变样,看不出来是 antd 做的。

<ConfigProvider
    locale={zhCN}
    theme={{
        algorithm: currentTheme === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm,
        token: {
            fontSize: 16,
            colorPrimary: '#2F54EB',
            borderRadius: 10,
        },
        components: {
            Button: {
                // We change: 0 2px 0 (Hard Edge) -> 0 0 4px (Soft Glow)
                primaryShadow: '0 0 4px rgba(5, 145, 255, 0.15)',
                dangerShadow: '0 0 4px rgba(255, 38, 5, 0.12)',
                defaultShadow: '0 0 4px rgba(0, 0, 0, 0.08)',
            },
        },
    }}
>
    <ThemeApp />
</ConfigProvider>

现在,拉垮的只剩下审美。因此我需要学习 shadcn/ui 的设计。

发表于 2026 年 1 月 23 日,星期五
更新于 2026 年 5 月 4 日,星期一