Skip to main content

Perspective Origin

Utilities for setting perspective origin css property.

ClassProperties
transform-box-contenttransform-box: content-box;
transform-box-bordertransform-box: border-box;
transform-box-filltransform-box: fill-box;
transform-box-stroketransform-box: stroke-box;
transform-box-viewtransform-box: view-box;

Basic Usage

Use perspective-origin classes set the perspective origin property which is used to determine the position at which the viewer is looking. See more on perspective origin from MDN reference. This is used along with perspective class.

For instance you can use,

<div class="perspective-800 perspective-origin-top-left">
<!--Some elementes-->
</div>

Customizing Your Theme

This takes the same values as transformOrigin. We can add new perspective-origin classes by extend the default theme by giving additional values for transformOrigin key.

module.exports = {
theme: {
extend: {
transformOrigin: {
'1/2': '50%',
}
}
}
}

Arbitrary Values

Use usual bracket syntax to add arbitrary values for perspective origin. If you have two values, then join them with _ char. For example,

       <div class="perspective-origin-[40%_50%]">
<!-- html content -->
</div>

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