<?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: Simon Conrad</title>
    <description>The latest articles on DEV Community by Simon Conrad (@slyskillet).</description>
    <link>https://dev.to/slyskillet</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%2F2357566%2F274ce52d-300d-4b19-92ec-fd647d2ec964.png</url>
      <title>DEV Community: Simon Conrad</title>
      <link>https://dev.to/slyskillet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/slyskillet"/>
    <language>en</language>
    <item>
      <title>Mobile first design with Tailwind CSS</title>
      <dc:creator>Simon Conrad</dc:creator>
      <pubDate>Fri, 14 Feb 2025 18:59:37 +0000</pubDate>
      <link>https://dev.to/slyskillet/mobile-first-design-with-tailwind-css-3phd</link>
      <guid>https://dev.to/slyskillet/mobile-first-design-with-tailwind-css-3phd</guid>
      <description>&lt;p&gt;Building UI was one of the first things to click for me in my web development journey. It’s a tricky, nit-picky business that requires a keen eye for detail. Early on, small UI bugs &lt;em&gt;really&lt;/em&gt; bothered me. I spent hours troubleshooting inconsistencies, which, in turn, deepened my understanding of CSS.&lt;/p&gt;

&lt;p&gt;Call me a glutton for punishment, but I &lt;em&gt;enjoy&lt;/em&gt; chasing down a good UI bug. The moment where everything clicks into place is incredibly satisfying.&lt;/p&gt;

&lt;p&gt;I first encountered Tailwind CSS while building my first production app for a client this summer. It’s a utility-first CSS framework that allows the developer to write styles directly into HTML tags as a class. This keeps styles and html structure contained in one place and allows for fast and intuitive development of responsive design.&lt;/p&gt;

&lt;p&gt;Tailwind CSS is loaded with features. I was particularly impressed by the ease of styling for various screen sizes by configuring breakpoints and using them to render specific styles.&lt;/p&gt;

&lt;p&gt;This tutorial will show my approach to styling a responsive layout for multiple screen sizes and walk through a simple example of creating a blog.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using this tutorial
&lt;/h2&gt;

&lt;p&gt;I present these concepts with code blocks, images and screen recordings. For your reference, the finished code can be found in &lt;a href="https://github.com/SlySkillet/simons-tailwind-demo" rel="noopener noreferrer"&gt;my tailwind demo repository (main branch)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you choose to, you may code alongside. Fork and clone the repository according to README instructions and checkout to the &lt;code&gt;starter&lt;/code&gt; branch by running &lt;code&gt;git checkout starter&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Instructions for forking and cloning the repository can be found in the README.&lt;/p&gt;

&lt;p&gt;This tutorial assumes familiarity with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic CSS and HTML concepts&lt;/li&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;li&gt;Tailwind CSS - if you are &lt;strong&gt;&lt;em&gt;completely new&lt;/em&gt;&lt;/strong&gt; to Tailwind’s functionality, I suggest spending a little bit of time with their &lt;a href="https://v2.tailwindcss.com/docs" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you are ready to build from scratch, configure your project according to the &lt;a href="https://v2.tailwindcss.com/docs/installation" rel="noopener noreferrer"&gt;Installation section&lt;/a&gt; of the docs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary of starter code and setup
&lt;/h2&gt;

&lt;p&gt;The focus of this tutorial is &lt;strong&gt;using Tailwind CSS to create a layout that works on multiple screen sizes and devices&lt;/strong&gt;, maintaining the same style and feel across all devices.&lt;/p&gt;

&lt;p&gt;I’m beginning with a mobile display already styled to demonstrate &lt;strong&gt;mobile first design&lt;/strong&gt;. This is a React app, a mobile-first blog layout with a simple structure.&lt;/p&gt;

&lt;p&gt;To follow along:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;first clone the code down according to instructions in the README&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;npm run dev&lt;/code&gt; to start the development server&lt;/li&gt;
&lt;li&gt;Open a tab in your browser (this tutorial will use Chrome) and navigate to &lt;code&gt;localhost:5173&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Enter dev tools with &lt;code&gt;Command + Option + I&lt;/code&gt; (Mac) or &lt;code&gt;Ctrl + Shift + I&lt;/code&gt; (Windows)and click the ‘toggle device toolbar’ icon. It’s in the top left corner.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkao83agu0s2vcj138sww.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkao83agu0s2vcj138sww.png" alt="https://res.cloudinary.com/ddgt67wcb/image/upload/v1739475690/blog/tailwind-css/Screenshot_2025-02-13_at_2.40.38_PM_wzxg7z.png" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select a mobile device eg. iPhone SE.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Welcome to… T*he Bacterium Blog - exploring the world of tiny titans.* Your source for fun facts in microbiology. It should look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74maa8kuuey9tmx48ehl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74maa8kuuey9tmx48ehl.png" alt="https://res.cloudinary.com/ddgt67wcb/image/upload/v1739476040/blog/tailwind-css/Screenshot_2025-02-13_at_2.46.41_PM_rbue8t.png" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The page consists of 3 main components written in &lt;code&gt;src/App.tsx&lt;/code&gt; and a 4th ‘Blog Post’ component found in the components directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nav - a fixed navigation bar with a hamburger menu icon&lt;/li&gt;
&lt;li&gt;Header - a banner section featuring a circular blog logo (the beautiful pink and purple bacterium)&lt;/li&gt;
&lt;li&gt;BlogFeed - the container for blog posts which are written as a component in &lt;code&gt;src/components/BlogPost.tsx&lt;/code&gt; and given content in &lt;code&gt;src/components/BlogPosts.tsx&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before we proceed any further, &lt;strong&gt;let me illustrate the problem I am trying to solve here.&lt;/strong&gt; As is, my UI fits nicely on a small screen, but as the window grows to fill larger and larger screens, it starts to look clunky and stupid. That’s bad. I don’t want that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi81gm3ki0y51fbq6kr22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi81gm3ki0y51fbq6kr22.png" alt="https://res.cloudinary.com/ddgt67wcb/image/upload/v1739371604/blog/tailwind-css/Screenshot_2025-02-11_at_8.30.04_AM_jogaix.png" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With my simple, one column mobile display as a starting point, I can proceed to creating a dynamic layout. My priorities are to&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make the banner fill the space on larger screens by applying styles with Tailwind’s breakpoints&lt;/li&gt;
&lt;li&gt;Use CSS grid to make the blog feed a readable column of information&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Mobile first design and breakpoints
&lt;/h2&gt;

&lt;p&gt;The core concept of my approach to responsive design is Tailwind’s breakpoints. By default, un-prefixed styles will render on all screen sizes while styles prefixed with &lt;code&gt;sm:&lt;/code&gt;, &lt;code&gt;md:&lt;/code&gt; , &lt;code&gt;lg:&lt;/code&gt; etc. will only take effect on screens &lt;em&gt;larger than the specified breakpoint.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For this reason, in developing the UI with Tailwind, it’s best to &lt;em&gt;begin by developing the mobile styles.&lt;/em&gt; As the design expands to larger screens, we can progressively add enhancements and layout adjustments where needed.&lt;/p&gt;

&lt;p&gt;These are the default Tailwind breakpoints that can be customized if desired. I generally choose to work with the defaults.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// tailwind.config.js&lt;/span&gt;
&lt;span class="kr"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;screens&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="s1"&gt;sm&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="s1"&gt;640px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="c1"&gt;// =&amp;gt; @media (min-width: 640px) { ... }&lt;/span&gt;

      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;md&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="s1"&gt;768px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="c1"&gt;// =&amp;gt; @media (min-width: 768px) { ... }&lt;/span&gt;

      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lg&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="s1"&gt;1024px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="c1"&gt;// =&amp;gt; @media (min-width: 1024px) { ... }&lt;/span&gt;

      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;xl&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="s1"&gt;1280px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="c1"&gt;// =&amp;gt; @media (min-width: 1280px) { ... }&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;Using the Tailwind defaults, a screen larger than 640px wide will render the styles prefixed with &lt;code&gt;sm:&lt;/code&gt;. It’s important to note that those styles will apply to any screen greater than that size unless another breakpoint is used.&lt;/p&gt;

&lt;p&gt;For example, if I give the banner a background color of ‘blue’ by default, and change it to red at the small breakpoint with &lt;code&gt;sm:bg-red-400&lt;/code&gt; it will render as red for screens of 640px &lt;em&gt;and greater.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Header&lt;/span&gt; &lt;span class="o"&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"bg-blue-300 text-lg grid pt-14 pb-5 sm:bg-red-400"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Header html here */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;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;




  
  Your browser does not support the video tag.


&lt;p&gt;Let’s say I give a green background at the xl breakpoint. Now, on mobile, the banner will be blue, on screens between 640px and 1280px, it will be red, and screens 1280px and above will render green.&lt;/p&gt;

&lt;p&gt;So the code now looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Header&lt;/span&gt; &lt;span class="o"&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"bg-blue-300 text-lg grid pt-14 pb-5 sm:bg-red-400 xl:bg-green-400"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Header html here */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;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;And the resulting styles appear like this:&lt;/p&gt;


  
  Your browser does not support the video tag.


&lt;blockquote&gt;
&lt;p&gt;This step was to demonstrate the behavior of breakpoints, but it’s also a valuable trick for designing and debugging. I use background colors like this all the time to visualize how breakpoints are behaving.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With this understanding of breakpoints, I’ll make adjustments to the Header component so it fills the space nicely on larger screens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Styling the Header component
&lt;/h2&gt;

&lt;p&gt;Currently, my header is a stack of 3 elements&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a div containing my ‘bacterium graphic’&lt;/li&gt;
&lt;li&gt;an h1 containing the blog title&lt;/li&gt;
&lt;li&gt;an h5 containing my blog subtitle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To fill the space better, I’m going to add some CSS grid styles to the &lt;code&gt;sm:&lt;/code&gt; breakpoint to adjust how the Header is laid out.&lt;/p&gt;

&lt;p&gt;Instead of a stack, I’ll create a 2 x 3 grid (2 columns, 3 rows) where my graphic occupies the entire first column, spanning 3 rows and my title and subtitle occupy rows 2 and 3 of the second column respectively.&lt;/p&gt;

&lt;p&gt;To do that, I first add &lt;code&gt;sm:row-span-3 sm:col-start-1&lt;/code&gt; to the className of the div containing my graphic. I add &lt;code&gt;sm:row-start-2 sm:col-start-2&lt;/code&gt; to my h1 tag holding my title and &lt;code&gt;sm:row-start-3 sm:col-start-2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On a small screen, I now have a banner that looks like this (with dev-tools grid-lines for reference):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn0g2xghxhaqdbm97h1et.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn0g2xghxhaqdbm97h1et.png" alt="https://res.cloudinary.com/ddgt67wcb/image/upload/v1739371603/blog/tailwind-css/Screenshot_2025-02-11_at_10.43.37_AM_w89drf.png" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s more or less what I’m going for, but I want it a little more snug. Using ‘justify’ I’ll bring all my items to hug the column line 2 for a snug layout. My graphic gets &lt;code&gt;sm:justify-end&lt;/code&gt; and my ‘h’ tags get &lt;code&gt;sm:justify-start&lt;/code&gt;. I’ll give my graphic a little boost in size while I’m at it.&lt;/p&gt;

&lt;p&gt;Using tailwinds built in text-sizing, I can make it pretty big with &lt;code&gt;text-9xl&lt;/code&gt; but that’s the limit. I want to be even a little bigger, so I’ll pass in a custom size, like this &lt;code&gt;text-[10rem]&lt;/code&gt; . I’ll give my headers a little boost in size too so my header fills its container nicely.&lt;/p&gt;

&lt;p&gt;One last thing, I’ll add some extra padding to the top and bottom of the parent container for the header like this &lt;code&gt;py-20&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My small screen page now looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frj7k69i0644yuaxhvaxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frj7k69i0644yuaxhvaxp.png" alt="https://res.cloudinary.com/ddgt67wcb/image/upload/v1739371604/blog/tailwind-css/Screenshot_2025-02-11_at_11.09.36_AM_ndfvso.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’m feeling better already about publishing my favorite microbe facts to the internet. Here is the current state of my code. Now would be a good time to commit and push my changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Header&lt;/span&gt; &lt;span class="o"&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"bg-gray-300 text-lg grid pt-14 pb-5 sm:py-20"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex justify-center sm:justify-end m-4 sm:row-span-3 sm:col-start-1"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"border rounded-full bg-pink-200"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FaBacterium&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text-8xl sm:text-[10rem] text-gray-700 translate-x-2 translate-y-[-3px]"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex justify-center sm:justify-start font-cursive text-5xl sm:text-6xl sm:row-start-2 sm:col-start-2"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        The Bacterium Blog
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h5&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex justify-center sm:justify-start italic text-md sm:text-lg sm:row-start-3 sm:col-start-2"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Exploring the World of Tiny Titans
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h5&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;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;blockquote&gt;
&lt;p&gt;Something interesting to note here is that I never had to define how many grid columns and rows I wanted in my parent container. They were auto generated when I specified the row and column I wanted to place my items.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Full screen styles
&lt;/h2&gt;

&lt;p&gt;Now I need to think about how I want this to look on a full screen desktop. I want to create a centered column to contain the BlogFeed column so it’s more readable. I’ll apply the same breakpoints and css grid concepts as before.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the BlogFeed column
&lt;/h3&gt;

&lt;p&gt;I want to create a grid with 4 columns for my large screen and position a container for my blog posts inside of that. I start by making the container a grid by adding &lt;code&gt;grid&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;I want small screens to be a column that fills the whole page, so I’ll define columns with the &lt;code&gt;lg:&lt;/code&gt; breakpoint. I want space to the left and right so I’ll create 4 columns with &lt;code&gt;lg:grid-cols-4&lt;/code&gt; and place my container with &lt;code&gt;lg:col-start-2 lg:col-span-2&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;This looks quite a bit better on the full screen window on my 13in macbook now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzitp7kps8zth7obd3rvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzitp7kps8zth7obd3rvk.png" alt="https://res.cloudinary.com/ddgt67wcb/image/upload/v1739371606/blog/tailwind-css/Screenshot_2025-02-11_at_12.30.22_PM_whdvj9.png" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My blog posts are a nice, readable column down the middle of the page and I’ve created space to the left and right for a table of contents, calls to action, announcements, whatever needs I may have for my Bacterium Blog as I scale it.&lt;/p&gt;

&lt;p&gt;Here’s what the code looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;BlogFeed&lt;/span&gt; &lt;span class="o"&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"bg-gray-50 font-serif text-lg p-2 pt-4 grid lg:grid-cols-4"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"lg:col-start-2 lg:col-span-2"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Post1&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Post2&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Post3&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;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;h3&gt;
  
  
  Final touches
&lt;/h3&gt;

&lt;p&gt;This is much better, but I think a little cramped on the midsize screens. To finish things off, I’m going to create a slightly better progression from medium to full screen.&lt;/p&gt;

&lt;p&gt;For medium screens, there are no columns and there don’t need to be. I’m just going to add some padding to give it a similar effect. I add &lt;code&gt;md:px-10&lt;/code&gt; to give padding on the x-axis (padding-left and padding-right).&lt;/p&gt;

&lt;p&gt;Keeping that same padding, I’ll make my large screen text column just a little wider so it’s not so cramped. I’ll try this out: &lt;code&gt;lg:col-start-1 lg:col-span-3&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;I liked my previous styles for the full screen view, so I’ll keep them and switch the breakpoint to &lt;code&gt;xl:&lt;/code&gt; like this &lt;code&gt;xl:col-start-2 xl:col-span-2&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;BlogFeed&lt;/span&gt; &lt;span class="o"&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"bg-gray-50 font-serif text-lg p-2 pt-4 grid lg:grid-cols-4"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"md:px-10 lg:col-start-1 lg:col-span-3 xl:col-start-2 xl:col-span-2"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Post1&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Post2&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Post3&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;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;The last thing I’ll do is make my Header grow bigger as the window size increases. I’ll add the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;lg:text-[13rem] xl:text-[14rem]&lt;/code&gt; to my bacterium graphic container&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lg:text-7xl xl:text-9xl&lt;/code&gt; to my h1 tag&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lg:text-xl xl:text-2xl&lt;/code&gt; to my h5 subtitle and&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lg:py-24 xl:py-28&lt;/code&gt; to my grid container to give it some extra padding
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Header&lt;/span&gt; &lt;span class="o"&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"bg-gray-300 text-lg grid pt-14 pb-5 sm:py-20 lg:py-24 xl:py-28"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex justify-center sm:justify-end m-4 sm:row-span-3 sm:col-start-1"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"border rounded-full bg-pink-200"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FaBacterium&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text-8xl sm:text-[10rem] lg:text-[13rem] xl:text-[14rem] text-gray-700 translate-x-2 translate-y-[-3px]"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex justify-center sm:justify-start font-cursive text-5xl sm:text-6xl lg:text-7xl xl:text-9xl sm:row-start-2 sm:col-start-2"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        The Bacterium Blog
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h5&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex justify-center sm:justify-start italic text-md sm:text-lg sm:row-start-3 sm:col-start-2 lg:text-xl xl:text-2xl "&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Exploring the World of Tiny Titans
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h5&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;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;So, my new and improved &lt;em&gt;Bacterium Blog&lt;/em&gt; responsive UI now looks like this:&lt;/p&gt;


  
  Your browser does not support the video tag.


&lt;h2&gt;
  
  
  Conclusion &amp;amp; next steps
&lt;/h2&gt;

&lt;p&gt;I hope this was an informative tour of Tailwind’s breakpoints! You’ve now seen the foundation of my UI development strategy. This was a simple, quirky example, but the principles of responsive design apply to the most complex layouts. Breaking a design into components and placing them on a grid clarifies the vision and brings everything into alignment. This process can be done in neat iterations with Tailwind’s breakpoints and mobile-first approach.&lt;/p&gt;

&lt;p&gt;I have found Tailwind to be a powerful tool for developing responsive layouts. It was a game changer for me and I highly recommend putting in the time to learn it.&lt;/p&gt;

&lt;p&gt;The best way to grow as a designer is to stay inspired, imagine interesting components and bring them to life.&lt;/p&gt;

&lt;p&gt;Happy coding friends - as always, have fun building and be easy on yourself and others&lt;/p&gt;

&lt;h3&gt;
  
  
  Some final notes:
&lt;/h3&gt;

&lt;p&gt;Tailwind classes can be used in tandem with a css stylesheet if, for example, I wanted to use the breakpoints for defining grid placement, but not font colors and formatting.&lt;/p&gt;




&lt;p&gt;Other useful features to explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dark mode implementation&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;hidden&lt;/code&gt; to conditionally render elements depending on screen size&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Their documentation is excellent. Here it is one more time: &lt;a href="https://v2.tailwindcss.com/docs" rel="noopener noreferrer"&gt;tailwind docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tailwindcss</category>
      <category>design</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
