Positions
Utilities for controlling element positioning.Import
API
Frompositions/positions.js:29:
Position Property
Set the position type:positions.js:4-6:
Z-Index
Control stacking order with theme integration:positions.js:8-11:
Theme zIndex Values
Offset Properties
top
Set distance from top edge:positions.js:13-15:
right
Set distance from right edge:positions.js:17-19:
bottom
Set distance from bottom edge:positions.js:21-23:
left
Set distance from left edge:positions.js:25-27:
Common Patterns
Centered Absolute Element
Corner Positioning
Fixed Header
Sticky Sidebar
Floating Action Button
Modal Overlay
Notification Badge
Tooltip Positioning
Sidebar Layout
Responsive Positioning
Layering with zIndex
With sx Prop
TypeScript
Available Properties
| Prop | CSS Property | Theme Key | Values |
|---|---|---|---|
position | position | - | static, relative, absolute, fixed, sticky |
zIndex | z-index | zIndex | Number or theme key |
top | top | - | Length value |
right | right | - | Length value |
bottom | bottom | - | Length value |
left | left | - | Length value |
Best Practices
- Use relative positioning for containers - Create positioning contexts
- Theme zIndex values - Use theme values for consistent layering
- Avoid fixed positioning on mobile - Can interfere with scrolling
- Use sticky for headers - Better UX than fixed in most cases
- Center with transform - Use
transform: translate(-50%, -50%)for perfect centering
Related
- Box Component - Using positions with Box
- Display - Display utilities
- sx Prop - Advanced positioning with sx