아름다운 애니메이션을 만들기 위한 Tailwind CSS v4.0 유틸리티 모음

hackernews | | 🏗️ 프레임워크
#오픈소스
원문 출처: hackernews · Genesis Park에서 요약 및 분석

요약

이 패키지는 아코디언과 깜빡임 등 즉시 사용 가능한 애니메이션과 유틸리티를 제공하며, 순수 CSS 기반 아키텍처를 채택해 자바스크립트 플러그인 없이 Tailwind CSS 프로젝트에 애니메이션을 쉽게 추가할 수 있습니다. 기존 tailwindcss-animate를 대체하며 곧 출시될 v2.0.0 버전에는 주요 변경사항이 포함될 예정이라 마이그레이션 스크립트와 가이드가 제공됩니다.

본문

A collection of Tailwind CSS v4.0 utilities for creating beautiful animations. Includes ready-to-use animations accordion-down , accordion-up and caret-blink , as well as a set of utilities for creating your own animations. This package is a replacement for tailwindcss-animate . It embraces the new CSS-first architecture, providing a pure CSS solution for adding animation capabilities to your Tailwind CSS project without relying on the legacy JavaScript plugin system or having to define all keywords from scratch. Warning The upcoming release v2.0.0 will include breaking changes. A migration script and a guide will be provided to help you transition smoothly. - Install the package with npm :npm install -D tw-animate-css - Add the following line to your app.css orglobals.css file:@import "tw-animate-css"; - Start using the animations! ... ... ... ... Note The above guide works for esbuild, Vite and probably other bundlers too. If you are using a different bundler, the syntax may differ. Let me know how it works and I'll update the documentation. - Download the tw-animate.css file from GitHub and place it next to yourapp.css orglobals.css file. - Add the following line to your app.css orglobals.css file:@import "./tw-animate.css"; - Start using the animations! ... ... ... ... To keep the README concise, I'll define a few variables: : Specify the type of animation. This can bein for enter orout for exit animations. : Specify the direction of the slide. This can bein-from-top ,in-from-bottom ,in-from-left ,in-from-right ,in-from-start ,in-from-end ,out-to-top ,out-to-bottom ,out-to-left ,out-to-right ,out-to-start , orout-to-end .* : Specify a value to apply. See list of possible values. | Class | Description | |---|---| animate- | Base class for enter/exit animations. This needs to be applied in order for enter/exit animations to work. | To customize the animation parameters, use the following classes: | Class | Description | |---|---| duration-* | Sets animation-duration . Uses --tw-duration , see Tailwind CSS docs. Defaults to duration-150 . | ease-* | Sets animation-timing-function . Uses --tw-ease , see Tailwind CSS docs. Defaults to ease-[ease] . | delay-* | Sets animation-delay . Possible values: Any , initial , or any other [] . | repeat-* | Sets animation-iteration-count . Possible values: Any , infinite , initial or any other [] . | direction-* | Sets animation-direction . Possible values: normal , reverse , alternate , alternate-reverse , initial or any other [] . | fill-mode-* | Sets animation-fill-mode . Possible values: none , forwards , backwards , both , initial or any other [] . | running | Sets animation-play-state to running . | paused | Sets animation-play-state to paused . | play-state-* | Sets animation-play-state . Possible values: initial or any other [] . | | Class | Description | |---|---| blur-in-* | Applies a blur effect on the element when it enters. Possible values: blur-in , blur-in- , blur-in-() , or blur-in-[] . | blur-out-* | Applies a blur effect on the element when it exits. Possible values: blur-out , blur-out- , blur-out-() , or blur-out-[] . | fade- | Fades the element in from or out to opacity: 0 . | fade--* | Fades the element in from or out to the specified value. Possible values: Any (percentage) or any other [] . | zoom- | Zooms the element in from or out to scale3D(0,0,0) . | zoom--* | Zooms the element in from or out to the specified value. Possible values: Any (percentage) or any other [] . | spin- | Spins the element in from or out to rotate(30deg) . | spin--* | Spins the element in from or out to the specified value. Possible values: Any (degrees) or any other [] . | slide- | Slides the element in from or out to the specified direction (100% ). | slide--* | Slides the element in from or out to the specified value. Possible values: Any (percentage) or any other [] . | | Class | Description | |---|---| accordion-down | Accordion down animation. Requires --radix-accordion-content-height or one of the other accordion content height variables to be set to the content's height. | accordion-up | Accordion up animation. Requires --radix-accordion-content-height or one of the other accordion content height variables to be set to the content's height. | collapsible-down | Collapsible down animation. Requires --radix-collapsible-content-height or one of the other collapsible content height variables to be set to the content's height. | collapsible-up | Collapsible up animation. Requires --radix-collapsible-content-height or one of the other collapsible content height variables to be set to the content's height. | caret-blink | Blinking animation for caret/cursor. | By the way, if you don't use some of the above animations, they will not be included in the final CSS file. This is because Tailwind CSS kind of does tree-shaking for you. So, if you don't use accordion-down , it won't be included in the final CSS file. Basic usage: Fade in from 0% opacity, slide from top by 8 spacing units (2rem), with a 500ms duration. Advanced usage: If the element has the data-state="show" attribute, fade in from 0% opacity, slide from top by 8 spacing units (2rem), with a 500ms duration. If the element has the data-state="hide" attribute, fade out to 0% opacity, slide to top by 8 spacing units (2rem), with a 500ms duration. Note I use only a small portion of the original plugin, so it might not be a 100% compatible drop-in replacement. If you notice any inconsistencies, feel free to contribute to this repository by opening a pull-request.

Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.

공유

관련 저널 읽기

전체 보기 →