0.3.4 • Published 12 months ago

tailwindcss-primeui v0.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Tailwind CSS Utilities for Prime UI Libraries

Extended utilities to integrate Prime UI library theming with Tailwind CSS and add the missing animation utilities from the legacy PrimeFlex.

Prime UI Library

This plugin requires a Prime UI library with the next-gen theming, compatible with styled and unstyled modes.

  • primevue v4+
  • primeng v18+
  • @primereact/core v1+

Installation

Install the plugin from npm.

npm i tailwindcss-primeui

Add the plugin to your tailwind.config.js file.

// tailwind.config.js
module.exports = {
    // ...
    plugins: [require('tailwindcss-primeui')]
};

Colors

Prime UI libraries utilize a color palette that consists of primary colors and surfaces, these colors can be used as Tailwind extensions.

<div class="bg-primary text-primary-contrast border-primary-500">Content</div>
<div class="bg-surface-50 dark:bg-surface-900 text-surface-900 dark:text-surface-0 border-surface-200 dark:border-surface-700">Content</div>
ColorDescription
primary-50-950Primary colors
surface-0-950Surface colors
primaryDefault primary color
primary-contrastDefault primary contrast color
primary-emphasisDefault primary emphasis color

Special preset classes defined by the Prime UI library theme preset such as Aura, Lara, or Nora.

ColorDescription
border-surfaceBorder color
bg-emphasisEmphasis background, e.g. hovered element
bg-highlightHighlight background
bg-highlight-emphasisHighlight background with emphasis
rounded-borderBorder radius
text-colorText color
text-color-emphasisText color with emphasis
text-muted-colorSecondary text color
text-muted-color-emphasisSecondary text color with emphasis

Animations

PrimeFlex provide various animation utilities that are missing in Tailwind CSS core, this plugin adds these plugins for migration.

Duration

ClassProperties
animate-duration-0animation-duration: 0s;
animate-duration-75animation-duration: 75ms;
animate-duration-100animation-duration: 100ms;
animate-duration-150animation-duration: 150ms;
animate-duration-200animation-duration: 200ms;
animate-duration-300animation-duration: 300ms;
animate-duration-400animation-duration: 400ms;
animate-duration-500animation-duration: 500ms;
animate-duration-700animation-duration: 700ms;
animate-duration-1000animation-duration: 1000ms;
animate-duration-2000animation-duration: 2000ms;
animate-duration-3000animation-duration: 3000ms;

Delay

ClassProperties
animate-delay-noneanimation-delay: 0ms;
animate-delay-75animation-delay: 75ms;
animate-delay-100animation-delay: 100ms;
animate-delay-150animation-delay: 150ms;
animate-delay-200animation-delay: 200ms;
animate-delay-300animation-delay: 300ms;
animate-delay-400animation-delay: 400ms;
animate-delay-500animation-delay: 500ms;
animate-delay-700animation-delay: 700ms;
animate-delay-1000animation-delay: 1000ms;

Iteration Count

ClassProperties
animate-infiniteanimation-iteration-count: infinite;
animate-onceanimation-iteration-count: 1;
animate-twiceanimation-iteration-count: 2;

Direction

ClassProperties
animate-normalanimation-direction: normal;
animate-reverseanimation-direction: reverse;
animate-alternateanimation-direction: alternate;
animate-alternate-reverseanimation-direction: alternate-reverse;

Timing Function

ClassProperties
animate-ease-linearanimation-timing-function: linear;
animate-ease-inanimation-timing-function: cubic-bezier(0.4, 0, 1, 1);
animate-ease-outanimation-timing-function: cubic-bezier(0, 0, 0.2, 1);
animate-ease-in-outanimation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);

Fill Mode

ClassProperties
animate-fill-noneanimation-fill-mode: normal;
animate-fill-forwardsanimation-fill-mode: forwards;
animate-fill-backwardsanimation-fill-mode: backwards;
animate-fill-bothanimation-fill-mode: both;

Play State

ClassProperties
animate-runninganimation-play-state: running;
animate-pausedanimation-play-state: paused;

Backface Visibility

ClassProperties
backface-visiblebackface-visibility: visible;
backface-hiddenbackface-visibility: hidden;

Animations

ClassProperties
animate-fadeinfadein 0.15s linear
animate-fadeoutfadeout 0.15s linear
animate-slidedownslidedown 0.45s ease-in-out
animate-slideupslideup 0.45s cubic-bezier(0, 1, 0, 1)
animate-scaleinscalein 0.15s linear
animate-fadeinleftfadeinleft 0.15s linear
animate-fadeoutleftfadeoutleft 0.15s linear
animate-fadeinrightfadeinright 0.15s linear
animate-fadeoutrightfadeoutright 0.15s linear
animate-fadeinupfadeinup 0.15s linear
animate-fadeoutupfadeoutup 0.15s linear
animate-fadeindownfadeindown 0.15s linear
animate-fadeoutupfadeoutup 0.15s linear
animate-widthwidth 0.15s linear
animate-flipflip 0.15s linear
animate-flipupflipup 0.15s linear
animate-flipleftflipleft 0.15s linear
animate-fliprightflipright 0.15s linear
animate-zoominzoomin 0.15s linear
animate-zoomindownzoomindown 0.15s linear
animate-zoominleftzoominleft 0.15s linear
animate-zoominrightzoominright 0.15s linear
animate-zoominupzoominup 0.15s linear

Variant modifiers and breakpoints

All variants and breakpoints are supported.

<div class="lg:hover:bg-primary lg:hover:animate-fadein motion-reduce:animate-none">
    <!-- ... -->
</div>

Arbitrary values

Any value within the square brackets allow defining one-off values that do not need to be defined as a reusable utility.

<div class="animate-delay-[450ms] animate-duration-[4s]">
    <!-- ... -->
</div>

Customizing the Plugin

The default values can be customized using as a theme extension.

// tailwind.config.js
module.exports = {
    theme: {
        extend: {
            animationDelay: {
                475: '475ms',
                2000: '2s'
            },
            animationDuration: {
                4000: '4s',
                slow: '10s'
            }
        }
    },
    plugins: [require('tailwindcss-primeui')]
};