API

css.keyframes

★★★★★ Frozen

CSS animations you can play from any style, including on hover.

export type keyframes = <const T extends Keyframes>(rule: T) => string;
export const keyframes: keyframes;

keyframes() defines an @keyframes rule and returns its name, a unique hash inlined at build time, for use as animationName.

Example

TypeScript
import * as css from '@plumeria/core'

const fadeIn = css.keyframes({
  from: {
    opacity: 0,
  },
  to: {
    opacity: 1,
  },
});

const styles = css.create({
  box: {
    animationName: fadeIn,
    animationDuration: '1s',
    animationTimingFunction: 'ease-in-out',
  },
});

Usage

An animation can start from a pseudo-class such as :hover:

const styles = css.create({
  card: {
    transition: 'transform 0.3s ease',
    ':hover': {
      animationName: fadeIn,
      animationDuration: '0.5s',
    },
  },
});
Edit on GitHub