question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using custom CSS utilities with tw`` doesn't work

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
vharvalacommented, Jun 23, 2020

I will close this issue since it is not actually an issue.

2reactions
vharvalacommented, Jun 23, 2020

@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 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found