<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Jason's Blog]]></title><description><![CDATA[Jason's Blog]]></description><link>https://swartzrock.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1670393538010/vLtZwuPz_.png</url><title>Jason&apos;s Blog</title><link>https://swartzrock.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 31 Aug 2026 08:48:28 GMT</lastBuildDate><atom:link href="https://swartzrock.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Learning Tailwind CSS]]></title><description><![CDATA[The following are some personal notes I took when learning the tailwindcss framework. Their docs are comprehensive and easy to navigate, and really nice to read, so I recommend starting & ending with them as you learn the framework. These notes are h...]]></description><link>https://swartzrock.hashnode.dev/learning-tailwind-css</link><guid isPermaLink="true">https://swartzrock.hashnode.dev/learning-tailwind-css</guid><category><![CDATA[Tailwind CSS]]></category><category><![CDATA[CSS]]></category><category><![CDATA[reference]]></category><category><![CDATA[Frontend Development]]></category><dc:creator><![CDATA[Jason Swartz]]></dc:creator><pubDate>Wed, 07 Dec 2022 06:11:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1670432819951/AMU4_fkVc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The following are some personal notes I took when learning the <a target="_blank" href="https://tailwindcss.com/">tailwindcss</a> framework. Their docs are comprehensive and easy to navigate, and really nice to read, so I recommend starting &amp; ending with them as you learn the framework. These notes are high-level and do not include all of the Tailwind classes you can use (there are <em>sooo</em> many to learn), but do cover some of the most popular ones.</p>
<h2 id="heading-about-tailwind">About Tailwind</h2>
<h3 id="heading-utility-first-fundamentals">Utility-First Fundamentals</h3>
<ol>
<li><p>Style elements by adding existing classes to your elements, e.g. <code>p-5</code>, <code>mx-auto</code></p>
</li>
<li><p>Design your entire site w/o writing css styles</p>
</li>
<li><p>Want to reuse styles, e.g. <code>text-xs text-slate-600 uppercase font-bold tracking-wider</code>? Try putting these into a React component and reusing it.</p>
</li>
<li><p>If you are reusing styles on a page, try using a loop or map to avoid duplication</p>
</li>
</ol>
<h3 id="heading-tailwind-sizes">Tailwind Sizes</h3>
<ol>
<li><p>Most Tailwind sizes are in 0.25rem (where 1 rem = the pixel size of the root element's font size, often defaults to 16px).</p>
</li>
<li><p>E.g. <code>size 2 == 0.5rem</code>, <code>size 4 == 1rem</code>, <code>size 8 == 2rem</code></p>
</li>
</ol>
<h3 id="heading-custom-styles">Custom Styles</h3>
<ol>
<li>Customize Tailwind's default styles (e.g. colors and fonts) by adding them to your <code>tailwind.config.js</code> file. See the <a target="_blank" href="https://github.com/tailwindlabs/tailwindcss/blob/master/stubs/defaultConfig.stub.js">default configuration</a> or read more at <a target="_blank" href="https://tailwindcss.com/docs/adding-custom-styles">Adding Custom Styles</a>.</li>
</ol>
<h2 id="heading-tailwind-modifiers">Tailwind Modifiers (:)</h2>
<ol>
<li><p>Modify a class to target a condition with a pseudo <code>hover:, focus:, first-child:, required:, before:, etc</code></p>
</li>
<li><p>Modify a class to target a condition with a tailwind tag <code>visited:, focus-within:, dark:, etc.</code></p>
</li>
<li><p>Modify a class to require a min size <code>sm:, md:, lg:, xl:, 2xl:.</code> Or set a max size with <code>max-xl</code></p>
<ol>
<li><p><code>sm = element &gt;= 640px</code></p>
</li>
<li><p><code>md = element &gt;= 768px</code></p>
</li>
<li><p><code>lg = element &gt;= 1024px</code></p>
</li>
<li><p><code>xl = element &gt;= 1280px</code></p>
</li>
<li><p><code>2xl = element &gt;= 1536px</code></p>
</li>
</ol>
</li>
<li><p>Stack modifiers in sequence to combine them, e.g. <code>dark:hover:bg-sky-700</code></p>
</li>
<li><p>Modifiers are great for first/last padding, zebra, forms, parent state, sibling state (floating labels!), placeholder formatting, buttons, etc. See the <a target="_blank" href="https://tailwindcss.com/docs/hover-focus-and-other-states#quick-reference">quick reference</a> for all the modifiers</p>
</li>
</ol>
<h2 id="heading-layout-classes">Layout Classes</h2>
<h3 id="heading-display">Display</h3>
<p>These classes are shortcuts for the css <code>display: ???</code> classes, a core part of CSS layout which can magically transform ordinary elements (often <code>div</code>'s) into other elements.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>block</code></td><td>Sets a block element, starts on new line, takes up full width</td></tr>
<tr>
<td><code>contents</code></td><td>Sets the element to be replaced by its children</td></tr>
<tr>
<td><code>flex</code></td><td>Sets a flex container</td></tr>
<tr>
<td><code>grid</code></td><td>Sets a grid container</td></tr>
<tr>
<td><code>inline</code></td><td>Sets an inline element, height/width ignored</td></tr>
<tr>
<td><code>inline-block</code></td><td>Sets an inline element, height/width observed</td></tr>
<tr>
<td><code>inline-flex</code></td><td>Sets an inline flex container</td></tr>
<tr>
<td><code>inline-grid</code></td><td>Sets an inline grid container</td></tr>
<tr>
<td><code>inline-table</code></td><td>Sets an inline table</td></tr>
<tr>
<td><code>list-item</code></td><td>Sets a li element</td></tr>
<tr>
<td><code>none</code></td><td>Sets the element as essentially removed</td></tr>
<tr>
<td><code>table</code></td><td>Sets a table</td></tr>
<tr>
<td><code>table-???</code></td><td>Sets a table element, eg caption, thead, tr, etc.</td></tr>
</tbody>
</table>
</div><h3 id="heading-column-and-page-break">Column and Page Break</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Prefix</td><td>Where</td><td>What</td></tr>
</thead>
<tbody>
<tr>
<td><code>break</code></td><td><code>after</code></td><td><code>all</code></td></tr>
<tr>
<td></td><td><code>before</code></td><td><code>auto</code></td></tr>
<tr>
<td></td><td><code>inside</code></td><td><code>avoid</code></td></tr>
<tr>
<td></td><td></td><td><code>avoid-page</code></td></tr>
<tr>
<td></td><td></td><td><code>column</code></td></tr>
<tr>
<td></td><td></td><td><code>left</code></td></tr>
<tr>
<td></td><td></td><td><code>page</code></td></tr>
<tr>
<td></td><td></td><td><code>right</code></td></tr>
</tbody>
</table>
</div><h3 id="heading-all-other-layout-classes">All Other Layout Classes</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>aspect-[auto,square,video]</code></td><td>Set the aspect ratio</td></tr>
<tr>
<td><code>container</code></td><td>Sets taking up full width, uncentered</td></tr>
<tr>
<td><code>columns-#</code></td><td>Sets # of columns in element</td></tr>
<tr>
<td><code>box-decoration-[clone,slice]</code></td><td>Sets how element fragments (eg gradient) are rendered across items</td></tr>
<tr>
<td><code>box-[border,content]</code></td><td>Sets if borders &amp; padding are included when height/width are specified</td></tr>
<tr>
<td><code>[float,clear]-[right,left,none]</code></td><td>Controls wrapping content around an element</td></tr>
<tr>
<td><code>object-[...]</code></td><td>Sets how items fit and are positioned in their containers</td></tr>
<tr>
<td><code>overflow-[...]</code></td><td>Sets how items handle content that is too large</td></tr>
<tr>
<td><code>overscroll-[...]</code></td><td>Sets what the browser does at the edge of a scrollable area</td></tr>
<tr>
<td><code>[static,fixed,absolute,relative,sticky]</code></td><td>Sets how an item is positioned in the DOM</td></tr>
<tr>
<td><code>[left,top,right,bottom]-#</code></td><td>Set placement of positioned element in QuarterRem's</td></tr>
<tr>
<td><code>[inset-[x,y-]-#</code></td><td>Set the all/horiz/vert placement of positioned element in QuarterRem's</td></tr>
<tr>
<td><code>[visible,invisible,collapse]</code></td><td>Set the visibility of an item</td></tr>
<tr>
<td><code>z-#</code></td><td>Set the stack order (z-index) of an item</td></tr>
</tbody>
</table>
</div><h2 id="heading-spacing-classes">Spacing Classes</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Prefix</td><td>Direction</td><td>Values</td></tr>
</thead>
<tbody>
<tr>
<td><code>p- (padding)</code></td><td>t- (top)</td><td># QuarterRem's</td></tr>
<tr>
<td><code>m- (margin)</code></td><td>r- (right)</td><td>px (1px)</td></tr>
<tr>
<td><code>space-</code></td><td>b- (bottom)</td><td>auto</td></tr>
<tr>
<td></td><td>l- (left)</td><td></td></tr>
<tr>
<td></td><td>x- (horizontal)</td><td></td></tr>
<tr>
<td></td><td>y- (vertical)</td><td></td></tr>
<tr>
<td></td><td>'' (all 4 sides)</td></tr>
</tbody>
</table>
</div><p>For example, <code>p-px</code> sets 1px spacing on all sides and <code>space-x-2</code> sets 0.5rem spacing left and right.</p>
<h2 id="heading-sizing-classes-width-andamp-height">Sizing Classes: Width &amp; Height</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Prefix</td><td>Values</td></tr>
</thead>
<tbody>
<tr>
<td><code>w- (width)</code></td><td># QuarterRem's</td></tr>
<tr>
<td><code>h- (height)</code></td><td>px (1px)</td></tr>
</tbody>
</table>
</div><h2 id="heading-sizing-classes-minmax-width-andamp-height">Sizing Classes: Min/Max Width &amp; Height</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Prefix</td><td>Values</td></tr>
</thead>
<tbody>
<tr>
<td><code>min-[wh]-</code></td><td>0</td></tr>
<tr>
<td><code>max-[wh]-</code></td><td>full (100%)</td></tr>
<tr>
<td></td><td>min</td></tr>
<tr>
<td></td><td>max</td></tr>
<tr>
<td></td><td>fit</td></tr>
<tr>
<td></td><td>xs,sm,md,lg... (max-w only)</td></tr>
</tbody>
</table>
</div><h1 id="heading-flex-andamp-grid-classes">Flex &amp; Grid Classes</h1>
<h3 id="heading-flex-containers">Flex Containers</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>flex</code></td><td>Sets an element as a flex container</td></tr>
<tr>
<td><code>flex-[col,row][-reverse]</code></td><td>Set the direction of a flex container</td></tr>
<tr>
<td><code>flex-[nowrap,wrap][-reverse]</code></td><td>Set the flex container's wrap policy</td></tr>
</tbody>
</table>
</div><h3 id="heading-flex-items">Flex Items</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>basis-#</code></td><td>Set the initial size of a flex item (QR's or fraction of total)</td></tr>
<tr>
<td><code>flex-[col,row][-reverse]</code></td><td>Set the direction of a flex container</td></tr>
<tr>
<td><code>flex-[nowrap,wrap][-reverse]</code></td><td>Set the flex container's wrap policy</td></tr>
<tr>
<td><code>flex-[1,auto,initial,none]</code></td><td>Set the growth / shrink policy of a flex item</td></tr>
<tr>
<td><code>grow[-0]</code></td><td>Set the growth policy of a flex item</td></tr>
<tr>
<td><code>shrink[-0]</code></td><td>Set the shrink policy of a flex item</td></tr>
<tr>
<td><code>order-x</code></td><td>Set the order of a flex item in its container</td></tr>
</tbody>
</table>
</div><h3 id="heading-grid-containers">Grid Containers</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>grid</code></td><td>Sets an element as a grid container</td></tr>
<tr>
<td><code>grid-cols-#</code></td><td>Set the # of columns</td></tr>
<tr>
<td><code>grid-rows-#</code></td><td>Set the # of rows</td></tr>
<tr>
<td><code>grid-flow-[row,col,dense,row-dense,col-dense]</code></td><td>Set the auto placement strategy</td></tr>
<tr>
<td><code>auto-cols-[auto,min,max,fr]</code></td><td>Set the size of implicit columns</td></tr>
<tr>
<td><code>auto-rows-[auto,min,max,fr]</code></td><td>Set the size of implicit rows</td></tr>
</tbody>
</table>
</div><h3 id="heading-grid-items">Grid Items</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td><code>col-span-[#,full]</code></td><td>Set a grid item to span multiple columns</td></tr>
<tr>
<td><code>col-[start,end]-#</code></td><td>Set a grid item to start or end at the 1-based column</td></tr>
<tr>
<td><code>row-span-[#,full]</code></td><td>Set a grid item to span multiple rows</td></tr>
<tr>
<td><code>row-[start,end]-#</code></td><td>Set a grid item to start or end at the 1-based row</td></tr>
<tr>
<td><code>order-x</code></td><td>Set the order of a grid item in its container</td></tr>
</tbody>
</table>
</div><h3 id="heading-flex-andamp-grid-containers">Flex &amp; Grid Containers</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Value</td></tr>
</thead>
<tbody>
<tr>
<td><code>gap-[x,y-]#</code></td><td>Gap between items # QuarterRem's</td></tr>
<tr>
<td><code>justify-[around,between,center,evenly,end,start]</code></td><td>Justify items along main axis</td></tr>
<tr>
<td><code>justify-items-[center,end,start,stretch]</code></td><td>Justify item children</td></tr>
<tr>
<td><code>content-[around,baseline,between,center,evenly,end,start]</code></td><td>Align rows</td></tr>
<tr>
<td><code>items-[baseline,center,end,start,stretch]</code></td><td>Align items along cross-axis</td></tr>
<tr>
<td><code>pace-content-[around,baseline,between,center, end,evenly,start,stretch]</code></td><td>Justify and align</td></tr>
</tbody>
</table>
</div><h3 id="heading-flex-andamp-grid-items">Flex &amp; Grid Items</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Prefix</td><td>Value</td></tr>
</thead>
<tbody>
<tr>
<td><code>justify-[self-auto-center,end,start,stretch]</code></td><td>Align an item along its inline axis</td></tr>
<tr>
<td><code>self-[auto,baseline,center,end,start,stretch]</code></td><td>Align an item along its cross axis</td></tr>
</tbody>
</table>
</div><h1 id="heading-typography-classes">Typography Classes</h1>
<h2 id="heading-font">Font</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Value</td></tr>
</thead>
<tbody>
<tr>
<td><code>font-[serif,sans,mono]</code></td><td>Set the font family (configure in <code>tailwind.config.js</code>)</td></tr>
<tr>
<td><code>text-[xs,sm,base,lg,xl,#xl]</code></td><td>Set the font size (up to <code>9xl</code> )</td></tr>
<tr>
<td><code>[not-]italic</code></td><td>Italicize text</td></tr>
<tr>
<td><code>font-[thin,extralight,light,normal,medium, semibold,bold,extrabold,black]</code></td><td>Set the font weight</td></tr>
<tr>
<td><code>text-[inherit,current,transparent,black,white,(color)]</code></td><td>Set the text color (See the <a target="_blank" href="https://tailwindcss.com/docs/customizing-colors">official color chart</a>)</td></tr>
<tr>
<td><code>[underline,overline,line-through,no-underline]</code></td><td>Set the text decoration</td></tr>
<tr>
<td><code>decoration-[inherit,current,transparent,black,white,(color)]</code></td><td>Set the text decoration color</td></tr>
<tr>
<td><code>[uppercase,lowercase,capitalize,normal-case]</code></td><td>Set the text case</td></tr>
<tr>
<td><code>indent-[px,#]</code></td><td>Set the starting indent in QuarterRem's (or px for 1px)</td></tr>
<tr>
<td><code>align-[baseline,top,middle,bottom,text-top,text-bottom,sub,super]</code></td><td>Set the vertical text alignment</td></tr>
<tr>
<td><code>leading-#</code></td><td>Set the line height</td></tr>
<tr>
<td></td></tr>
</tbody>
</table>
</div><h2 id="heading-text-layout">Text Layout</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Value</td></tr>
</thead>
<tbody>
<tr>
<td><code>indent-[px,#]</code></td><td>Set the starting indent in QuarterRem's (or px for 1px)</td></tr>
<tr>
<td><code>align-[baseline,top,middle,bottom,text-top,text-bottom,sub,super]</code></td><td>Set the vertical text alignment</td></tr>
<tr>
<td><code>leading-#</code></td><td>Set the line height</td></tr>
<tr>
<td><code>whitespace-[normal,nowrap,pre,pre-line,pre-wrap]</code></td><td>Set the text wrapping policy</td></tr>
<tr>
<td><code>break-[normal,words,all,keep]</code></td><td>Set the word break policy</td></tr>
</tbody>
</table>
</div><h3 id="heading-lists">Lists</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Class</td><td>Value</td></tr>
</thead>
<tbody>
<tr>
<td><code>list-[none,disc,decimal]</code></td><td>Set the type of list (bullet vs number)</td></tr>
<tr>
<td><code>list-[inside,outside]</code></td><td>Set the indentation of a list</td></tr>
</tbody>
</table>
</div>]]></content:encoded></item></channel></rss>