Transforms
Utilities for controlling an element'ss perspective when placed in 3D space.
Class | Styles |
---|---|
perspective-dramatic | perspective: var(--perspective-dramatic); /* 100px */ |
perspective-near | perspective: var(--perspective-near); /* 300px */ |
perspective-normal | perspective: var(--perspective-normal); /* 500px */ |
perspective-midrange | perspective: var(--perspective-midrange); /* 800px */ |
perspective-distant | perspective: var(--perspective-distant); /* 1200px */ |
perspective-none | perspective: none; |
perspective-(<custom-property>) | perspective: var(<custom-property>); |
perspective-[<value>] | perspective: <value>; |
Use utilities like perspective-normal
and perspective-distant
to control how close or how far away the z-plane is from the screen:
This is like moving a camera closer to or further away from an object.
Use the perspective-none
utility to remove a perspective transform from an element:
<div class="perspective-none ..."> <!-- ... --></div>
Use the perspective-[<value>]
syntax to set the perspective based on a completely custom value:
<div class="perspective-[750px] ..."> <!-- ... --></div>
For CSS variables, you can also use the perspective-(<custom-property>)
syntax:
<div class="perspective-(--my-perspective) ..."> <!-- ... --></div>
This is just a shorthand for perspective-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix a perspective
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="perspective-midrange md:perspective-dramatic ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.
Use the --perspective-*
theme variables to customize the perspective utilities in your project:
@theme { --perspective-remote: 1800px; }
Now the perspective-remote
utility can be used in your markup:
<div class="perspective-remote"> <!-- ... --></div>
Learn more about customizing your theme in the theme documentation.