0

导入 Chakra UI 时出现此错误。

   
   if (variantColorIsDefined) {
      var variantColorExists = variantColor in theme.colors; // If variant color exists in theme object
       ^  114 | 
    if (!variantColorExists) {
      console.warn("You passed an invalid variantColor to the " + label + " Component. Variant color values must be a color key in the theme object that has '100' - '900' color values. Check http://chakra-ui.com/theme#colors to see possible values");
4

1 回答 1

0

从文档中这有点难以理解,变体颜色实际上是一组颜色。

在您的主题中,您需要定义一种颜色和相应的 :hover 值,例如:

yellow: {
  500: "#FFFF80",  //this is the default color
  600: "#FFFF00"   //this is the color on hover
},

然后你在你的组件中引用它,如下所示:

<IconButton size="sm" icon="unicorn" isRound variantColor="yellow" />
于 2020-11-01T14:07:43.440 回答