Position Offset Utilities top/right/bottom/left
Control the placement of positioned elements with top, right, bottom, and left offset utilities.
Quick Reference
top-0
Align to top edge
top: 0px
right-4
16px from right
right: 1rem
bottom-8
32px from bottom
bottom: 2rem
left-1/2
50% from left
left: 50%
inset-0
All sides 0
top/right/bottom/left: 0
inset-x-4
Horizontal inset
left/right: 1rem
inset-y-2
Vertical inset
top/bottom: 0.5rem
-top-4
Negative offset
top: -1rem
Interactive Examples
Basic Position Offsets
<div class="absolute top-4 right-4">Positioned</div>
Inset Utilities
inset-0 (Full overlay)
inset-x-4 (Horizontal inset)
inset-y-2 (Vertical inset)
Negative Offsets
✓ Elements can extend outside container
✓ Useful for overlapping effects
⚠️ May require overflow-visible on parent
Responsive Positioning
✓ Position changes based on screen size
✓ Great for mobile-first design
✓ Combine with responsive positioning types
<div class="absolute top-2 left-2 md:top-4 md:right-4">
Responsive positioning
</div>
Common Use Cases
🎯 Tooltips
Position tooltips relative to trigger elements.
<div class="absolute -top-2 left-1/2">
🏷️ Badges
Position notification badges on buttons or avatars.
<span class="absolute -top-1 -right-1">
🖼️ Image Overlays
Create full or partial overlays on images.
<div class="absolute inset-0">
📱 Fixed Elements
Position fixed headers, footers, or floating buttons.
<div class="fixed top-0 left-0 right-0">
🎨 Decorative Elements
Position decorative shapes or backgrounds.
<div class="absolute -top-4 -left-4">
📊 Chart Annotations
Position labels and annotations on charts.
<div class="absolute top-1/4 left-3/4">
Position Values Reference
Spacing Scale
top-0
0pxtop-px
1pxtop-1
4pxtop-2
8pxtop-4
16pxtop-8
32pxtop-16
64pxtop-32
128pxPercentage Values
top-1/2
50%top-1/3
33.333%top-2/3
66.667%top-1/4
25%top-3/4
75%top-full
100%✓ Percentage values are relative to the containing block
✓ Useful for responsive positioning
✓ Combine with transform for centering
Best Practices
✅ Do
- • Use
inset-0
for full overlays - • Combine percentage values with transform for centering
- • Use negative values for overlapping effects
- • Test positioning on different screen sizes
- • Use responsive variants for mobile-first design
- • Consider z-index when elements overlap
❌ Don't
- • Use positioning offsets on static elements
- • Forget about overflow when using negative values
- • Use complex positioning when simpler solutions exist
- • Ignore accessibility when positioning content
- • Use fixed positioning without considering mobile
- • Create overly complex positioning hierarchies