Skip to main content

Translate

Utilities for translating an element on all three axis.

ClassProperties
translate-x-0transform: translateX(0rem);
translate-y-0transform: translateY(0rem);
translate-z-0transform: translateZ(0rem);
translate-x-pxtransform: translateX(1px);
translate-y-pxtransform: translateY(1px);
translate-z-pxtransform: translateZ(1px);
translate-x-0.5transform: translateX(0.125rem);
translate-y-0.5transform: translateY(0.125rem);
translate-z-0.5transform: translateZ(0.125rem);
translate-x-1transform: translateX(0.25rem);
translate-y-1transform: translateY(0.25rem);
translate-z-1transform: translateZ(0.25rem);
translate-x-1.5transform: translateX(0.375rem);
translate-y-1.5transform: translateY(0.375rem);
translate-z-1.5transform: translateZ(0.375rem);
translate-x-2transform: translateX(0.5rem);
translate-y-2transform: translateY(0.5rem);
translate-z-2transform: translateZ(0.5rem);
translate-x-2.5transform: translateX(0.625rem);
translate-y-2.5transform: translateY(0.625rem);
translate-z-2.5transform: translateZ(0.625rem);
translate-x-3transform: translateX(0.75rem);
translate-y-3transform: translateY(0.75rem);
translate-z-3transform: translateZ(0.75rem);
translate-x-3.5transform: translateX(0.875rem);
translate-y-3.5transform: translateY(0.875rem);
translate-z-3.5transform: translateZ(0.875rem);
translate-x-4transform: translateX(1rem);
translate-y-4transform: translateY(1rem);
translate-z-4transform: translateZ(1rem);
translate-x-5transform: translateX(1.25rem);
translate-y-5transform: translateY(1.25rem);
translate-z-5transform: translateZ(1.25rem);
translate-x-6transform: translateX(1.5rem);
translate-y-6transform: translateY(1.5rem);
translate-z-6transform: translateZ(1.5rem);
translate-x-7transform: translateX(1.75rem);
translate-y-7transform: translateY(1.75rem);
translate-z-7transform: translateZ(1.75rem);
translate-x-8transform: translateX(2.0rem);
translate-y-8transform: translateY(2.0rem);
translate-z-8transform: translateZ(2.0rem);
translate-x-9transform: translateX(2.25rem);
translate-y-9transform: translateY(2.25rem);
translate-z-9transform: translateZ(2.25rem);
translate-x-10transform: translateX(2.5rem);
translate-y-10transform: translateY(2.5rem);
translate-z-10transform: translateZ(2.5rem);
translate-x-11transform: translateX(2.75rem);
translate-y-11transform: translateY(2.75rem);
translate-z-11transform: translateZ(2.75rem);
translate-x-12transform: translateX(3.0rem);
translate-y-12transform: translateY(3.0rem);
translate-z-12transform: translateZ(3.0rem);
translate-x-14transform: translateX(3.5rem);
translate-y-14transform: translateY(3.5rem);
translate-z-14transform: translateZ(3.5rem);
translate-x-16transform: translateX(4.0rem);
translate-y-16transform: translateY(4.0rem);
translate-z-16transform: translateZ(4.0rem);
translate-x-20transform: translateX(5.0rem);
translate-y-20transform: translateY(5.0rem);
translate-z-20transform: translateZ(5.0rem);
translate-x-24transform: translateX(6.0rem);
translate-y-24transform: translateY(6.0rem);
translate-z-24transform: translateZ(6.0rem);
translate-x-28transform: translateX(7.0rem);
translate-y-28transform: translateY(7.0rem);
translate-z-28transform: translateZ(7.0rem);
translate-x-32transform: translateX(8.0rem);
translate-y-32transform: translateY(8.0rem);
translate-z-32transform: translateZ(8.0rem);
translate-x-36transform: translateX(9.0rem);
translate-y-36transform: translateY(9.0rem);
translate-z-36transform: translateZ(9.0rem);
translate-x-40transform: translateX(10.0rem);
translate-y-40transform: translateY(10.0rem);
translate-z-40transform: translateZ(10.0rem);
translate-x-44transform: translateX(11.0rem);
translate-y-44transform: translateY(11.0rem);
translate-z-44transform: translateZ(11.0rem);
translate-x-48transform: translateX(12.0rem);
translate-y-48transform: translateY(12.0rem);
translate-z-48transform: translateZ(12.0rem);
translate-x-52transform: translateX(13.0rem);
translate-y-52transform: translateY(13.0rem);
translate-z-52transform: translateZ(13.0rem);
translate-x-56transform: translateX(14.0rem);
translate-y-56transform: translateY(14.0rem);
translate-z-56transform: translateZ(14.0rem);
translate-x-60transform: translateX(15.0rem);
translate-y-60transform: translateY(15.0rem);
translate-z-60transform: translateZ(15.0rem);
translate-x-64transform: translateX(16.0rem);
translate-y-64transform: translateY(16.0rem);
translate-z-64transform: translateZ(16.0rem);
translate-x-72transform: translateX(18.0rem);
translate-y-72transform: translateY(18.0rem);
translate-z-72transform: translateZ(18.0rem);
translate-x-80transform: translateX(20.0rem);
translate-y-80transform: translateY(20.0rem);
translate-z-80transform: translateZ(20.0rem);
translate-x-96transform: translateX(24.0rem);
translate-y-96transform: translateY(24.0rem);
translate-z-96transform: translateZ(24.0rem);
translate-x-1/2transform: translateX(50%);
translate-y-1/2transform: translateY(50%);
translate-z-1/2transform: translateZ(50%);
translate-x-1/3transform: translateX(33.333%);
translate-y-1/3transform: translateY(33.333%);
translate-z-1/3transform: translateZ(33.333%);
translate-x-2/3transform: translateX(66.666%);
translate-y-2/3transform: translateY(66.666%);
translate-z-2/3transform: translateZ(66.666%);
translate-x-1/4transform: translateX(25%);
translate-y-1/4transform: translateY(25%);
translate-z-1/4transform: translateZ(25%);
translate-x-2/4transform: translateX(50%);
translate-y-2/4transform: translateY(50%);
translate-z-2/4transform: translateZ(50%);
translate-x-3/4transform: translateX(75%);
translate-y-3/4transform: translateY(75%);
translate-z-3/4transform: translateZ(75%);
translate-x-fulltransform: translateX(100%);
translate-y-fulltransform: translateY(100%);
translate-z-fulltransform: translateZ(100%);
translate-3d-valuetransform: translate3d(value, value, value);

Basic Usage

You can translate on all axes using different translate classes provided. Default translate values are supported. For instance to translate 4rem on x axis and 20px on y axis, you can use,

<div class="transform tranlate-x-20 translate-y-[20px]"><!--Some Content--></div>

This is another example using tailwind defaults,

<div class="perspective-1200">
<div class="transform translate-x-1/2 -translate-y-24 translate-z-12">My element</div>
</div>
Remember to add transform class

Plugin requires you to add transform class along with other transform classes to apply the effect.
For example, instead of translate-y-20, use transform translate-y-20.
Read more on this here.

No transforms
translate-x-10
translate-y-16
translate-x-10
translate-y-16
translate-z-10
Applying different classes for translate
<div class="flex space-x-10">
<div class="w-52 h-52">
<div class="w-20 h-20">
</div>
</div>
<div class="w-52 h-52">
<div class="w-20 h-20 transform translate-x-10 translate-y-16">
</div>
</div>
<div class="w-52 h-52 transform rotate-x-30">
<div class="w-20 h-20 transform translate-x-10 translate-y-16 translate-z-10">
</div>
</div>
</div>

Customizing Your Theme

We extend the default theme by adding additional values for translate key. You can add any custom values from tailwind.config.js file.

module.exports = {
theme: {
extend: {
translate: {
'4.25': '18rem',
}
}
}
}

Arbitrary Values

If you need to use an custom value for translate, you can use the following syntax.

<div class="translate-x-[250px]">
<!-- More Items -->
</div>

Learn more about arbitrary value support in the tailwindcss arbitrary values documentation.

Read More

To learn more about css translate transform refer here.

info

You can use modifiers such as md:translate-x-60 to target media queries, hover, active... etc. You can read about modifiers here.