Skip to content

Commit 6967e61

Browse files
committed
update readme
1 parent df440b7 commit 6967e61

File tree

1 file changed

+48
-37
lines changed

1 file changed

+48
-37
lines changed

README.md

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@ https://tailwindcss-animated.com
55

66
## Installation
77

8-
Install the plugin from npm:
8+
First, install the plugin via npm:
99

1010
```sh
11-
npm i tailwindcss-animated
11+
npm install tailwindcss-animated
1212
```
1313

14-
Then add the plugin to your tailwind.config.js file:
14+
## Import
15+
16+
Second, import it alongside Tailwind CSS in your CSS file:
17+
18+
```css
19+
/* tailwind css v4.x */
20+
@import "tailwindcss";
21+
@import "tailwindcss-animated";
22+
```
23+
24+
Or, if you are using **Tailwind CSS v3.x** or the legacy JavaScript configuration file, import the plugin like this:
1525

1626
```js
1727
// tailwind.config.js
@@ -58,7 +68,9 @@ All animations can be customized with the utility classes below.
5868
| animate-duration-500 | animation-duration: 500ms; |
5969
| animate-duration-700 | animation-duration: 700ms; |
6070
| animate-duration-1000 | animation-duration: 1000ms; |
61-
| animate-duration-\[5s\] [*](#arbitrary-values) | animation-duration: 5s; |
71+
| animate-duration-[*\<value\>*] | animation-duration: *\<value\>* ms; |
72+
| animate-duration-*\<number\>* [*](#custom-properties-and-bare-values) | animation-duration: *\<number\>* ms; |
73+
| animate-duration-(*\<custom-property\>*) [*](#custom-properties-and-bare-values) | animation-duration: var(*\<custom-property\>*); |
6274

6375
### Delay
6476

@@ -73,7 +85,9 @@ All animations can be customized with the utility classes below.
7385
| animate-delay-500 | animation-delay: 500ms; |
7486
| animate-delay-700 | animation-delay: 700ms; |
7587
| animate-delay-1000 | animation-delay: 1000ms; |
76-
| animate-delay-\[5s\] [*](#arbitrary-values) | animation-delay: 5s; |
88+
| animate-delay-[*\<value\>*] | animation-delay: *\<value\>* ms; |
89+
| animate-delay-*\<number\>* [*](#custom-properties-and-bare-values) | animation-delay: *\<number\>* ms; |
90+
| animate-delay-(*\<custom-property\>*) [*](#custom-properties-and-bare-values) | animation-delay: var(*\<custom-property\>*); |
7791

7892
### Direction
7993

@@ -92,7 +106,9 @@ All animations can be customized with the utility classes below.
92106
| animate-once | animation-iteration-count: 1; |
93107
| animate-twice | animation-iteration-count: 2; |
94108
| animate-thrice | animation-iteration-count: 3; |
95-
| animate-iteration-\[10\] [*](#arbitrary-values) | animation-iteration-count: 10; |
109+
| animate-iteration-[*\<number\>*] | animation-iteration-count: *\<number\>*; |
110+
| animate-iteration-*\<number\>* [*](#custom-properties-and-bare-values) | animation-iteration-count: *\<number\>*; |
111+
| animate-iteration-(*\<custom-property\>*) [*](#custom-properties-and-bare-values) | animation-iteration-count: var(*\<custom-property\>*); |
96112

97113
### Timing Function
98114

@@ -103,7 +119,8 @@ All animations can be customized with the utility classes below.
103119
| animate-ease-in | animation-timing-function: cubic-bezier(0.4, 0, 1, 1); |
104120
| animate-ease-out | animation-timing-function: cubic-bezier(0, 0, 0.2, 1); |
105121
| animate-ease-in-out | animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); |
106-
| animate-ease-\[cubic-bezier(1,1,0,0)\] [*](#arbitrary-values) | animation-timing-function: cubic-bezier(1, 1, 0, 0); |
122+
| animate-ease-[*\<value\>*] | animation-timing-function: *\<value\>*; |
123+
| animate-ease-(*\<custom-property\>*) [*](#custom-properties-and-bare-values) | animation-timing-function: var(*\<custom-property\>*); |
107124

108125
### Fill Mode
109126

@@ -143,41 +160,37 @@ All variants and breakpoints (hover, focus, lg, ...) work with animations und an
143160

144161
## Arbitrary values
145162

146-
This plugin uses the Just-in-Time (JIT) engine, which allows you to use [arbitrary values](https://tailwindcss.com/docs/adding-custom-styles#using-arbitrary-values) for most animation properties.
163+
Of course, you can use arbitrary values for animations ultilities:
147164

148165
```html
149166
<div class="animate-delay-[85ms] animate-duration-[2s] animate-iteration-[10]">
150167
<!-- ... -->
151168
</div>
152169
```
153170

154-
## Customizing your theme
171+
## Custom properties and bare values
155172

156-
If you want to change some animations, extend your tailwind.config.js file:
173+
With **Tailwind CSS v4.0** or newer you can use the shorthand syntax for custom properties. Bare values for delay, duration and iteration utilities also work.
157174

158-
```js
159-
// tailwind.config.js
160-
module.exports = {
161-
theme: {
162-
extend: {
163-
animationDelay: {
164-
275: '275ms',
165-
5000: '5s',
166-
},
167-
animationDuration: {
168-
2000: '2s',
169-
'long': '10s',
170-
'very-long': '20s',
171-
},
172-
},
173-
},
174-
plugins: [
175-
require('tailwindcss-animated')
176-
],
177-
}
175+
```html
176+
<div class="animate-delay-(--my-custom-delay) animate-duration-1234">
177+
<!-- ... -->
178+
</div>
178179
```
179180

180-
Take a look at [src/theme.js](https://github.com/new-data-services/tailwindcss-animated/blob/main/src/theme.js) for the default settings.
181+
More information on the new arbitrary value syntax can be found in the [Tailwind CSS Docs](https://tailwindcss.com/docs/adding-custom-styles#using-arbitrary-values).
182+
183+
## Override default values
184+
185+
All animations come with default values for duration, delay and timing function. If you want to overwrite these values globally, you can set the following CSS properties:
186+
187+
```css
188+
:root {
189+
--default-animation-duration: 500ms;
190+
--default-animation-delay: 0s;
191+
--default-animation-timing-function: ease;
192+
}
193+
```
181194

182195
## FAQ
183196

@@ -187,10 +200,6 @@ To run animations when an element enters the viewport, you need JavaScript. (At
187200

188201
A good starting point for a JavaScript solution would be the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API). Or tools that build on it, such as the [Alpine.js Intersect plugin](https://alpinejs.dev/plugins/intersect) and the [Tailwind CSS Intersection plugin](https://github.com/heidkaemper/tailwindcss-intersect), to name just two.
189202

190-
### Does this work with the Play CDN?
191-
192-
Unfortunately not. The Tailwind CSS Play CDN currently does not support third-party plugins.
193-
194203
### How to combine multiple animations?
195204

196205
The simplest approach is to nest two elements:
@@ -207,10 +216,12 @@ Offset positions of predefined animations can't be changed on the fly. But the b
207216

208217
If you need more details on how compositions work, check out the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-composition).
209218

219+
### Does this work with the Play CDN?
210220

221+
Unfortunately not. The Tailwind CSS Play CDN currently does not support third-party plugins.
211222

212223
---
213224

214-
<a href="https://tailwindcss.com/"><img src="https://img.shields.io/badge/Tailwind%20CSS-3.1+-38bdf8?style=for-the-badge"></a>
215-
<a href="https://www.npmjs.com/package/tailwindcss-animated"><img src="https://img.shields.io/npm/v/tailwindcss-animated?style=for-the-badge"></a>
225+
<a href="https://v3.tailwindcss.com/"><img src="https://img.shields.io/badge/Tailwind%20CSS-3.1+-38bdf8?style=for-the-badge"></a>
226+
<a href="https://tailwindcss.com/"><img src="https://img.shields.io/badge/Tailwind%20CSS-4.0+-38bdf8?style=for-the-badge"></a>
216227
<a href="https://www.npmjs.com/package/tailwindcss-animated"><img src="https://img.shields.io/npm/dt/tailwindcss-animated?style=for-the-badge"></a>

0 commit comments

Comments
 (0)