Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to override custom colors with built in color #2

Closed
garth opened this issue Dec 8, 2019 · 5 comments
Closed

Not possible to override custom colors with built in color #2

garth opened this issue Dec 8, 2019 · 5 comments

Comments

@garth
Copy link

garth commented Dec 8, 2019

When extending the tailwind colors and using one the the custom colors, it is not possible to override with a built in color. For example the following does not work.

      classNames(
        'dark:border-my-custom-color', // using a built in color works
        {
          'dark:border-red-500': !isValid, // this has no effect
        }
      )

The workaround is to remove 'dark:border-my-custom-color', but I would expect it to be possible to override both built in and extended colors with either built in or extended colors.

@javifm86
Copy link
Owner

move 'dark:border-my-custom-color', but I would expect it to be possible to override both built in and extended colors

Can you share your tailwind.config.js please?

@garth
Copy link
Author

garth commented Dec 10, 2019

module.exports = {
  theme: {
    transitionDuration: {
      default: '300ms',
      '0': '0ms',
      '100': '100ms',
      '200': '200ms',
      '300': '300ms',
    },
    transitionDelay: {
      default: '0ms',
      '0': '0ms',
      '100': '100ms',
      '200': '250ms',
      '300': '500ms',
    },
    extend: {
      colors: {
        app: {
          primary: '#22859b',
          'primary-dark': '#014e5e',
          secondary: '#fc7244',
          'secondary-dark': '#9e4629',
        },
      },
    },
  },
  variants: {
    backgroundColor: [
      'responsive',
      'first',
      'last',
      'odd',
      'even',
      'hover',
      'focus',
      'active',
      'disabled',
      'dark',
      'dark:odd',
      'dark:even',
      'dark:hover',
      'dark:focus',
      'dark:active',
      'dark:disabled',
    ],
    borderColor: [
      'responsive',
      'first',
      'last',
      'odd',
      'even',
      'hover',
      'focus',
      'active',
      'disabled',
      'dark',
      'dark:odd',
      'dark:even',
      'dark:hover',
      'dark:focus',
      'dark:active',
      'dark:disabled',
    ],
    textColor: [
      'responsive',
      'first',
      'last',
      'odd',
      'even',
      'hover',
      'focus',
      'active',
      'disabled',
      'dark',
      'dark:odd',
      'dark:even',
      'dark:hover',
      'dark:focus',
      'dark:active',
      'dark:disabled',
    ],
  },
  plugins: [require('tailwindcss-prefers-dark-mode')(), require('tailwindcss-transitions')()],
}

@javifm86
Copy link
Owner

I don´t understand exactly what are you trying to do. With your config colors, I am using this classes and everything is working as expected:
border-t-4 border-green-500 dark:border-app-secondary

By default border is default green-500, with user preference dark, border is app-secondary extended color ('#fc7244').

It is this behaviour which is not working for you? Perhaps you are trying to do something more advanced with Tailwind.

@garth
Copy link
Author

garth commented Dec 14, 2019

Thanks for looking into this. The problem occurs when you try to override an extended color with a build in one (I think you tried the other way around).

I think that it may be a bug in tailwind, the way that it implements extend. Since the workaround is so easy I don't think that it's worth spending more time on.

BTW: this plugin is working really well, thanks for taking the time to make and publish it!

@javifm86
Copy link
Owner

Ok, I suppose you can open an issue in TailwindCSS repo. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants