-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Support plugin options in CSS #14264
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
Conversation
ae63a57
to
3a8dd7a
Compare
7175dca
to
c2479ee
Compare
Is this documented anywhere? |
@thecrypticace did this make it to 4.0 release? https://play.tailwindcss.com/zyTwDJniph?file=css |
@chasegiunta remove the |
Yep, it did. ☝️ What @saadeghi said, the |
@thecrypticace @saadeghi I'm an idiot. Thanks fellas! Semi-related, I was looking at this due to a breaking behavior on which layer the |
Builds on #14239 — that PR needs to be merged first.
This PR allows plugins defined with
plugin.withOptions
to receive options in CSS when using@plugin
as long as the options are simple key/value pairs.For example, the following is now valid and will include the forms plugin with only the base styles enabled:
We handle
null
,true
,false
, and numeric values as expected and will convert them to their JavaScript equivalents. Comma separated values are turned into arrays. All other values are converted to strings.For example, in the following plugin definition, the options that are passed to the plugin will be the correct types:
debug
will be the boolean valuetrue
threshold
will be the number0.5
message
will be the string"Hello world"
features
will be the array["base", "responsive"]
If you need to pass a number or boolean value as a string, you can do so by wrapping the value in quotes:
When duplicate options are encountered the last value wins:
It's important to note that this feature is only available for plugins defined with
plugin.withOptions
. If you try to pass options to a plugin that doesn't support them, you'll get an error message when building:Additionally, if you try to pass in more complex values like objects or selectors you'll get an error message: