Skip to content

Latest commit

 

History

History
256 lines (229 loc) · 15.1 KB

exit-animation-translate.md

File metadata and controls

256 lines (229 loc) · 15.1 KB

Exit Animation Translate

Utilities for controlling the ending scale of exit animations.

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

Basic Usage

Changing exit animation ending translate

Set the ending translate of an animation using the slide-out-to-{direction}-{amount} utilities.

<button class="animate-out slide-out-to-top ...">Button A</button>
<button class="animate-out slide-out-to-bottom-50 ...">Button B</button>
<button class="animate-out slide-out-to-left-75 ...">Button C</button>
<button class="animate-out slide-out-to-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-out-to-right to only apply the slide-out-to-right utility on hover.

<div class="animate-out slide-out-to-left hover:slide-out-to-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-out-to-right to apply the slide-out-to-right utility at only medium screen sizes and above.

<div class="animate-out slide-out-to-left md:slide-out-to-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-out-to-left-[17rem]">
	<!-- ... -->
</div>

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