--- name: transform-translate description: Translating elements on x, y, and z axes with spacing scale, percentages, and custom values --- # Translate Utilities for translating (moving) elements. ## Usage ### Spacing scale Use `translate-` to translate on both axes, or `translate-x-` / `translate-y-` for single axis: ```html
Moved 2 units
Moved -4 units
Moved right 4 units
Moved down 6 units
``` ### Percentage translation Use `translate-` to translate by percentage of element size: ```html
Moved 50% on both axes
Moved 25% right
Moved 100% up
``` ### Centering elements Common pattern for centering absolutely positioned elements: ```html
Centered
``` ### Z-axis translation Use `translate-z-` for 3D translation (requires `transform-3d` on parent): ```html
Forward in 3D space
Backward in 3D space
``` ### Custom values Use arbitrary values for custom translations: ```html
Custom translation
Custom pixel value
``` ## Key Points - `translate-*` moves on both x and y axes - `translate-x-*` moves horizontally (right = positive) - `translate-y-*` moves vertically (down = positive) - `translate-z-*` moves in 3D space (forward = positive) - Negative values use dash prefix: `-translate-4`, `-translate-x-8` - Percentages are relative to element's own size - Common centering: `top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2` - Z-axis requires `transform-3d` utility on parent element