TailwindCSS
A 19y/o self-learned ethical hacker, mainly interested in bug hunting, malware analysis, and digital forensics. Currently expertise in SEO, OSINT, ethical hacking, WordPress, Shopify, front-end web.
The concept of Preflight
Preflight is a set of base styles for Tailwind projects that are designed to smooth over cross-browser inconsistencies and make it easier for you to work within the constraints of your design system.
When we import tailwindcss into our project, it gets auto applied.
Margins are removed - Preflight removes all of the default margins from all elements including headings, blockquotes, paragraphs, etc.
Border styles are reset - In order to make it easy to add a border by simply adding the
borderclass, Tailwind overrides the default border styles for all elements.Headings are unstyled - All heading elements are completely unstyled by default, and have the same font size and weight as normal text. It helps you avoid accidentally deviating from your type scale. In UI development, headings should often be visually de-emphasized.
Lists are unstyled - Ordered and unordered lists are unstyled by default, with no bullets or numbers.
Images are block-level - Images and other replaced elements (like
svg,video,canvas, and others) aredisplay: blockby default.Images are constrained - Images and videos are constrained to the parent width in a way that preserves their intrinsic aspect ratio. This prevents them from overflowing their containers and makes them responsive by default.
You can extend, modify or disable preflight as per your need. Read documentation for more.
Layout
Aspect-ratio - for controlling the aspect ratio of an element.
aspect-ratio = to give a specific ratio (like aspect-3/2)
aspect-video = to give a video aspect ration of 16/9
aspect-[<value>] = to give aspect ratio based on a custom value (like aspect-[calc(4*3+1)/3])
For responsive design, Prefix it with a breakpoint variant like md: or lg:
columns - for controlling the number of columns within an element.
columns-<number> = to set column based on number like columns-3 for 3columns
columns-<width size> = to set the column width(like columns-sm**)**
gap-<width> = to set the width between columns
columns-<custom value> = to set the columns based on a completely custom value( like columns-[30vw])
display - for controlling the display box type of an element.
Use the
inline,inline-block, andblockutilities to control the flow of text and elements.Use the
flow-rootto create self-contained layout container that prevents floats, margins, and content from escaping or collapsing the parent.Use the
flexutility to create a block-level flex container.Use the
inline-flexutility to create an inline flex container that flows with text.Use the
gridutility to create a grid container.Use the
inline-gridutility to create an inline grid container.Use the
contentsutility to create a "phantom" container whose children act like direct children of the parent.Use the
table,table-row,table-cell,table-caption,table-column,table-column-group,table-header-group,table-row-group, andtable-footer-grouputilities to create elements that behave like their respective table elements.Use the
hiddenutility to remove an element from the document.Use
sr-onlyto hide an element visually without hiding it from screen readers.Use
not-sr-onlyto undosr-only, making an element visible to sighted users as well as screen readers.
overflow - for controlling how an element handles content that is too large for the container.
Use the
overflow-visibleutility to show content that overflows.Use the
overflow-hiddenutility to hide content that overflows.Use the
overflow-autoutility to add scrollbars to an element in the event that its content overflows the bounds of that element.Unlike
overflow-scroll, which always shows scrollbars, this utility will only show them if scrolling is necessary.Use the
overflow-x-autoutility to allow horizontal scrolling if needed.Use the
overflow-y-autoutility to allow vertical scrolling if needed.Use the
overflow-x-scrollutility to allow horizontal scrolling and always show scrollbars unless always-visible scrollbars are disabled by the operating system.
overscroll-behaviour - for controlling how the browser behaves when reaching the boundary of a scrolling area.
Use the
overscroll-containutility to prevent scrolling in the target area from triggering scrolling in the parent element, but preserve "bounce" effects when scrolling past the end of the container in operating systems that support it.Use the
overscroll-noneutility to prevent scrolling in the target area from triggering scrolling in the parent element, and also prevent "bounce" effects when scrolling past the end of the container.Use the
overscroll-autoutility to make it possible for the user to continue scrolling a parent scroll area when they reach the boundary of the primary scroll area.
position - for controlling how an element is positioned in the document.
Use the
staticutility to position an element according to the normal flow of the document.Use the
relativeutility to position an element according to the normal flow of the document.Use the
absoluteutility to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn't exist.Use the
fixedutility to position an element relative to the browser window.Use the
stickyutility to position an element asrelativeuntil it crosses a specified threshold, then treat it asfixeduntil its parent is off screen.
float - for controlling the wrapping of content around an element.
Use the
float-rightutility to float an element to the right of its container.Use the
float-leftutility to float an element to the left of its container.Use the
float-startandfloat-endutilities, which use logical properties to map to either the left or right side based on the text direction.Use the
float-noneutility to reset any floats that are applied to an element.
top/right/bottom/left - for controlling the placement of positioned elements.
Use
top-<number>,right-<number>,bottom-<number>,left-<number>, andinset-<number>utilities liketop-0andbottom-4to set the horizontal or vertical position of a positioned element.To use a negative top/right/bottom/left value, prefix the class name with a dash to convert it to a negative value.
Use
start-<number>orend-<number>utilities likestart-0andend-4to set theinset-inline-startandinset-inline-endlogical properties, which map to either the left or right side based on the text direction.Use utilities like
inset-[<value>]andtop-[<value>]to set the position based on a completely custom value.
visibility - for controlling the visibility of an element.
Use the
invisibleutility to hide an element, but still maintain its place in the document, affecting the layout of other elements.Use the
collapseutility to hide table rows, row groups, columns, and column groups as if they were set todisplay: none, but without impacting the size of other rows and columns.Use the
visibleutility to make an element visible.
z-index - for controlling the stack order of an element.
Use the
z-<number>utilities likez-10andz-50to control the stack order (or three-dimensional positioning) of an element, regardless of the order it has been displayed.To use a negative z-index value, prefix the class name with a dash to convert it to a negative value.
Use the
z-[<value>]syntax to set the stack order based on a completely custom value (like z-[calc(var(--index)+1)] ).
clear - for controlling the wrapping of content around an element.
Use the
clear-leftutility to position an element below any preceding left-floated elements.Use the
clear-rightutility to position an element below any preceding right-floated elements.Use the
clear-bothutility to position an element below all preceding floated elements.Use the
clear-startandclear-endutilities, which use logical properties to map to either the left or right side based on the text direction.Use the
clear-noneutility to reset any clears that are applied to an element.
object-fit - for controlling how a replaced element's content should be resized.
Use the
object-coverutility to resize an element's content to cover its container:Use the
object-containutility to resize an element's content to stay contained within its container.Use the
object-fillutility to stretch an element's content to fit its container.Use the
object-scale-downutility to display an element's content at its original size but scale it down to fit its container if necessary.Use the
object-noneutility to display an element's content at its original size ignoring the container size.
object-position - for controlling how a replaced element's content should be positioned within its container. Use utilities like
object-leftandobject-bottom-rightto specify how a replaced element's content should be positioned within its container. Use theobject-[<value>]syntax to set the object position based on a completely custom value (like object-[25%_75%] ).break-after - for controlling how a column or page should break after an element.
break-before - for controlling how a column or page should break before an element.
break-inside -for controlling how a column or page should break within an element.
box-decoration-break - Use the
box-decoration-sliceandbox-decoration-cloneutilities to control whether properties like background, border, border-image, box-shadow, clip-path, margin, and padding should be rendered as if the element were one continuous fragment, or distinct blocks.box-sizing - for controlling how the browser should calculate an element's total size.
Use the
box-borderutility to set an element'sbox-sizingtoborder-box, telling the browser to include the element's borders and padding when you give it a height or width. Tailwind makes this the default for all elements in our preflight base styles.Use the
box-contentutility to set an element'sbox-sizingtocontent-box, telling the browser to add borders and padding on top of the element's specified width or height.
isolation - for controlling whether an element should explicitly create a new stacking context.
Use theisolateandisolation-autoutilities to control whether an element should explicitly create a new stacking context.
Flexbox
flex-direction - for controlling the direction of flex items.
Use
flex-rowto position flex items horizontally in the same direction as text.Use
flex-row-reverseto position flex items horizontally in the opposite direction.Use
flex-colto position flex items vertically.Use
flex-col-reverseto position flex items vertically in the opposite direction.
flex-wrap - for controlling how flex items wrap.
Use
flex-nowrapto prevent flex items from wrapping, causing inflexible items to overflow the container if necessary.Use
flex-wrapto allow flex items to wrap.Use
flex-wrap-reverseto wrap flex items in the reverse direction.
flex - for controlling how flex items both grow and shrink.
Use
flex-<number>utilities likeflex-1to allow a flex item to grow and shrink as needed, ignoring its initial size.Use
flex-initialto allow a flex item to shrink but not grow, taking into account its initial size.Use
flex-autoto allow a flex item to grow and shrink, taking into account its initial size.Use
flex-noneto prevent a flex item from growing or shrinking.Use the
flex-[<value>]syntax to set the flex shorthand property based on a completely custom value (like flex-[3_1_auto] ).
justify-content - for controlling how flex and grid items are positioned along a container's main axis.
Use the
justify-startutility to justify items against the start of the container's main axis.Use the
justify-centerorjustify-center-safeutilities to justify items along the center of the container's main axis.Use the
justify-endorjustify-end-safeutilities to justify items against the end of the container's main axis.Use the
justify-betweenutility to justify items along the container's main axis such that there is an equal amount of space between each item.Use the
justify-aroundutility to justify items along the container's main axis such that there is an equal amount of space on each side of each item.Use the
justify-evenlyutility to justify items along the container's main axis such that there is an equal amount of space around each item, but also accounting for the doubling of space you would normally see between each item when usingjustify-around.Use the
justify-stretchutility to allow auto-sized content items to fill the available space along the container's main axis.Use the
justify-normalutility to pack content items in their default position as if nojustify-contentvalue was set.
flex-basis - for controlling the initial size of flex items.
Use
basis-<number>utilities likebasis-64andbasis-128to set the initial size of flex items based on the spacing scale.Use utilities like
basis-xsandbasis-smto set the initial size of flex items based on the container scale.Use
basis-<fraction>utilities likebasis-1/2andbasis-2/3to set the initial size of flex items.Use the
basis-[<value>]syntax to set the basis based on a completely custom value.
flex-grow - for controlling how flex items grow.
Use
growto allow a flex item to grow to fill any available space.Use
grow-<number>utilities likegrow-3to make flex items grow proportionally based on their growth factor, allowing them to fill the available space relative to each other.Use
grow-0to prevent a flex item from growing.Use the
grow-[<value>]syntax to set the flex grow factor based on a completely custom value.
flex-shrink - for controlling how flex items shrink.
Use
shrinkto allow a flex item to shrink if needed.Use
shrink-0to prevent a flex item from shrinking.Use the
shrink-[<value>]syntax to set the flex shrink factor based on a completely custom value.
Grid
grid-template-columns - for specifying the columns in a grid layout.
Use
grid-cols-<number>utilities likegrid-cols-2andgrid-cols-4to create grids with n equally sized columns.Use the
grid-cols-subgridutility to adopt the column tracks defined by the item's parent.Use the
grid-cols-[<value>]syntax to set the columns based on a completely custom value.
grid-column - for controlling how elements are sized and placed across grid columns.
Use
col-span-<number>utilities likecol-span-2andcol-span-4to make an element span n columns space.Use
col-start-<number>orcol-end-<number>utilities likecol-start-2andcol-end-3to make an element start or end at the nth grid line.Use utilities like
col-[<value>],col-span-[<value>],col-start-[<value>], andcol-end-[<value>]to set the grid column size and location based on a completely custom value.
grid-template-rows - for specifying the rows in a grid layout.
Use
grid-rows-<number>utilities likegrid-rows-2andgrid-rows-4to create grids with n equally sized rows.Use the
grid-rows-subgridutility to adopt the row tracks defined by the item's parent.Use the
grid-rows-[<value>]syntax to set the rows based on a completely custom value.
grid-row - for controlling how elements are sized and placed across grid rows.
Use
row-span-<number>utilities likerow-span-2androw-span-4to make an element span n rows space.Use
row-start-<number>orrow-end-<number>utilities likerow-start-2androw-end-3to make an element start or end at the nth grid line.Use utilities like
row-[<value>],row-span-[<value>],row-start-[<value>], androw-end-[<value>]to set the grid row size and location based on a completely custom value.
justify-items - for controlling how grid items are aligned along their inline axis.
Use the
justify-items-startutility to justify grid items against the start of their inline axis.Use the
justify-items-endorjustify-items-end-safeutilities to justify grid items against the end of their inline axis.Use the
justify-items-centerorjustify-items-center-safeutilities to justify grid items against the end of their inline axis.Use the
justify-items-stretchutility to stretch items along their inline axis.
justify-self - for controlling how an individual grid item is aligned along its inline axis.
Use the
justify-self-autoutility to align an item based on the value of the grid'sjustify-itemsproperty.Use the
justify-self-startutility to align a grid item to the start of its inline axis.Use the
justify-self-centerorjustify-self-center-safeutilities to align a grid item along the center of its inline axis.Use the
justify-self-endorjustify-self-end-safeutilities to align a grid item to the end of its inline axis.Use the
justify-self-stretchutility to stretch a grid item to fill the grid area on its inline axis.
place-items - for controlling how items are justified and aligned at the same time.
Use
place-items-startto place grid items on the start of their grid areas on both axes.Use
place-items-endto place grid items on the end of their grid areas on both axes.Use
place-items-centerto place grid items on the center of their grid areas on both axes.Use
place-items-stretchto stretch items along their grid areas on both axes.
place-self - for controlling how an individual item is justified and aligned at the same time.
Use
place-self-autoto align an item based on the value of the container'splace-itemsproperty.Use
place-self-startto align an item to the start on both axes.Use
place-self-centerto align an item at the center on both axes.Use
place-self-endto align an item to the end on both axes.Use
place-self-stretchto stretch an item on both axes.
grid-auto-flow - for controlling how elements in a grid are auto-placed.
Use utilities like
grid-flow-colandgrid-flow-row-denseto control how the auto-placement algorithm works for a grid layout.| Tailwind Class | Meaning | | --- | --- | |
grid-flow-row| Fill rows left → right | |grid-flow-col| Fill columns top → bottom | |grid-flow-dense| Pack items tightly | |grid-flow-row-dense| Row flow + tight packing | |grid-flow-col-dense| Column flow + tight packing |Without dense → keep order, allow gaps
With dense → fill gaps like Tetris
grid-auto-columns - for controlling how wide automatically generated grid columns become when content overflows or columns aren’t predefined.
grid-auto-rows - for controlling how wide automatically generated grid rows become when content overflows or rows aren’t predefined.
Flexbox & Grid Commons
self = works at individual level
items and context = works at group level
justify = grid
align = flex & grid both
order - for controlling the order of flex and grid items.
Use
order-<number>utilities likeorder-1andorder-3to render flex and grid items in a different order than they appear in the document.Use the
order-firstandorder-lastutilities to render flex and grid items first or last.To use a negative order value, prefix the class name with a dash to convert it to a negative value.
Use the
order-[<value>]syntax to set the order based on a completely custom value.
gap - for controlling gap between grid and flexbox items.
Use
gap-<number>utilities likegap-2andgap-4to change the gap between both rows and columns in grid and flexbox layouts.Use
gap-x-<number>orgap-y-<number>utilities likegap-x-8andgap-y-4to change the gap between columns and rows independently.Use utilities like
gap-[<value>],gap-x-[<value>], andgap-y-[<value>]to set the gap based on a completely custom value.
align-content - for controlling how rows are positioned in multi-row flex and grid containers(x-axis).
Use
content-startto pack rows in a container against the start of the cross axis.Use
content-centerto pack rows in a container in the center of the cross axis.Use
content-endto pack rows in a container against the end of the cross axis.Use
content-betweento distribute rows in a container such that there is an equal amount of space between each line.Use
content-aroundto distribute rows in a container such that there is an equal amount of space around each line.Use
content-evenlyto distribute rows in a container such that there is an equal amount of space around each item, but also accounting for the doubling of space you would normally see between each item when usingcontent-around.Use
content-stretchto allow content items to fill the available space along the container’s cross axis.Use
content-normalto pack content items in their default position as if noalign-contentvalue was set.
align-items - Utilities for controlling how flex and grid items are positioned along a container's cross axis(x-axis).
Use the
items-stretchutility to stretch items to fill the container's cross axis.Use the
items-startutility to align items to the start of the container's cross axis.Use the
items-centerutility to align items along the center of the container's cross axis.Use the
items-endutility to align items to the end of the container's cross axis.Use the
items-baselineutility to align items along the container's cross axis such that all of their baselines align.
align-self - for controlling how an individual flex or grid item is positioned along its container's cross axis.
Use the
self-autoutility to align an item based on the value of the container'salign-itemsproperty.Use the
self-startutility to align an item to the start of the container's cross axis, despite the container'salign-itemsvalue.Use the
self-centerutility to align an item along the center of the container's cross axis, despite the container'salign-itemsvalue.Use the
self-endutility to align an item to the end of the container's cross axis, despite the container'salign-itemsvalue.Use the
self-stretchutility to stretch an item to fill the container's cross axis, despite the container'salign-itemsvalue.Use the
self-baselineutility to align an item such that its baseline aligns with the baseline of the flex container's cross axis.Use the
self-baseline-lastutility to align an item along the container's cross axis such that its baseline aligns with the last baseline in the container.
place-content - for controlling how content is justified and aligned at the same time.
Use
place-content-centerto pack items in the center of the inline and block axes.Use
place-content-startto pack items against the start of the inline and block axes.Use
place-content-endto pack items against the end of the inline and block axes.Use
place-content-betweento distribute grid items along the inline and block axes so that there is an equal amount of space between each row and column on each axis respectively.Use
place-content-aroundto distribute grid items along the inline and block axes so that there is an equal amount of space around each row and column on each axis respectively.Use
place-content-evenlyto distribute grid items such that they are evenly spaced on the inline and block axes.Use
place-content-stretchto stretch grid items along their grid areas on the inline and block axes.
Spacing & Sizing
padding - for controlling an element's padding.
Use
p-<number>utilities likep-4andp-8to control the padding on all sides of an element.Use
pt-<number>,pr-<number>,pb-<number>, andpl-<number>utilities likept-6andpr-4to control the padding on one side of an element.Use
px-<number>utilities likepx-4andpx-8to control the horizontal padding of an element.Use
py-<number>utilities likepy-4andpy-8to control the vertical padding of an element.Using logical properties - Use
ps-<number>orpe-<number>utilities likeps-4andpe-8to set thepadding-inline-startandpadding-inline-endlogical properties, which map to either the left or right side based on the text direction.Use utilities like
p-[<value>],px-[<value>], andpb-[<value>]to set the padding based on a completely custom value.
margin - for controlling an element's margin.
Use
m-<number>utilities likem-4andm-8to control the margin on all sides of an element.Use
mt-<number>,mr-<number>,mb-<number>, andml-<number>utilities likeml-2andmt-6to control the margin on one side of an element.Use
mx-<number>utilities likemx-4andmx-8to control the horizontal margin of an element.Use
my-<number>utilities likemy-4andmy-8to control the vertical margin of an element.To use a negative margin value, prefix the class name with a dash to convert it to a negative value.
Using logical properties - Use
ms-<number>orme-<number>utilities likems-4andme-8to set themargin-inline-startandmargin-inline-endlogical properties.Adding space between children - Use
space-x-<number>orspace-y-<number>utilities likespace-x-4andspace-y-8to control the space between elements.Reversing children order - If your elements are in reverse order (using say
flex-row-reverseorflex-col-reverse), use thespace-x-reverseorspace-y-reverseutilities to ensure the space is added to the correct side of each element.Use utilities like
m-[<value>],mx-[<value>], andmb-[<value>]to set the margin based on a completely custom value.
width - for setting the width of an element.
Use
w-<number>utilities likew-24andw-64to set an element to a fixed width based on the spacing scale.Use
w-fullorw-<fraction>utilities likew-1/2andw-2/5to give an element a percentage-based width.Use utilities like
w-smandw-xlto set an element to a fixed width based on the container scale.Matching the viewport - Use the
w-screenutility to make an element span the entire width of the viewport.Resetting the width - Use the
w-autoutility to remove an element's assigned width under a specific condition, like at a particular breakpoint.Setting both width and height - Use utilities like
size-px,size-4, andsize-fullto set both the width and height of an element at the same time.Use the
w-[<value>]syntax to set the width based on a completely custom value.
min-width - for setting the minimum width of an element.
Use
min-w-<number>utilities likemin-w-24andmin-w-64to set an element to a fixed minimum width based on the spacing scale.Use
min-w-fullormin-w-<fraction>utilities likemin-w-1/2andmin-w-2/5to give an element a percentage-based minimum width.Use utilities like
min-w-smandmin-w-xlto set an element to a fixed minimum width based on the container scale.Use the
min-w-[<value>]syntax to set the minimum width based on a completely custom value.
max-width - for setting the maximum width of an element.
Use
max-w-<number>utilities likemax-w-24andmax-w-64to set an element to a fixed maximum width based on the spacing scale.Use
max-w-fullormax-w-<fraction>utilities likemax-w-1/2andmax-w-2/5to give an element a percentage-based maximum width.Use utilities like
max-w-smandmax-w-xlto set an element to a fixed maximum width based on the container scale.Use the
max-w-[<value>]syntax to set the maximum width based on a completely custom value.
height - for setting the height of an element.
Use
h-<number>utilities likeh-24andh-64to set an element to a fixed height based on the spacing scale.Use
h-fullorh-<fraction>utilities likeh-1/2andh-2/5to give an element a percentage-based height.Use the
h-screenutility to make an element span the entire height of the viewport.For dynamic viewport - Use the
h-dvhutility to make an element span the entire height of the viewport, which changes as the browser UI expands or contracts.For large viewport - Use the
h-lvhutility to set an element's height to the largest possible height of the viewport.For small viewport - Use the
h-svhutility to set an element's height to the smallest possible height of the viewport.Use utilities like
size-px,size-4, andsize-fullto set both the width and height of an element at the same time.Use the
h-[<value>]syntax to set the height based on a completely custom value.
min-height - for setting the minimum height of an element.
Use
min-h-<number>utilities likemin-h-24andmin-h-64to set an element to a fixed minimum height based on the spacing scale.Use
min-h-fullormin-h-<fraction>utilities likemin-h-1/2, andmin-h-2/5to give an element a percentage-based minimum height.Use the
min-h-[<value>]syntax to set the minimum height based on a completely custom value.
max-height - setting the maximum height of an element.
Use
max-h-<number>utilities likemax-h-24andmax-h-64to set an element to a fixed maximum height based on the spacing scale.Use
max-h-fullormax-h-<fraction>utilities likemax-h-1/2andmax-h-2/5to give an element a percentage-based maximum height.Use the
max-h-[<value>]syntax to set the maximum height based on a completely custom value.
Typography
font-family - for controlling the font family of an element like
font-sans.font-size - for controlling the font size of an element like
text-sm. Use utilities liketext-sm/6andtext-lg/7to set the font size and line-height of an element at the same time.font-style - for controlling the style of text. Use the
italicutility to make text italic andnot-italicutility to display text normally.font-weight - for controlling the font weight of an element. Use utilities like
font-thinandfont-boldto set the font weight of an element.text-align - for controlling the alignment of text. Use the
text-leftutility to left align the text of an element, similarly, usetext-center, text-right, text-start, text-end, text-justify.color - for controlling the text color of an element. Use utilities like
text-blue-600andtext-blue-600/25(color opacity modifier to control the text color opacity of an element).
Prefix acolorutility with a variant likehover:*to only apply the utility in that state.text-transform - for controlling the capitalization of text. Like
uppercase,lowercase,capitalizeornormal-case.text-wrap - for controlling how text wraps within an element. Use the
text-wraputility to wrap overflowing text onto multiple lines at logical points in the text. Use thetext-nowraputility to prevent text from wrapping, allowing it to overflow if necessary. Use thetext-balanceutility to distribute the text evenly across each line.text-indent - for controlling the amount of empty space shown before text in a block. Use
indent-<number>utilities likeindent-2andindent-8to set the amount of empty space (indentation) that's shown before text in a block. For using a negative value, just use - before the utility.text-decoration-line - for controlling the decoration of text. Use the
overlineutility to add an overline to the text of an element, Use theno-underlineutility to remove a line from the text of an element, Use theunderlineutility to add an underline, Use theline-throughutility to add a line through the text of an element. Prefix atext-decoration-lineutility with a variant likehover:*to only apply the utility in that state.list-style-position - for controlling the position of bullets and numbers in lists. Use utilities like
list-insideandlist-outsideto control the position of the markers and text indentation in a list.list-style-type - for controlling the marker style of a list. Use utilities like
list-discandlist-decimalto control the style of the markers in a list.white-space - for controlling an element's white-space property.
font-variant-numeric - for controlling the variant of numbers.
line-clamp - for cutting long text after a fixed number of lines and adds
..., useline-clamp-<number>.line-height - for controlling the leading, or line height, of an element. Use
leading-<number>utilities likeleading-6andleading-7to set the line height of an element independent of the font-size or Use theleading-noneutility to set the line height of an element equal to its font size.
Backgrounds
background-attachment - for controlling how a background image behaves when scrolling.
Use the
bg-fixedutility to fix the background image relative to the viewport.Use the
bg-localutility to scroll the background image with the container and the viewport.Use the
bg-scrollutility to scroll the background image with the viewport, but not with the container.
background-clip - for controlling where the background color or image is allowed to appear inside a box.
bg-clip-border- Background fills everything — content, padding, and under the border.bg-clip-padding- Background fills content + padding, but NOT the border.bg-clip-content- Background fills ONLY the content area**.**bg-clip-text- Background is visible ONLY inside the text**.**
background-color - for controlling an element's background color.
Use utilities like
bg-white,bg-indigo-500andbg-transparentto control the background color of an element.Use the color opacity modifier to control the opacity of an element's background color like
bg-sky-500/100.Use the
bg-[<value>]syntax to set the background color based on a completely custom value likebg-[#50d71e]For CSS variables, you can also use the
bg-(<custom-property>)syntax likebg-(--my-color).Prefix a
background-colorutility with a variant likehover:*to only apply the utility in that state.
background-image - for controlling an element's background image.
Use the
bg-[<value>]syntax to set the background image of an element likebg-[url(/img/mountains.jpg)]Adding linear gradient - Use utilities like
bg-linear-to-randbg-linear-<angle>with the color stop utilities to add a linear gradient to an element likebg-linear-to-r from-cyan-500 to-blue-500.Adding radical gradient - Use the
bg-radialandbg-radial-[<position>]utilities with the color stop utilities to add a radial gradient to an element likebg-radial from-pink-400 from-40% to-fuchsia-700.Adding conical gradient - Use the
bg-conicandbg-conic-<angle>utilities with the color stop utilities to add a conic gradient to an element likebg-conic from-blue-600 to-sky-400 to-50%.Setting gradient color stops - Use utilities like
from-indigo-500,via-purple-500, andto-pink-500to set the colors of the gradient stops likebg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500Setting gradient stop positions - Use utilities like
from-10%,via-30%, andto-90%to set more precise positions for the gradient color stops likebg-gradient-to-r from-indigo-500 from-10% via-sky-500 via-30% to-emerald-500 to-90%.Changing interpolation mode - Use the interpolation modifier to control the interpolation mode of a gradient. By default gradients are interpolated in the
oklabcolor space.Use the
bg-noneutility to remove an existing background image from an element.
background-origin - for controlling how an element's background is positioned relative to borders, padding, and content.
bg-origin-border- Background starts from the outer border edge (Covers border + padding + content).bg-origin-padding- Background starts inside the border (Covers padding + content).bg-origin-content- Background starts only inside the content area (Covers content only).
background-position - for controlling the position of an element's background image. Use utilities like
bg-center,bg-right, andbg-top-leftto control the position of an element's background image.background-repeat - for controlling the repetition of an element's background image.
Use the
bg-repeatutility to repeat the background image both vertically and horizontally.Use the
bg-repeat-xutility to only repeat the background image horizontally.Use the
bg-repeat-yutility to only repeat the background image vertically.Use the
bg-repeat-spaceutility to repeat the background image without clipping.Use the
bg-repeat-roundutility to repeat the background image without clipping, stretching if needed to avoid gaps.Use the
bg-no-repeatutility to prevent a background image from repeating.
background-size - for controlling the background size of an element's background image.
filling the container - Use the
bg-coverutility to scale the background image until it fills the background layer, cropping the image if needed.filling without cropping - Use the
bg-containutility to scale the background image to the outer edges without cropping or stretching.using default size - Use the
bg-autoutility to display the background image at its default size.using custom value - Use the
bg-size-[<value>]syntax to set the background size based on a completely custom value likebg-size-[auto_100px].
Borders
border-radius - for controlling the border radius of an element.
Use utilities like
rounded-smandrounded-mdto apply different border radius sizes to an element.Rounding sides separately - Use utilities like
rounded-t-mdandrounded-r-lgto only round one side of an element.Rounding corners separately - Use utilities like
rounded-tr-mdandrounded-tl-lgutilities to only round one corner of an element.Creating pill button - Use the
rounded-fullutility to create pill buttons.Removing the border radius - Use the
rounded-noneutility to remove an existing border radius from an element.Using custom value - Use the
rounded-[<value>]syntax to set the border radius based on a completely custom value likerounded-[2vw].
border-width - for controlling the width of an element's borders.
Use
borderorborder-<number>utilities likeborder-2andborder-4to set the border width for all sides of an element.Individual sides - Use utilities like
border-randborder-t-4to set the border width for one side of an element.Horizontal and vertical sides - Use utilities like
border-xandborder-y-4to set the border width on two sides of an element at the same time.Between children - Use utilities like
divide-xanddivide-y-4to add borders between child elements.Using custom value - Use the
border-[<value>]syntax to set the border width based on a completely custom value likeborder-[2vw].
border-color - for controlling the color of an element's borders.
Use utilities like
border-rose-500andborder-lime-100to control the border color of an element.Changing the opacity - Use the color opacity modifier to control the opacity of an element's border color like
border-indigo-500/100.Individual sides - Use utilities like
border-t-indigo-500andborder-r-lime-100to set the border color for one side of an element.Horizontal and Vertical sides - Use utilities like
border-x-indigo-500andborder-y-lime-100to set the border color on two sides of an element at the same time.Between children - Use utilities like
divide-indigo-500anddivide-lime-100to control the border color between child elements.Using custom value - Use the
border-[<value>]syntax to set the border color based on a completely custom value likeborder-[#243c5a].Applying on focus - Prefix a
border-colorutility with a variant likefocus:*to only apply the utility in that state likefocus:border-pink-600.
border-style - for controlling the style of an element's borders.
Use utilities like
border-solid,border-dashed,border-doubleandborder-dottedto control an element's border style.Removing border - Use the
border-noneutility to remove an existing border from an element.Between children - Use utilities like
divide-dashedanddivide-dottedto control the border style between child elements.
outline-width - for controlling the width of an element's outline.
Use
outlineoroutline-<number>utilities likeoutline-2andoutline-4to set the width of an element's outline.Prefix an
outline-widthutility with a variant likefocus:*to only apply the utility in that state.Use the
outline-[<value>]syntax to set the outline width based on a completely custom value likeoutline-[2vw].
outline-color - for controlling the color of an element's outline.
Use utilities like
outline-rose-500andoutline-lime-100to control the color of an element's outline.Changing the opacity - Use the color opacity modifier to control the opacity of an element's outline color.
Using custom value - Use the
outline-[<value>]syntax to set the outline color based on a completely custom value.
outline-style - for controlling the style of an element's outline.
Use utilities like
outline-solid,outline-dashed,outline-doubleandoutline-dashedto set the style of an element's outline.Use the
outline-hiddenutility to hide the default browser outline on focused elements, while still preserving the outline in forced colors mode.Use the
outline-noneutility to completely remove the default browser outline on focused elements.
outline-offset - for adding space between the element and its outline.
Use utilities like
outline-offset-2andoutline-offset-4to change the offset of an element's outline.Use the
outline-offset-[<value>]syntax to set the outline offset based on a completely custom value likeoutline-offset-[2vw].
Effects
box-shadow - for controlling the box shadow of an element.
Use utilities like
shadow-smandshadow-lgto apply different sized outer box shadows to an element.Changing the opacity - Use the opacity modifier to adjust the opacity of the box shadow like
shadow-xl/20.Setting the shadow color - Use utilities like
shadow-indigo-500andshadow-cyan-500/50to change the color of a box shadow.Adding an insert shadow - Use utilities like
inset-shadow-xsandinset-shadow-smto apply an inset box shadow to an element.Setting the insert shadow cUse
inset-ringorinset-ring-<number>utilities likeinset-ring-2andinset-ring-4to apply a solid inset box-shadow to an elemenolor - Use utilities likeinset-shadow-indigo-500andinset-shadow-cyan-500/50to change the color of an inset box shadow.Adding a ring - Use
ringorring-<number>utilities likering-2andring-4to apply a solid box-shadow to an element.Setting the ring color - Use utilities like
ring-indigo-500andring-cyan-500/50to change the color of a ring.Adding an inset ring - Use
inset-ringorinset-ring-<number>utilities likeinset-ring-2andinset-ring-4to apply a solid inset box-shadow to an element.Adding inset ring color - Use utilities like
inset-ring-indigo-500andinset-ring-cyan-500/50to change the color of an inset ring.Remove the shadow - Use the
shadow-none,inset-shadow-none,ring-0, andinset-ring-0utilities to remove an existing box shadow from an element.Using custom value - Use utilities like
shadow-[<value>],inset-shadow-[<value>],ring-[<value>], andinset-ring-[<value>]to set the box shadow based on a completely custom value likeshadow-[0_35px_35px_rgba(0,0,0,0.25)].
text-shadow - for controlling the shadow of a text element.
Use utilities like
text-shadow-smandshadow-lgto apply different sized text shadows to a text element.Changing the opacity - Use the opacity modifier to adjust the opacity of the text shadow.
Setting shadow color - Use utilities like
text-shadow-indigo-500andtext-shadow-cyan-500/50to change the color of a text shadow.Removing text shadow - Use the
text-shadow-noneutility to remove an existing text shadow from an element.Using custom value - Use the
text-shadow-[<value>]syntax to set the text shadow based on a completely custom value liketext-shadow-[0_35px_35px_rgb(0_0_0_/_0.25)].
opacity - for controlling the opacity of an element.
Use
opacity-<number>utilities likeopacity-25andopacity-100to set the opacity of an element.Applying conditionally - Prefix an
opacityutility with a variant likedisabled:*to only apply the utility in that state.Using custom value - Use the
opacity-[<value>]syntax to set the opacity based on a completely custom value likeopacity-[.67].
mix-blend-mode - for controlling how an element should blend with the background.
background-blend-mode - for controlling how an element's background image should blend with its background color.
mask-clip - for controlling how far a mask can hide or reveal content inside an element.
For all effects related to mask, prefer official documentation.
Filters
filter - for applying filters to an element.
Use utilities like
blur-xsandgrayscaleto apply filters to an element.You can combine the following filter utilities: blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, saturate, and sepia.
Use the
filter-noneutility to remove all of the filters applied to an element. Use thefilter-[<value>]syntax to set the filter based on a completely custom value.Prefix a
filterutility with a variant likehover:*to only apply the utility in that state.
blur - for applying blur filters to an element.
Use utilities likeblur-smandblur-lgto blur an element. Use theblur-[<value>]syntax to set the blur based on a completely custom value likeblur-[2px].brightness - for applying brightness filters to an element.
Use utilities likebrightness-50andbrightness-100to control an element's brightness. Use thebrightness-[<value>]syntax to set the brightness based on a completely custom value likebrightness-[1.75].contrast - for applying contrast filters to an element. Use utilities like
contrast-50andcontrast-100to control an element's contrast. Use thecontrast-[<value>]syntax to set the contrast based on a completely custom value likecontrast-[.25].
Similarly you can use other filters, refer documentation for more.
backdrop-filter - for applying backdrop filters to an element. It affects the background behind the element. All CSS utilities work exactly the same the text got replaced from filter to backdrop-filter.
Transitions and Animations
Transitions = smooth change between states (hover, focus, active)
Animations = continuous or repeating motion over time
Think:
Transition → reacts to user interaction
Animation → runs on its own timeline
transition-property - for controlling which CSS properties transition.
Use utilities like
transitionandtransition-colorsto specify which properties should transition when they change.Supporting reduced motions - For situations where the user has specified that they prefer reduced motion, you can conditionally apply animations and transitions using the
motion-safeandmotion-reducevariants.Using custom value - Use the
transition-[<value>]syntax to set the transition properties based on a completely custom value.
transition-behavior - to control the behavior of CSS transitions.
Use thetransition-discreteutility to start transitions when changing properties with a discrete set of values, such as elements that change fromhiddentoblock.transition-duration - for controlling the duration of CSS transitions.
Use utilities likeduration-150andduration-700to set the transition duration of an element in milliseconds.transition-timing-function - for controlling the easing of CSS transitions.
Use utilities likeease-inandease-outto control the easing curve of an element's transition.transition-delay - for controlling the delay of CSS transitions.
Use utilities likedelay-150anddelay-700to set the transition delay of an element in milliseconds.animation - for animating elements with CSS animations.
Adding a spin animation - Use the
animate-spinutility to add a linear spin animation to elements like loading indicators.Adding a ping animation - Use the
animate-pingutility to make an element scale and fade like a radar ping or ripple of water—useful for things like notification badges.Adding a pulse animation - Use the
animate-pulseutility to make an element gently fade in and out—useful for things like skeleton loaders.Adding a bounce animation - Use the
animate-bounceutility to make an element bounce up and down—useful for things like "scroll down" indicators.
Transforms
Transforms = moving, rotating, resizing, or tilting an element visually — without changing the page layout.
rotate - for rotating elements.
Use
rotate-<number>utilities likerotate-45androtate-90to rotate an element by degrees.Using negative values - Use
-rotate-<number>utilities like-rotate-45and-rotate-90to rotate an element counterclockwise by degrees.Rotating in 3D spaces - Use
rotate-x-<number>,rotate-y-<number>, androtate-z-<number>utilities likerotate-x-50,-rotate-y-30, androtate-z-45together to rotate an element in 3D space.
scale - for scaling elements(Make elements bigger or smaller).
Use
scale-<number>utilities likescale-75andscale-150to scale an element by a percentage of its original size.Scaling on the x-axis - Use the
scale-x-<number>utilities likescale-x-75and-scale-x-150to scale an element on the x-axis by a percentage of its original width.Scaling on the y-axis - Use the
scale-y-<number>utilities likescale-y-75andscale-y-150to scale an element on the y-axis by a percentage of its original height.Using negative values - Use
-scale-<number>,-scale-x-<number>or-scale-y-<number>utilities like-scale-x-75and-scale-125to mirror and scale down an element by a percentage of its original size.
skew - for skewing elements with transform(Tilt Diagonally).
Use
skew-<number>utilities likeskew-4andskew-10to skew an element on both axes.Using negative values - Use
-skew-<number>utilities like-skew-4and-skew-10to skew an element on both axes.On x-axis - Use
skew-x-<number>utilities likeskew-x-4and-skew-x-10to skew an element on the x-axis.On y-axis - Use
skew-y-<number>utilities likeskew-y-4and-skew-y-10to skew an element on the y-axis.
translate - for translating elements(Move left, right, up, or down).
Using spacing scale - Use
translate-<number>utilities liketranslate-2and-translate-4to translate an element on both axes based on the spacing scale.Using percentage scale - Use
translate-<fraction>utilities liketranslate-1/4and-translate-fullto translate an element on both axes by a percentage of the element's size.On x-axis axis - Use
translate-x-<number>ortranslate-x-<fraction>utilities liketranslate-x-4andtranslate-x-1/4to translate an element on the x-axis.On y-axis - Use
translate-y-<number>ortranslate-y-<fraction>utilities liketranslate-y-6andtranslate-y-1/3to translate an element on the y-axis.On z-axis - Use
translate-z-<number>utilities liketranslate-z-6and-translate-z-12to translate an element on the z-axis.
transform - for transforming elements.
Hardware acceleration - If your transition performs better when rendered by the GPU instead of the CPU, you can force hardware acceleration by adding the
transform-gpuutility.Use the
transform-cpuutility to force things back to the CPU if you need to undo this conditionally.Removing transforms - Use the
transform-noneutility to remove all of the transforms on an element at once.
transform-origin - for specifying the origin for an element's transformations.
Use utilities likeorigin-topandorigin-bottom-leftto set an element's transform origin.transform-style - for controlling if an elements children are placed in 3D space.
Usetransform-3dto position children in 3D space.
Interactivity
accent-color - for controlling the accented color of a form control.
Setting the accent color - Use utilities like
accent-rose-500andaccent-lime-600to change the accent color of an element. This is helpful for styling elements like checkboxes and radio groups by overriding the browser's default color.Changing the opacity - Use the color opacity modifier to control the opacity of an element's accent color. Setting the accent color opacity has limited browser-support and only works in Firefox at this time.
Using custom value - Use the
accent-[<value>]syntax to set the accent color based on a completely custom value likeaccent-[#50d71e].Applying on hover - Prefix an
accent-colorutility with a variant likehover:*to only apply the utility in that state.
appearance - for suppressing native form control styling.
Removing default appearance - Use
appearance-noneto reset any browser specific styling on an element.Restoring default appearance - Use
appearance-autoto restore the default browser specific styling on an element.
caret-color - for controlling the color of the text input cursor.
Use utilities like
caret-rose-500andcaret-lime-600to change the color of the text input cursor.Using custom value - Use the
caret-[<value>]syntax to set the caret color based on a completely custom value likecaret-[#50d71e].
color-schema - for controlling the color scheme of an element.
Use utilities like
scheme-lightandscheme-light-darkto control how element should be rendered.Applying in dark mode - Prefix a
color-schemeutility with a variant likedark:*to only apply the utility in that state.
cursor - for controlling the cursor style when hovering over an element.
Use utilities likecursor-pointerandcursor-grabto control which cursor is displayed when hovering over an element.field-sizing - for controlling the sizing of form controls.
Sizing based on content - Use the
field-sizing-contentutility to allow a form control to adjust it's size based on the content.Using fixed size - Use the
field-sizing-fixedutility to make a form control use a fixed size.
pointer-events - for controlling whether an element responds to pointer events.
Ignoring pointer events - Use the
pointer-events-noneutility to make an element ignore pointer events, like:hoverandclickevents. The pointer events will still trigger on child elements and pass-through to elements that are "beneath" the target.Restoring pointer events - Use the
pointer-events-autoutility to revert to the default browser behavior for pointer events.
resize - for controlling how an element can be resized.
Resizing in all directions - Use
resizeto make an element horizontally and vertically resizable.Resizing vertically - Use
resize-yto make an element vertically resizable.Resizing horizontally - Use
resize-xto make an element horizontally resizable.Prevent resizing - Use
resize-noneto prevent an element from being resizable.
scroll-behavior - for controlling the scroll behavior of an element.
Using smooth scrolling - Use the
scroll-smoothutility to enable smooth scrolling within an element. Setting thescroll-behavioronly affects scroll events that are triggered by the browser.Using normal scrolling - Use the
scroll-autoutility to revert to the default browser behavior for scrolling.
scroll-margin - for controlling the scroll offset around items in a snap container.
Use the
scroll-mt-<number>,scroll-mr-<number>,scroll-mb-<number>, andscroll-ml-<number>utilities likescroll-ml-4andscroll-mt-6to set the scroll offset around items within a snap container.Using negative values - To use a negative scroll margin value, prefix the class name with a dash to convert it to a negative value.
Using custom value - Use utilities like
scroll-ml-[<value>]andscroll-me-[<value>]to set the scroll margin based on a completely custom value.
scroll-padding - for controlling an element's scroll offset within a snap container.
Use the
scroll-pt-<number>,scroll-pr-<number>,scroll-pb-<number>, andscroll-pl-<number>utilities likescroll-pl-4andscroll-pt-6to set the scroll offset of an element within a snap container.Using negative values - To use a negative scroll padding value, prefix the class name with a dash to convert it to a negative value.
Using custom value - Use utilities like
scroll-pl-[<value>]andscroll-pe-[<value>]to set the scroll padding based on a completely custom value likescroll-pl-[24rem].
scroll-snap-align - for controlling the scroll snap alignment of an element.
Snapping to the center - Use the
snap-centerutility to snap an element to its center when being scrolled inside a snap container.Snapping to the start - Use the
snap-startutility to snap an element to its start when being scrolled inside a snap container.Snapping to the end - Use the
snap-endutility to snap an element to its end when being scrolled inside a snap container.
scroll-snap-stop - for controlling whether you can skip past possible snap positions.
Forcing snap-position stops - Use the
snap-alwaysutility together with the snap-mandatory utility to force a snap container to always stop on an element before the user can continue scrolling to the next item.Skipping snap-position stops - Use the
snap-normalutility to allow a snap container to skip past possible scroll snap positions.
scroll-snap-type - for controlling how strictly snap points are enforced in a snap container.
touch-action - for controlling how an element can be scrolled and zoomed on touchscreens.
Use utilities like
touch-pan-yandtouch-pinch-zoomto control how an element can be scrolled (panned) and zoomed (pinched) on touchscreensuser-select - for controlling whether the user can select text in an element.
Disabling text selection - Use the
select-noneutility to prevent selecting text in an element and its children.Allowing text selection - Use the
select-textutility to allow selecting text in an element and its children.Selecting all text in one click - Use the
select-allutility to automatically select all the text in an element when a user clicks.Using auto select behavior - Use the
select-autoutility to use the default browser behavior for selecting text.
will-change - for optimizing upcoming animations of elements that are expected to change.