Skip to content

yarn build color lost after customizing color #13501

Answered by alex-krasikau
qianmoQ asked this question in Help
Discussion options

You must be logged in to vote

Hello @qianmoQ!

Tailwind CSS doesn't support dynamic values such as bg-[${computedType}]. In order to add the class to the generated CSS, Tailwind CSS needs to see the full string in your source code like bg-[#409EFF]. To fix this, you can utilize CSS custom variables. Here's an updated example:

<Button 
  :style="{
    '--button-bg': computedType,
    '--button-bg-hover': calculateHoverColor(computedType)
  }"
  :class="cn(
    computedSize,
    "bg-[--button-bg] hover:bg-[--button-bg-hover]",
    { 'rounded-full': round },
    { 'rounded-full': circle }
  )"
  :size="circle ? 'icon' : 'default'"
>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@qianmoQ
Comment options

Answer selected by qianmoQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants