Comments (8)
Done
from twind.
Regarding this new (:global)[https://github.com/tw-in-js/twind/blob/main/docs/plugins.md#inject-global-styles] property, is it at all possible to declare global styles from within inline plugins? That would be a nifty way to allow declaration of global styles from virtually anywhere in your app.
Something like this should work:
tw(() => ({
':global': { /* global styles */ },
}))
tw(css({
':global': { /* global styles */ },
}))
With tw.apply
this should be possible:
tw(() => ({
':global': {
a: tw.apply`text-blue-500`
},
}))
tw(css({
':global': {
a: tw.apply`text-blue-500`
},
}))
from twind.
That honestly looks amazing but I am having no luck actually getting either of those to output anything at all...
tw(() => ({
':global': {
html: tw('bg-gray-900 text-white'),
},
}))
Meanwhile, the following does work...
tw(
css({
':global': {
html: {
backgroundColor: '#333',
},
},
})
)
And this...
tw(() => ({
':global': {
html: {
backgroundColor: '#333',
},
},
}))
And this...
tw(({ theme }) => ({
':global': {
html: {
backgroundColor: theme('colors.gray.900'),
},
},
}))
from twind.
Sorry. My bad. This depends on #85 and is not yet released. You could try the PR package. It's described in the PR
Edit: @tylerforesthauser I'll try to cut a release tomorrow. Could you please describe what you are trying to achieve and I'll add tests to verify the behavior before the release. Sorry. It's late here maybe you already did.
from twind.
Your first example (the one that does not work) can not work as tw always returns a string of class names. You'll need to use tw.apply for this which is not yet merged or released. See the component PR #83 and try PR package.
from twind.
No no it's all good. I've got the changes merged into my local repo and I'm using the package from there, so it includes your changes from #85 and the component-api
branch. The selector actually works! Just not for nested tw.apply
functions.
My end goal is to declare global styles (specifically on the html
element) from somewhere other than from preflight
.
I realize I entered my code incorrectly in my comment above but I, indeed, used tw.apply
.
So to clarify from my comment above, the following examples WORK:
tw(
css({
':global': {
html: {
backgroundColor: '#333',
},
},
})
)
tw(() => ({
':global': {
html: {
backgroundColor: '#333',
},
},
}))
tw(({ theme }) => ({
':global': {
html: {
backgroundColor: theme('colors.gray.900'),
},
},
}))
And these examples, however, DO NOT WORK.
tw(() => ({
':global': {
html: tw.apply('bg-gray-900 text-white'),
},
}))
tw(css({
':global': {
html: tw.apply('bg-gray-900 text-white'),
},
}))
from twind.
This should work in #83 (7b446c9)
from twind.
@tylerforesthauser This issue has two topics. Using tw.apply in :global
and in preflight should now be fixed in #83 . Preflight merging should be a new issue discussing its impact. Could you please create one only for merging preflight styles.
from twind.
Related Issues (20)
- [Bug]: apply hoists before preflight HOT 1
- [Bug]: Style is prepend, not append HOT 4
- [Docs]: Help wanted! HOT 15
- How to make cssom() inject at the end of the document? HOT 5
- [Bug]: It is not possible to specify the stop position of the gradient color HOT 1
- [Bug]: Twind Intellisense is not working when I create project using fresh HOT 2
- [Feature]:@twind/with-web-components support function components and/or existing element instances using withTwind HOT 1
- [Bug]: no w-fit HOT 1
- [Feature]: flex-shrink-* is deprecated HOT 1
- missing data HOT 1
- How to use tailwindcss plugins? HOT 3
- Is there a way to make tailwind-scrollbar plugin to work with twind? HOT 3
- [Bug]: keyframes added with injectGlobal only contain the last keyframe HOT 2
- [Bug]: Classes added with injectGlobal can't reference each other with @apply HOT 2
- [Bug]: Classes added with injectGlobal can't be used with variants HOT 2
- [Feature]: allow peer dep of typescript v5 HOT 2
- [Bug]: max-w-{number} does not work
- defineConfig / setup mixed up[Docs]:
- Template literals like className={tw`bg-green-${c}`}
- How to style host and slot elements with Lit HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twind.