DEV Community

Cover image for Remix - Styled with TailwindCSS 3.0 ๐Ÿšจ
Fathy
Fathy

Posted on โ€ข Edited on

4 2

Remix - Styled with TailwindCSS 3.0 ๐Ÿšจ

Remix App ๐Ÿ‘‹

I'm going to be using the default create-remix@latest command which sets up our project and gives us a demo site.

TailwindCSS Setup with Remix

Open your terminal and let's install tailwindcss, its peer dependencies, and concurrently via npm or yarn

npm install -D tailwindcss postcss autoprefixer concurrently
or if you prefer yarn
yarn add -D tailwindcss postcss autoprefixer concurrently
Enter fullscreen mode Exit fullscreen mode

and then run the init command to generate both tailwind.config.js and postcss.config.js.

npx tailwindcss init -p
Enter fullscreen mode Exit fullscreen mode

Let's update our tailwind.config.js file, Add the paths to all of your template files in your tailwind.config.js file.

module.exports = {
  content: [
    "./app/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
Enter fullscreen mode Exit fullscreen mode

now we need to update your package.json scripts

{
  "scripts": {
    "build": "npm run build:css && remix build",
    "build:css": "tailwindcss -m -i ./styles/app.css -o app/styles/app.css",
    "dev": "concurrently \"npm run dev:css\" \"remix dev\"",
    "dev:css": "tailwindcss -w -i ./styles/app.css -o app/styles/app.css",
  }
}
Enter fullscreen mode Exit fullscreen mode

Tailwind styles

We need to Add the Tailwind directives to your CSS.
Create a ./styles/app.css file and add the @tailwind directives for each of Tailwindโ€™s layers.

@tailwind base;
@tailwind components;
@tailwind utilities;
Enter fullscreen mode Exit fullscreen mode

now we need Add a reference of the generated CSS files using links in ./app/root.jsx file.

import styles from "./styles/app.css"

export function links() {
  return [{ rel: "stylesheet", href: styles }]
}
Enter fullscreen mode Exit fullscreen mode

TailwindCSS is all setup in our Remix app.
Now when we run npm run dev it will generate a tailwind.css file in the root of our /app/ folder

npm run dev
Enter fullscreen mode Exit fullscreen mode

Start using Tailwind in your project ๐Ÿฅณ
Start using Tailwindโ€™s utility classes to style your content.

export default function home() {
  return (
    <h1 className="text-3xl font-bold ">
      Remix + Tailwindcss 
    </h1>
  )
}
Enter fullscreen mode Exit fullscreen mode

Well done! ๐Ÿ‘
Read original post Click

Thanks for reading! Say Hallo! Twitter

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay