<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Plain Sailing with Tailwind</title>
    <description>The latest articles on DEV Community by Plain Sailing with Tailwind (@plainsailing).</description>
    <link>https://dev.to/plainsailing</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1016783%2F59bfc550-e1af-47e6-974c-c401b40898c5.jpg</url>
      <title>DEV Community: Plain Sailing with Tailwind</title>
      <link>https://dev.to/plainsailing</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/plainsailing"/>
    <language>en</language>
    <item>
      <title>Getting started with Tailwind v4</title>
      <dc:creator>Plain Sailing with Tailwind</dc:creator>
      <pubDate>Tue, 04 Mar 2025 15:12:21 +0000</pubDate>
      <link>https://dev.to/plainsailing/getting-started-with-tailwind-v4-3cip</link>
      <guid>https://dev.to/plainsailing/getting-started-with-tailwind-v4-3cip</guid>
      <description>&lt;p&gt;Tailwind v4 is here, and with it come a few fundamental changes. This guide will hopefully demystify installing and using Tailwind v4.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing
&lt;/h2&gt;

&lt;p&gt;First off, you need to install Tailwind. How you do that will depend on whether or not you're using a framework, and if so, what framework it is.&lt;/p&gt;

&lt;h3&gt;
  
  
  Frameworks
&lt;/h3&gt;

&lt;p&gt;If you're using a framework like Next, Nuxt, Sveltekit, Solid, and so on, then the Tailwind docs probably have a dedicated guide for you:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/docs/installation/framework-guides" rel="noopener noreferrer"&gt;https://tailwindcss.com/docs/installation/framework-guides&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're using something like React or Vue without a framework (ie Next or Nuxt), then your best approach is to use Vite. First scaffold a new Vite project with your JS framework of choice:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://vite.dev/guide/#scaffolding-your-first-vite-project" rel="noopener noreferrer"&gt;https://vite.dev/guide/#scaffolding-your-first-vite-project&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then follow the Tailwind docs for Vite integration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/docs/installation/using-vite" rel="noopener noreferrer"&gt;https://tailwindcss.com/docs/installation/using-vite&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If for some reason you want to use PostCSS, you should use Vite to scaffold your new project, then follow the PostCSS installation docs:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/docs/installation/using-postcss" rel="noopener noreferrer"&gt;https://tailwindcss.com/docs/installation/using-postcss&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  No framework, just static HTML
&lt;/h3&gt;

&lt;p&gt;Firstly, if you're developing static HTML websites the old fashioned way, I would highly, &lt;em&gt;highly&lt;/em&gt; recommend switching to &lt;a href="https://astro.build/" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; now and joining us in the 21st Century. It's an excellent framework, produces no JS that you don't add yourself, and also makes using Tailwind properly much more viable.&lt;/p&gt;

&lt;p&gt;If you just want to try Tailwind out with static files, then this is how to do it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make a new folder for your project, eg &lt;code&gt;twtest&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In that folder, in a terminal, initiate a new npm project with &lt;code&gt;npm init -y&lt;/code&gt;. You can skip this step if you're using &lt;code&gt;pnpm&lt;/code&gt;, which you should be.&lt;/li&gt;
&lt;li&gt;Run

&lt;code&gt;npm install tailwindcss @tailwindcss/cli&lt;/code&gt;

.&lt;/li&gt;
&lt;li&gt;Create a new &lt;code&gt;index.html&lt;/code&gt; and &lt;code&gt;input.css&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;In &lt;code&gt;input.css&lt;/code&gt; enter

&lt;code&gt;@import tailwindcss;&lt;/code&gt;

and save.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your HTML file, add your HTML boilerplate (! in Vs Code), and then add the link to an output CSS file (which you haven't created, yet): e.g.&lt;br&gt;
&lt;br&gt;
&lt;code&gt;html&amp;lt;link href="./output.css" rel="stylesheet"&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your terminal, run&lt;br&gt;
&lt;br&gt;
&lt;code&gt;npx @tailwindcss/cli -i ./input.css -o ./output.css --watch&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add some test Tailwind to your HTML, e.g.&lt;br&gt;
&lt;br&gt;
&lt;code&gt;html&amp;lt;h1 class="text-4xl font-bold text-red-500"&amp;gt;Hello World!&amp;lt;/h1&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Open your HTML file in a browser and you should see a big, red Hello World!&lt;/p&gt;

&lt;h3&gt;
  
  
  Customising your theme
&lt;/h3&gt;

&lt;p&gt;The major user-facing change in Tailwind v4 is that there is no longer a &lt;code&gt;tailwind.config.js&lt;/code&gt; file with which to configure your theme and any other customisations. If you're following a video tutorial somewhere and they go to &lt;code&gt;tailwind.config.js&lt;/code&gt;, that tutorial is now out of date.&lt;/p&gt;

&lt;p&gt;Instead, all customisation is done in your CSS file (e.g. &lt;code&gt;app.css&lt;/code&gt;, &lt;code&gt;input.css&lt;/code&gt;, &lt;code&gt;global.css&lt;/code&gt;, or whatever CSS file has &lt;code&gt;@import "tailwindcss";&lt;/code&gt; in it. Customisation is done mainly via CSS variables.&lt;/p&gt;

&lt;p&gt;For example, to add a new colour, you would do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"tailwindcss"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;@theme&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--color-brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#b4d455&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would make that colour available to any utility that uses colours, ie &lt;code&gt;bg-brand&lt;/code&gt;, &lt;code&gt;text-brand&lt;/code&gt;, and so on. The Tailwind docs have a complete guide to theme customisation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/docs/theme" rel="noopener noreferrer"&gt;https://tailwindcss.com/docs/theme&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  FAQs
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;My CSS file has squiggly lines and warnings, why?&lt;/em&gt;&lt;br&gt;
This is purely a VS Code issue - it thinks you're using CSS, when in fact you're using &lt;em&gt;special&lt;/em&gt; CSS, with custom directives. Install the official Tailwind extension, and then set your file language to TailwindCSS, and the squiggly lines will be banished.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Where's the content array?&lt;/em&gt;&lt;br&gt;
V3 used a content array to find the files where Tailwind was being used. V4 has done away with this and now uses several clever methods to find your files automagically. For the most part this works well, however if you need to explicitly point Tailwind to a folder you can do so with the &lt;code&gt;@source&lt;/code&gt; directive e.g.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@source&lt;/span&gt; &lt;span class="s1"&gt;"./src/components/"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Where's the safelist function?&lt;/em&gt;&lt;br&gt;
There isn't one, at least not 'built in' as it was in V3. Instead, you can simply add a file (e.g. &lt;code&gt;safelist.txt&lt;/code&gt;) and add any classes you want to build in that file. Tailwind's automatic content detection will pick them up.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Where's the blocklist function?&lt;/em&gt;&lt;br&gt;
Again, there isn't one. However, Tailwind's content detection makes use of the &lt;code&gt;.gitignore&lt;/code&gt; file to help it ignore content, so you can just add your paths to the .gitignore file to prevent them being scanned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;This is a basic guide so I won't go into much further depth. 99% of questions can be answered with a simple search on the Tailwind Docs site at &lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;tailwindcss.com&lt;/a&gt;. If you can't find the answers there, hop on to the &lt;a href="https://discord.gg/qAY5jz93" rel="noopener noreferrer"&gt;Tailwind Discord&lt;/a&gt; and we'll do our best to help.&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>Stacking elements with Tailwind CSS</title>
      <dc:creator>Plain Sailing with Tailwind</dc:creator>
      <pubDate>Wed, 24 May 2023 08:44:40 +0000</pubDate>
      <link>https://dev.to/plainsailing/stacking-elements-with-tailwind-css-4ngc</link>
      <guid>https://dev.to/plainsailing/stacking-elements-with-tailwind-css-4ngc</guid>
      <description>&lt;p&gt;Stacking elements on top of each other is a common pattern that we all use regularly. There are two main approaches to achieving this with Tailwind CSS. We'll use a typical hero section layout with a background, a gradient layer, and some text as an example.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Absolute positioning
&lt;/h2&gt;

&lt;p&gt;Absolute positioning is the 'traditional' way to stack elements. It's very flexible, but can be a pain to make responsive, and centering elements can feel a little hacky.&lt;/p&gt;

&lt;p&gt;Let's start with our background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"h-screen bg-slate-500 relative"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We make this our relative parent simply by adding the &lt;code&gt;relative&lt;/code&gt; class.&lt;/p&gt;

&lt;p&gt;Now let's add our gradient:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"h-screen bg-slate-500 relative"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-gradient-to-t from-slate-800 to-transparent absolute inset-0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will give us a dark gradient effect from the bottom. We position it absolutely to fill the container using &lt;code&gt;absolute inset-0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now for the text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"h-screen bg-slate-500 relative"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-gradient-to-t from-slate-800 to-transparent absolute inset-0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-6xl text-white font-bold absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Tailwind CSS&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the text styling, we give our text &lt;code&gt;absolute&lt;/code&gt; to position it absolutely, then position it halfway in on both the X and Y axes with &lt;code&gt;left-1/2 top-1/2&lt;/code&gt;. However, since the origin point for the text is the top left corner, this results in the text appearing off-center. To remedy this, we use &lt;code&gt;-translate-x-1/2 -translate-y-1/2&lt;/code&gt; to move the text left and up by half its own width and height.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://play.tailwindcss.com/tMzD48IObS"&gt;Here it is in action&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a long walk for a short glass of water. Luckily, with the advent of CSS Grid, we have a more elegant solution...&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Stacking elements with Grid
&lt;/h2&gt;

&lt;p&gt;As well as making... grids, CSS Grid also allows us to stack grid elements on top of each other. The properties that allow this, &lt;code&gt;grid-template-areas&lt;/code&gt; and &lt;code&gt;grid-area&lt;/code&gt; don't have utility classes in TailwindCSS, but that's not a problem thanks to v3's arbitrary classes feature.&lt;/p&gt;

&lt;p&gt;Let's define our container again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"h-screen bg-slate-500 grid place-items-center [grid-template-areas:'stack']"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we set up a grid container with &lt;code&gt;grid&lt;/code&gt;. &lt;code&gt;place-items-center&lt;/code&gt; will ensure our text is automatically dead center on the screen without any translate shenanigans. The real magic is in our arbitrary class &lt;code&gt;[grid-template-areas:'stack']&lt;/code&gt;. This sets up a single grid area called &lt;code&gt;stack&lt;/code&gt; - you can call this whatever you like.&lt;/p&gt;

&lt;p&gt;Now we can add our gradient:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"h-screen bg-slate-500 grid place-items-center [grid-template-areas:'stack']"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"h-screen w-full bg-gradient-to-t from-slate-800 to-transparent [grid-area:stack]"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we use another arbitrary class to tell the browser that this element belongs to the &lt;code&gt;stack&lt;/code&gt; grid area defined in the parent.&lt;/p&gt;

&lt;p&gt;And now for the text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"h-screen bg-slate-500 grid place-items-center [grid-template-areas:'stack']"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"h-screen w-full bg-gradient-to-t from-slate-800 to-transparent [grid-area:stack]"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-6xl font-bold text-white [grid-area:stack]"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Tailwind CSS&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This element in particular is much cleaner - all we need to center it is the same arbitrary class as the gradient. &lt;code&gt;place-items-center&lt;/code&gt; on the parent takes care of the rest!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://play.tailwindcss.com/KXabnq3Ykq"&gt;Here it is in action&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>Tailwind CSS not working? It's probably this...</title>
      <dc:creator>Plain Sailing with Tailwind</dc:creator>
      <pubDate>Sun, 12 Feb 2023 17:19:51 +0000</pubDate>
      <link>https://dev.to/plainsailing/tailwind-css-not-working-its-probably-this-9m4</link>
      <guid>https://dev.to/plainsailing/tailwind-css-not-working-its-probably-this-9m4</guid>
      <description>&lt;p&gt;TailwindCSS is an amazing CSS utility library. It's pretty straightforward to set up, but there are a few common problems that arise from basic errors. Styles aren't applying. Styles were applying but don't anymore. Only some styles are applying. The solutions are almost always the same, so if you're finding that Tailwind just flat out doesn't seem to be working, here's what to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  NB - This guide is for Tailwind v3. Tailwind is now on v4 and has several fundamental changes that render many of the issues below obsolete. Check which version you're using before attempting to apply the solutions here.
&lt;/h3&gt;

&lt;h2&gt;
  
  
  1. Check you've added the Tailwind directives to the CSS file
&lt;/h2&gt;

&lt;p&gt;Whatever framework you're using (or even if you're not using one at all), your main CSS file needs to have the three basic Tailwind directives in place. Simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In some IDEs you might find that you get warnings for the these statements. This is simply because they are not valid CSS - they instead work with PostCSS. You can safely ignore the warnings, or if you're one of those people that just hates wiggly lines, set the file type in your IDE to PostCSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Check you're importing or linking your CSS file
&lt;/h2&gt;

&lt;p&gt;Once your directives are in place, make sure you're actually linking to or importing the relevant CSS file into your project, e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"styles.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../css/globals.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The telltale for this issue is your page having no styling - for example, Tailwind resets the &lt;code&gt;font-family&lt;/code&gt; to &lt;code&gt;sans-serif&lt;/code&gt;, so if you're seeing Times New Roman, you're not linking your CSS file correctly.&lt;/p&gt;

&lt;p&gt;If you're using the CLI, it's worth noting that the file names and paths used as examples in the Tailwind docs are just that - &lt;em&gt;examples&lt;/em&gt;. You aren't required to use &lt;code&gt;/src/input.css&lt;/code&gt; and &lt;code&gt;/dist/output.css&lt;/code&gt; - all you need is an input CSS file with the three &lt;code&gt;@tailwind&lt;/code&gt; directives, and an output CSS file where Tailwind will build the classes you use to. &lt;strong&gt;They can be called anything and be placed anywhere in your file structure&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Make sure your content array is correct
&lt;/h2&gt;

&lt;p&gt;Tailwind works by scanning your files for recognised class names and patterns and then including them in the CSS file. The files it scans are defined in the &lt;code&gt;content&lt;/code&gt; array in &lt;code&gt;tailwind.config.js&lt;/code&gt;. If this is pointing to the wrong place, Tailwind won't pick up any classes.&lt;/p&gt;

&lt;p&gt;A telltale that this is the problem is that the Tailwind default styles are applying (e.g. your text is sans-serif and you have no default page padding), but the Tailwind classes you're adding in your markup aren't applying.&lt;/p&gt;

&lt;p&gt;Sometimes, you might find that Tailwind &lt;em&gt;has&lt;/em&gt; been working, but now you're in a different file and only a few classes are working. What happens in this situation is that classes you have used in other files are already built in, and so if you use them in your new file, they will apply, but new classes won't.&lt;/p&gt;

&lt;p&gt;An example &lt;code&gt;content&lt;/code&gt; array for a Next.js project looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app/**/*.{js,ts,jsx,tsx}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/**/*.{js,ts,jsx,tsx}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./components/**/*.{js,ts,jsx,tsx}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="c1"&gt;// Or if using `src` directory:&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/**/*.{js,ts,jsx,tsx}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This checks the &lt;code&gt;app&lt;/code&gt;,&lt;code&gt;pages&lt;/code&gt;, &lt;code&gt;components&lt;/code&gt;, and &lt;code&gt;src&lt;/code&gt; folders, plus any subfolders (denoted by the &lt;code&gt;**&lt;/code&gt;) for any file with the js,ts,jsx, or tsx extensions containing classes recognised by Tailwind. If you create a folder outside this range, Tailwind won't scan it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Check your build process is running
&lt;/h2&gt;

&lt;p&gt;Tailwind needs to scan your markup and rebuild the CSS &lt;em&gt;every time you change it&lt;/em&gt;. You'd be surprised at how many times people forget this fact. So, check your dev server is running if you're using a framework, or if you're using the CLI, be sure to run the build command with the &lt;code&gt;--watch&lt;/code&gt; flag so the CSS will automatically rebuild.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tailwindcss &lt;span class="nt"&gt;-i&lt;/span&gt; src/input.css &lt;span class="nt"&gt;-o&lt;/span&gt; dist/output.css &lt;span class="nt"&gt;--watch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Check you're not concatenating class strings
&lt;/h2&gt;

&lt;p&gt;Tailwind works by scanning the files defined in your content array &lt;em&gt;at build time&lt;/em&gt;. Because of this, you can't use concatenated class names, e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`bg-&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;bgColor&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule of thumb is, if you can't do a text search in your IDE to find the class name, it won't work with Tailwind.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://tailwindcss.com/docs/content-configuration#dynamic-class-names" rel="noopener noreferrer"&gt;Tailwind Docs&lt;/a&gt; have several strategies you can use to get around this.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Check you're not overriding the defaults
&lt;/h2&gt;

&lt;p&gt;The Tailwind config allows you to add custom fonts, colours, and other  things to your setup. Crucially, there is a slight difference in how this is done if you want to retain access to Tailwind's defaults. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#b4d455&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will &lt;em&gt;override&lt;/em&gt; all the standard Tailwind colours, even black and white. Instead, use an &lt;code&gt;extend&lt;/code&gt; object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#b4d455&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will &lt;em&gt;add&lt;/em&gt; the custom colour to the theme, leaving you access to all the defaults. The example uses colours, but it applies to any custom value you add to your config.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;These steps will fix 95% of Tailwind problems. If you're still having trouble, feel free to &lt;a href="https://discord.com/invite/7NF8GNe" rel="noopener noreferrer"&gt;join us in the Discord&lt;/a&gt; and we'll be happy to help you out.&lt;/p&gt;

</description>
      <category>career</category>
      <category>motivation</category>
    </item>
  </channel>
</rss>
