Skip to content

Latest commit

 

History

History
256 lines (229 loc) · 15.4 KB

enter-animation-translate.md

File metadata and controls

256 lines (229 loc) · 15.4 KB

Enter Animation Translate

Utilities for controlling the starting scale of enter animations.

Class Properties
slide-in-from-top --tw-enter-translate-x: -100%;
slide-in-from-bottom --tw-enter-translate-x: 100%;
slide-in-from-left --tw-enter-translate-y: -100%;
slide-in-from-right --tw-enter-translate-y: 100%;
slide-in-from-top-0 --tw-enter-translate-x: -0px;
slide-in-from-bottom-0 --tw-enter-translate-x: 0px;
slide-in-from-left-0 --tw-enter-translate-y: -0px;
slide-in-from-right-0 --tw-enter-translate-y: 0px;
slide-in-from-top-px --tw-enter-translate-x: -1px;
slide-in-from-bottom-px --tw-enter-translate-x: 1px;
slide-in-from-left-px --tw-enter-translate-y: -1px;
slide-in-from-right-px --tw-enter-translate-y: 1px;
slide-in-from-top-0.5 --tw-enter-translate-x: -0.125rem;
slide-in-from-bottom-0.5 --tw-enter-translate-x: 0.125rem;
slide-in-from-left-0.5 --tw-enter-translate-y: -0.125rem;
slide-in-from-right-0.5 --tw-enter-translate-y: 0.125rem;
slide-in-from-top-1 --tw-enter-translate-x: -0.25rem;
slide-in-from-bottom-1 --tw-enter-translate-x: 0.25rem;
slide-in-from-left-1 --tw-enter-translate-y: -0.25rem;
slide-in-from-right-1 --tw-enter-translate-y: 0.25rem;
slide-in-from-top-1.5 --tw-enter-translate-x: -0.375rem;
slide-in-from-bottom-1.5 --tw-enter-translate-x: 0.375rem;
slide-in-from-left-1.5 --tw-enter-translate-y: -0.375rem;
slide-in-from-right-1.5 --tw-enter-translate-y: 0.375rem;
slide-in-from-top-2 --tw-enter-translate-x: -0.5rem;
slide-in-from-bottom-2 --tw-enter-translate-x: 0.5rem;
slide-in-from-left-2 --tw-enter-translate-y: -0.5rem;
slide-in-from-right-2 --tw-enter-translate-y: 0.5rem;
slide-in-from-top-2.5 --tw-enter-translate-x: -0.625rem;
slide-in-from-bottom-2.5 --tw-enter-translate-x: 0.625rem;
slide-in-from-left-2.5 --tw-enter-translate-y: -0.625rem;
slide-in-from-right-2.5 --tw-enter-translate-y: 0.625rem;
slide-in-from-top-3 --tw-enter-translate-x: -0.75rem;
slide-in-from-bottom-3 --tw-enter-translate-x: 0.75rem;
slide-in-from-left-3 --tw-enter-translate-y: -0.75rem;
slide-in-from-right-3 --tw-enter-translate-y: 0.75rem;
slide-in-from-top-3.5 --tw-enter-translate-x: -0.875rem;
slide-in-from-bottom-3.5 --tw-enter-translate-x: 0.875rem;
slide-in-from-left-3.5 --tw-enter-translate-y: -0.875rem;
slide-in-from-right-3.5 --tw-enter-translate-y: 0.875rem;
slide-in-from-top-4 --tw-enter-translate-x: -1rem;
slide-in-from-bottom-4 --tw-enter-translate-x: 1rem;
slide-in-from-left-4 --tw-enter-translate-y: -1rem;
slide-in-from-right-4 --tw-enter-translate-y: 1rem;
slide-in-from-top-5 --tw-enter-translate-x: -1.25rem;
slide-in-from-bottom-5 --tw-enter-translate-x: 1.25rem;
slide-in-from-left-5 --tw-enter-translate-y: -1.25rem;
slide-in-from-right-5 --tw-enter-translate-y: 1.25rem;
slide-in-from-top-6 --tw-enter-translate-x: -1.5rem;
slide-in-from-bottom-6 --tw-enter-translate-x: 1.5rem;
slide-in-from-left-6 --tw-enter-translate-y: -1.5rem;
slide-in-from-right-6 --tw-enter-translate-y: 1.5rem;
slide-in-from-top-7 --tw-enter-translate-x: -1.75rem;
slide-in-from-bottom-7 --tw-enter-translate-x: 1.75rem;
slide-in-from-left-7 --tw-enter-translate-y: -1.75rem;
slide-in-from-right-7 --tw-enter-translate-y: 1.75rem;
slide-in-from-top-8 --tw-enter-translate-x: -2rem;
slide-in-from-bottom-8 --tw-enter-translate-x: 2rem;
slide-in-from-left-8 --tw-enter-translate-y: -2rem;
slide-in-from-right-8 --tw-enter-translate-y: 2rem;
slide-in-from-top-9 --tw-enter-translate-x: -2.25rem;
slide-in-from-bottom-9 --tw-enter-translate-x: 2.25rem;
slide-in-from-left-9 --tw-enter-translate-y: -2.25rem;
slide-in-from-right-9 --tw-enter-translate-y: 2.25rem;
slide-in-from-top-10 --tw-enter-translate-x: -2.5rem;
slide-in-from-bottom-10 --tw-enter-translate-x: 2.5rem;
slide-in-from-left-10 --tw-enter-translate-y: -2.5rem;
slide-in-from-right-10 --tw-enter-translate-y: 2.5rem;
slide-in-from-top-11 --tw-enter-translate-x: -2.75rem;
slide-in-from-bottom-11 --tw-enter-translate-x: 2.75rem;
slide-in-from-left-11 --tw-enter-translate-y: -2.75rem;
slide-in-from-right-11 --tw-enter-translate-y: 2.75rem;
slide-in-from-top-12 --tw-enter-translate-x: -3rem;
slide-in-from-bottom-12 --tw-enter-translate-x: 3rem;
slide-in-from-left-12 --tw-enter-translate-y: -3rem;
slide-in-from-right-12 --tw-enter-translate-y: 3rem;
slide-in-from-top-14 --tw-enter-translate-x: -3.5rem;
slide-in-from-bottom-14 --tw-enter-translate-x: 3.5rem;
slide-in-from-left-14 --tw-enter-translate-y: -3.5rem;
slide-in-from-right-14 --tw-enter-translate-y: 3.5rem;
slide-in-from-top-16 --tw-enter-translate-x: -4rem;
slide-in-from-bottom-16 --tw-enter-translate-x: 4rem;
slide-in-from-left-16 --tw-enter-translate-y: -4rem;
slide-in-from-right-16 --tw-enter-translate-y: 4rem;
slide-in-from-top-20 --tw-enter-translate-x: -5rem;
slide-in-from-bottom-20 --tw-enter-translate-x: 5rem;
slide-in-from-left-20 --tw-enter-translate-y: -5rem;
slide-in-from-right-20 --tw-enter-translate-y: 5rem;
slide-in-from-top-24 --tw-enter-translate-x: -6rem;
slide-in-from-bottom-24 --tw-enter-translate-x: 6rem;
slide-in-from-left-24 --tw-enter-translate-y: -6rem;
slide-in-from-right-24 --tw-enter-translate-y: 6rem;
slide-in-from-top-28 --tw-enter-translate-x: -7rem;
slide-in-from-bottom-28 --tw-enter-translate-x: 7rem;
slide-in-from-left-28 --tw-enter-translate-y: -7rem;
slide-in-from-right-28 --tw-enter-translate-y: 7rem;
slide-in-from-top-32 --tw-enter-translate-x: -8rem;
slide-in-from-bottom-32 --tw-enter-translate-x: 8rem;
slide-in-from-left-32 --tw-enter-translate-y: -8rem;
slide-in-from-right-32 --tw-enter-translate-y: 8rem;
slide-in-from-top-36 --tw-enter-translate-x: -9rem;
slide-in-from-bottom-36 --tw-enter-translate-x: 9rem;
slide-in-from-left-36 --tw-enter-translate-y: -9rem;
slide-in-from-right-36 --tw-enter-translate-y: 9rem;
slide-in-from-top-40 --tw-enter-translate-x: -10rem;
slide-in-from-bottom-40 --tw-enter-translate-x: 10rem;
slide-in-from-left-40 --tw-enter-translate-y: -10rem;
slide-in-from-right-40 --tw-enter-translate-y: 10rem;
slide-in-from-top-44 --tw-enter-translate-x: -11rem;
slide-in-from-bottom-44 --tw-enter-translate-x: 11rem;
slide-in-from-left-44 --tw-enter-translate-y: -11rem;
slide-in-from-right-44 --tw-enter-translate-y: 11rem;
slide-in-from-top-48 --tw-enter-translate-x: -12rem;
slide-in-from-bottom-48 --tw-enter-translate-x: 12rem;
slide-in-from-left-48 --tw-enter-translate-y: -12rem;
slide-in-from-right-48 --tw-enter-translate-y: 12rem;
slide-in-from-top-52 --tw-enter-translate-x: -13rem;
slide-in-from-bottom-52 --tw-enter-translate-x: 13rem;
slide-in-from-left-52 --tw-enter-translate-y: -13rem;
slide-in-from-right-52 --tw-enter-translate-y: 13rem;
slide-in-from-top-56 --tw-enter-translate-x: -14rem;
slide-in-from-bottom-56 --tw-enter-translate-x: 14rem;
slide-in-from-left-56 --tw-enter-translate-y: -14rem;
slide-in-from-right-56 --tw-enter-translate-y: 14rem;
slide-in-from-top-60 --tw-enter-translate-x: -15rem;
slide-in-from-bottom-60 --tw-enter-translate-x: 15rem;
slide-in-from-left-60 --tw-enter-translate-y: -15rem;
slide-in-from-right-60 --tw-enter-translate-y: 15rem;
slide-in-from-top-64 --tw-enter-translate-x: -16rem;
slide-in-from-bottom-64 --tw-enter-translate-x: 16rem;
slide-in-from-left-64 --tw-enter-translate-y: -16rem;
slide-in-from-right-64 --tw-enter-translate-y: 16rem;
slide-in-from-top-72 --tw-enter-translate-x: -18rem;
slide-in-from-bottom-72 --tw-enter-translate-x: 18rem;
slide-in-from-left-72 --tw-enter-translate-y: -18rem;
slide-in-from-right-72 --tw-enter-translate-y: 18rem;
slide-in-from-top-80 --tw-enter-translate-x: -20rem;
slide-in-from-bottom-80 --tw-enter-translate-x: 20rem;
slide-in-from-left-80 --tw-enter-translate-y: -20rem;
slide-in-from-right-80 --tw-enter-translate-y: 20rem;
slide-in-from-top-96 --tw-enter-translate-x: -24rem;
slide-in-from-bottom-96 --tw-enter-translate-x: 24rem;
slide-in-from-left-96 --tw-enter-translate-y: -24rem;
slide-in-from-right-96 --tw-enter-translate-y: 24rem;
slide-in-from-top-1/2 --tw-enter-translate-x: -50%;
slide-in-from-bottom-1/2 --tw-enter-translate-x: 50%;
slide-in-from-left-1/2 --tw-enter-translate-y: -50%;
slide-in-from-right-1/2 --tw-enter-translate-y: 50%;
slide-in-from-top-1/3 --tw-enter-translate-x: -33.333333%;
slide-in-from-bottom-1/3 --tw-enter-translate-x: 33.333333%;
slide-in-from-left-1/3 --tw-enter-translate-y: -33.333333%;
slide-in-from-right-1/3 --tw-enter-translate-y: 33.333333%;
slide-in-from-top-2/3 --tw-enter-translate-x: -66.666667%;
slide-in-from-bottom-2/3 --tw-enter-translate-x: 66.666667%;
slide-in-from-left-2/3 --tw-enter-translate-y: -66.666667%;
slide-in-from-right-2/3 --tw-enter-translate-y: 66.666667%;
slide-in-from-top-1/4 --tw-enter-translate-x: -25%;
slide-in-from-bottom-1/4 --tw-enter-translate-x: 25%;
slide-in-from-left-1/4 --tw-enter-translate-y: -25%;
slide-in-from-right-1/4 --tw-enter-translate-y: 25%;
slide-in-from-top-2/4 --tw-enter-translate-x: -50%;
slide-in-from-bottom-2/4 --tw-enter-translate-x: 50%;
slide-in-from-left-2/4 --tw-enter-translate-y: -50%;
slide-in-from-right-2/4 --tw-enter-translate-y: 50%;
slide-in-from-top-3/4 --tw-enter-translate-x: -75%;
slide-in-from-bottom-3/4 --tw-enter-translate-x: 75%;
slide-in-from-left-3/4 --tw-enter-translate-y: -75%;
slide-in-from-right-3/4 --tw-enter-translate-y: 75%;
slide-in-from-top-full --tw-enter-translate-x: -100%;
slide-in-from-bottom-full --tw-enter-translate-x: 100%;
slide-in-from-left-full --tw-enter-translate-y: -100%;
slide-in-from-right-full --tw-enter-translate-y: 100%;

Basic Usage

Changing enter animation starting translate

Set the starting translate of an animation using the slide-in-from-{direction}-{amount} utilities.

<button class="animate-in slide-in-from-top ...">Button A</button>
<button class="animate-in slide-in-from-bottom-50 ...">Button B</button>
<button class="animate-in slide-in-from-left-75 ...">Button C</button>
<button class="animate-in slide-in-from-right-95 ...">Button C</button>

Applying Conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:slide-in-from-right to only apply the slide-in-from-right utility on hover.

<div class="animate-in slide-in-from-left hover:slide-in-from-right">
	<!-- ... -->
</div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:slide-in-from-right to apply the slide-in-from-right utility at only medium screen sizes and above.

<div class="animate-in slide-in-from-left md:slide-in-from-right">
	<!-- ... -->
</div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.

Using custom values

Customizing your theme

By default, Tailwind makes the entire default translate scale available as animation translate scale. You can customize your translate by editing theme.translate or theme.extend.translate in your tailwind.config.js file.

// @filename tailwind.config.js
module.exports = {
	theme: {
		extend: {
			translate: {
				4.25: "17rem",
			},
		},
	},
}

Alternatively, you can customize just your animation translate scale by editing theme.animationTranslate or theme.extend.animationTranslate in your tailwind.config.js file.

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off animation translation value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

<div class="slide-in-from-left-[17rem]">
	<!-- ... -->
</div>

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