How to integrate tailwindcss use #3045
-
I'm going to use css in js, but don't want to write the style myself, and instead use the class name of tailwindcss directly |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Use Tailwind CSS classes: Now, you can use Tailwind CSS class names directly in your CSS-in-JS solution by applying the desired classes to your components.
In the above example, the tw template literal is a utility provided by Tailwind CSS that allows you to apply Tailwind CSS class names within the CSS-in-JS template string. By following these steps, you can leverage the power of Tailwind CSS utility classes without having to write the styles manually. |
Beta Was this translation helpful? Give feedback.
-
@Menthol2k Hello, is there documentation for tw template strings? |
Beta Was this translation helpful? Give feedback.
Install Tailwind CSS Start by installing Tailwind CSS in your project. You can use npm
npm install tailwindcss
Configure Tailwind CSS: After installing, you'll need to generate a Tailwind CSS configuration file.
npx tailwindcss init
Open the tailwind.config.js file and customize it according to your requirements. You can modify colors, spacing, breakpoints, and other aspects of the generated CSS classes.
Import Tailwind CSS: In your CSS-in-JS solution (such as styled-components, Emotion, or any other library), import the Tailwind CSS styles by adding the following line at the top of your file
import 'tailwindcss/tailwind.css';