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

No css variable fallback support. #26

Closed
mpalpha opened this issue Mar 22, 2022 · 2 comments
Closed

No css variable fallback support. #26

mpalpha opened this issue Mar 22, 2022 · 2 comments

Comments

@mpalpha
Copy link

mpalpha commented Mar 22, 2022

Versions:

  • Package Version: ?.?.?
  • Tailwindcss Version: ?.?.?

Description:

CSS variable fallback not supported.
e.g. https://developer.mozilla.org/en-US/docs/Web/CSS/var#syntax

Steps To Reproduce:

Try to use css fallbacks as per spec.

/* Fallback */
/* In the component's style: */
.component .header {
  color: var(--header-color, blue); /* header-color isn't set, and so remains blue, the fallback value */
}

.component .text {
  color: var(--text-color, black);
}

/* In the larger application's style: */
.component {
  --text-color: #080;
}
@mpalpha mpalpha added the bug Something isn't working label Mar 22, 2022
@mertasan mertasan added feature request In progress and removed bug Something isn't working labels Mar 22, 2022
@mpalpha
Copy link
Author

mpalpha commented Mar 22, 2022

Great plugin, but I can't use it currently due to this limitation.

@mertasan
Copy link
Owner

mertasan commented Mar 23, 2022

Hey Jason, thanks!

I made a few additions for Fallbacks. v2.2.0

You have to set the variables in the config file.

https://tailwindcss.com/docs/plugins#adding-components

Or you can use it like this:

// tailwind.config.js
...
theme: {
  colors: {
    blue: {
      400: 'var(--header-color, blue)',
    }
  },
  variables: {
    DEFAULT: {
      header: {
        color: '#0075ff',
      }
    }
  }
}
...
.component .header {
  @apply text-blue-400;
}

Please check this: ee42258

or
fallback.test.js
fallback.test.css
fallback.test.html

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

No branches or pull requests

2 participants