Using custom CSS utilities with tw`` doesn't work
See original GitHub issueI would like to define my own CSS classes using Tailwind utilities in my tailwind.css
file e.g. like this:
@tailwind base;
@tailwind components;
@tailwind utilities;
.py-responsive {
@apply py-4
}
@screen tablet {
.py-responsive {
@apply py-6
}
}
But this results to py-responsive was not found
error if used like this:
import tw from 'twin.macro';
import { css } from 'emotion/css';
const styles = css`
${tw`py-responsive`}
`
Have anyone managed to do something like this?
My stack:
- Next.js 9.4.4
- Tailwindcss: 1.4.6
- Twin.macro: 1.4.1
- Emotion: 10.0.27
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Tailwind CSS classes is not working in my project?
This error is due to tailwind not finding any classes to scan in what it 'thinks' is your HTML code directories.
Read more >Adding Custom Styles - Tailwind CSS
Best practices for adding your own custom styles to Tailwind. ... If you ever need to use a CSS property that Tailwind doesn't...
Read more >Tailwind CSS: What It Is, Why Use It & Examples - HubSpot Blog
You can use utility classes to control the layout, color, spacing, typography, shadows, and more to create a completely custom component design ...
Read more >Organize your CSS in the Tailwind style with @layer directive
Any custom styles you add to the base, components, or utilities layers will only be included in your compiled CSS if those styles...
Read more >Using Tailwind CSS - Maizzle
Simply write your HTML markup and use Tailwind CSS utility classes to style ... contains a sample custom utility class that Tailwind CSS...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I will close this issue since it is not actually an issue.
@wildfrontend yeah that is how I use it currently and you described the problem perfectly. It does spread the css design logic.
@ben-rogerson thanks for the clarification and options! Didn’t think about the latter one so that might be the way to go. Thanks for the help 👍