Pseudo class watch out for ':root' - that could use '*' instead
Creates an sheet which inserts style rules through the CSS Object Model.
Returns an optimized and cached function for use with tw
.
tw
caches rules based on the function identity. This helper caches
the function based on the data.
to use when the directive is invoked
to use
```js const bounce = keyframes({ 'from, 20%, 53%, 80%, to': { transform: 'translate3d(0,0,0)', }, '40%, 43%': { transform: 'translate3d(0, -30px, 0)', }, '70%': { transform: 'translate3d(0, -15px, 0)', }, '90%': { transform: 'translate3d(0, -4px, 0)', } })
css({
animation: ${bounce} 1s ease infinite
,
})
```
```js const bounce = keyframes({ 'from, 20%, 53%, 80%, to': { transform: 'translate3d(0,0,0)', }, '40%, 43%': { transform: 'translate3d(0, -30px, 0)', }, '70%': { transform: 'translate3d(0, -15px, 0)', }, '90%': { transform: 'translate3d(0, -4px, 0)', } })
css({
animation: ${bounce} 1s ease infinite
,
})
```
```js const bounce = keyframes({ 'from, 20%, 53%, 80%, to': { transform: 'translate3d(0,0,0)', }, '40%, 43%': { transform: 'translate3d(0, -30px, 0)', }, '70%': { transform: 'translate3d(0, -15px, 0)', }, '90%': { transform: 'translate3d(0, -4px, 0)', } })
css({
animation: ${bounce} 1s ease infinite
,
})
```
An sheet placeholder which performs no operations. Useful for avoiding errors in a non-browser environment.
Generated using TypeDoc
Sometimes you might find yourself wanting to write some arbitrary styles for an element. Some rule that isn't covered by Tailwind API but perhaps isn't general enough to warrant creating a real plugin for.
CSS directive
Essentially the css directive uses some CSS rules in object notation, array or template literal format to create a optimized inline plugin. Here you can use the
&
selector to target the current element much like in other CSS-in-JS libraries. In this way, it is possible to write styles that cannot be described using an inline style attribute alone; things like specific children selectors.For best performance it is advised to extract CSS directive into a variable:
Furthermore any variants or groupings that are active when the CSS directive is called, will be respected by the return value. Meaning that you can scope CSS directives with responsive variants:
Values within the CSS object can be functions which are called with the
context
and should return the value to be used:css
allows to define global styles using the:global
selector:Tagged template literal syntax works like in emotion, goober or styled-components:
Variadic arguments and arrays (nested as deep as you like) are supported as well:
apply can be used within
css
:Accessing the theme
Values of the CSS object maybe functions that are passed the context and should return the value to be used:
Screen Directive
The
screen
directive allows you to create media queries that reference your breakpoints by name instead of duplicating their values in your own CSS.For example, say you have a
sm
breakpoint at640px
and you need to write some custom CSS that references this breakpoint.Instead of writing a raw media query that duplicates that value like this:
...you can use the
screen
directive and reference the breakpoint by name:Animation Directive
Custom animations are difficult to configure in Tailwind. During twind.setup you need to add to the
theme.animation
section and thetheme.keyframes
section. This means all animations must known before hand and you can not use "one-off" animations.With the animation exports this task is greatly simplified:
Template literal syntax is supported as well:
The first argument can be a animation shorthand CSS string, an object of CSS animation properties or a function which is passed the context to return the shorthand CSS:
The second parameter are the waypoints of a @keyframes at-rule in CSS object format. The keyframes helper can be used the create waypoints.
The result of
animation
can be used withincss
:Keyframes Helper
The keyframes export helps to create custom @keyframes:
Template literal syntax is supported as well:
The returned values can be used like this: