You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js+Chakra UI中button.ts样式类型错误及解决方法

Chakra UI v2.4.9 Button主题baseStyle类型错误解决

在使用Next.js、TypeScript和Chakra UI开发项目时,按钮主题文件button.ts中baseStyle对象内的borderRadius、color、border属性出现类型错误:

Type 'string' is not assignable to type 'SystemStyleObject | undefined'

相关代码如下:

import { ComponentMultiStyleConfig } from "@chakra-ui/theme";

export const Button: ComponentMultiStyleConfig = {
    baseStyle: {
        borderRadius: "60px",
        color: "brand.100",
        border: "2px solid red",
    },
};

该错误导致样式无法同步到主文件,最终找到解决方案:在Chakra UI v2.4.9版本中,需使用useMultiStyleConfig替代ComponentMultiStyleConfig,替换后问题已解决。

内容的提问来源于stack exchange,提问作者Sahil Halbe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 16:12:45