Tailwind CSS Outline Cheatsheet
Complete reference for outline utilities in Tailwind v4.
Click any utility to copy the class name.
Outline vs Border vs Ring
Understanding when to use each is crucial for proper styling and accessibility.
Border
- -Affects layout (takes space)
- +Part of box model
- +Can have different styles per side
border-widthOutline
- +Does NOT affect layout
- +Native CSS property
- -Can't style individual sides
outline-widthRing (Tailwind)
- +Does NOT affect layout
- +Has ring-offset utilities
- !Tailwind-specific (box-shadow)
box-shadowKey Takeaway: Use outline or ring for focus states since they don't shift the layout. Use border when the visual element should be part of the element's dimensions.
Outline Width
Control the width of an element's outline.
Outline Color
Set the color of an element's outline. All Tailwind color palettes are available.
Special Values
Color Palette (500 shade examples)
Shade variants: Each color has shades from 50 to 950.
Example: outline-blue-50, outline-blue-100, ..., outline-blue-950
Outline Style
Control the style of an element's outline.
Outline Offset
Control the space between an element and its outline.
Accessibility Warning: outline-none
Never remove focus outlines without providing an alternative!
Focus outlines are essential for keyboard navigation. Removing them makes your site inaccessible to users who rely on keyboard navigation (Tab key).
Bad Practice
<button class="outline-none"> Click me </button>
No focus indicator = inaccessible
Good Practice
<button class="outline-none
focus:ring-2
focus:ring-blue-500">
Click me
</button>Ring provides visible focus
Common Usage Patterns
Custom Focus Style
<input class="outline-none
focus:outline-2
focus:outline-blue-500
focus:outline-offset-2" />Dashed Selection Indicator
<div class="outline-2
outline-dashed
outline-gray-400">
Selected item
</div>Button Focus with Ring
<button class="outline-none
focus-visible:ring-2
focus-visible:ring-primary">
Better UX with focus-visible
</button>Thick Outline on Hover
<div class="outline-2
outline-transparent
hover:outline-purple-500
outline-offset-4
transition-all">
Hover me
</div>Frequently Asked Questions
What is the difference between outline, border, and ring in Tailwind CSS?
Border affects layout (takes up space), outline doesn't affect layout (sits outside the element), and ring uses box-shadow (also doesn't affect layout). Ring is Tailwind-specific and provides more flexibility with ring-offset utilities.
Should I use outline-none on focus states?
Never remove focus outlines without providing an alternative focus indicator. This is crucial for keyboard navigation accessibility. If you use outline-none, always pair it with a visible focus style like ring-2 or a custom focus indicator.
What does outline-offset do in Tailwind CSS?
Outline-offset creates space between the element and its outline. Values like outline-offset-2 or outline-offset-4 push the outline away from the element, creating a visual gap that can improve visibility and aesthetics.
When should I use outline vs ring?
Use outline when you need native CSS outline behavior (like for focus states that work with browser defaults). Use ring when you want more control, like using ring-offset to create space between the element and the ring, or when you want to combine it with other box-shadow effects.
Can I use arbitrary values for outline?
Yes! Use bracket notation for custom values: outline-[3px], outline-offset-[6px], or outline-[#custom-color].
Explore more Tailwind tools
Tailwind Grid Generator
Create grid layouts visually
Tailwind Flexbox Generator
Create flex layouts visually
Tailwind Gradient Generator
Create custom gradients
Tailwind Text Gradient
Gradient text effects
Tailwind Gradients Collection
275+ ready-to-use gradients
Tailwind Colors
Complete 240+ color palette
Tailwind Box Shadow Generator
Design multi-layer shadows
Tailwind Text Shadow
Add depth to text with shadows
Tailwind Filter Generator
Apply blur, brightness & more
Tailwind Transform Generator
Rotate, scale & translate elements
Tailwind Animation Generator
Create built-in & custom animations
Tailwind Transition Generator
Smooth hover transitions
Tailwind Config Generator
Generate your config file
Tailwind Input Generator
Design form inputs visually
Tailwind Class Sorter
Organize classes in order
Flexbox Cheatsheet
All flex utilities visualized
Overflow Cheatsheet
Control content overflow
