All Projects → soueuls → tailwind-color-alpha

soueuls / tailwind-color-alpha

Licence: MIT license
Automatic alpha variants for your Tailwind CSS colors based on your opacity config

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to tailwind-color-alpha

intellij-tailwind-css
Tailwind IntelliJ Plugin Tailwind Cheat Sheet
Stars: ✭ 49 (+133.33%)
Mutual labels:  tailwindcss, tailwind-css, tailwindcss-plugin
tailwindcss-background-extended
All of the missing background utilities for Tailwind CSS.
Stars: ✭ 25 (+19.05%)
Mutual labels:  tailwind, tailwind-css, tailwindcss-plugin
variantwind
Most elegant way to work with TailwindCSS variants in Vue
Stars: ✭ 45 (+114.29%)
Mutual labels:  tailwind, tailwindcss, tailwindcss-plugin
tailwindcss-postcss-browsersync-boilerplate
Tailwind CSS + PostCSS + BrowserSync boilerplate
Stars: ✭ 28 (+33.33%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
cra-tailwindcss
Integrate Tailwind CSS in a Create React App setup
Stars: ✭ 105 (+400%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
eslint-plugin-tailwind
ESLint rules for Tailwind CSS
Stars: ✭ 97 (+361.9%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
tailwindcss-scrims
Configurable Tailwind plugin for generating scrim classes.
Stars: ✭ 35 (+66.67%)
Mutual labels:  tailwind, tailwind-css, tailwindcss-plugin
material-tailwind
@material-tailwind is an easy-to-use components library for Tailwind CSS and Material Design.
Stars: ✭ 861 (+4000%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
tailwind-ui-components
Free Tailwind CSS UI Components - Crafted for modern websites, landing pages and web apps. TailGrids Core is free and open-source so, feel free to use with your personal or commercial projects. If you would like to show your support and love, don't forget to give us a star 🌟
Stars: ✭ 49 (+133.33%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
react-tailwind
This is a complementary React code for the tailwindcss project.
Stars: ✭ 29 (+38.1%)
Mutual labels:  tailwind, tailwindcss, tailwindcss-plugin
memento-svelte-electron-typescript
Template to create a desktop app with Svelte, TailwindCSS, Electron and TypeScript (with electron-updater, electron-reload and electron-builder)
Stars: ✭ 27 (+28.57%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
vuejs-tailwindcss-portfolio
A simple multipage and responsive Vue.js & Tailwind CSS portfolio theme with dark mode.
Stars: ✭ 100 (+376.19%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
Next-JS-Landing-Page-Starter-Template
🚀 Free NextJS Landing Page Template written in Tailwind CSS 3 and TypeScript ⚡️ Made with developer experience first: Next.js 12 + TypeScript + ESLint + Prettier + Husky + Lint-Staged + VSCode + Netlify + PostCSS + Tailwind CSS
Stars: ✭ 521 (+2380.95%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
Twin.macro
🦹‍♂️ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, stitches and goober) at build time.
Stars: ✭ 5,137 (+24361.9%)
Mutual labels:  tailwind, tailwindcss, tailwind-css
tailwind-shift
⚙️ Shift to the next TailwindCSS version hassle-free.
Stars: ✭ 114 (+442.86%)
Mutual labels:  tailwind, tailwind-css
tailwind
Website clones/examples using Tailwind CSS.
Stars: ✭ 49 (+133.33%)
Mutual labels:  tailwind, tailwind-css
ngx-tailwind
💨 Simple Angular schematic that initializes Tailwind CSS in your project and adds a custom webpack config to your build process.
Stars: ✭ 120 (+471.43%)
Mutual labels:  tailwind, tailwind-css
create-nuxt-tailwind-app
[DEPRECATED] Use create-nuxt-app, they added full tailwindcss & purgecss support
Stars: ✭ 32 (+52.38%)
Mutual labels:  tailwind, tailwind-css
windstrap
Tailwind CSS with Bootstrap JS
Stars: ✭ 63 (+200%)
Mutual labels:  tailwind, tailwindcss-plugin
code-type
Practice code-typing with top 1000 keywords of the most popular programming languages.
Stars: ✭ 31 (+47.62%)
Mutual labels:  tailwind, tailwind-css

Automatic alpha variants for your Tailwind CSS colors based on your opacity config

Why?

Tailwind only supports opacity but sometimes you need to apply semi-transparent background/border or text.

You could tweak your Tailwind configuration like this

module.exports = {
  theme: {
    colors: {
      primary: "#2b2e4a",
      "primary-10": "rgba(43,46,74, 0.1)",
      "primary-20": "rgba(43,46,74, 0.2)",
      "primary-75": "rgba(43,46,74, 0.75)",
      // ...
    },
    // ...
  },
};

But it's repetitive, confusing and error prone. We can do better.

Install

npm install --save-dev tailwind-color-alpha

module.exports = {
  // ...
  plugins: [require("tailwind-color-alpha")()],
};

The plugin will automatically use your colors and opacity config to generate all the corresponding rgba values for your text, background, border, fill and stroke utility classes respecting your variant settings for each.

Examples

module.exports = {
  theme: {
    colors: {
      primary: "#2b2e4a",
    },
    opacity: {
      "25": ".25",
      "50": "0.5",
    },
  },
};

The configuration above yields the following utilities:

.bg-primary-alpha-25 {
  background-color: rgba(43, 46, 74, 0.25);
}
.bg-primary-alpha-50 {
  background-color: rgba(43, 46, 74, 0.5);
}
.text-primary-alpha-25 {
  color: rgba(43, 46, 74, 0.25);
}
.text-primary-alpha-50 {
  color: rgba(43, 46, 74, 0.5);
}
.border-primary-alpha-25 {
  border-color: rgba(43, 46, 74, 0.25);
}
.border-primary-alpha-25 {
  border-color: rgba(43, 46, 74, 0.5);
}
.hover\:text-primary-alpha-25:hover {
  color: rgba(43, 46, 74, 0.25);
}
.focus\:text-primary-alpha-50:focus {
  color: rgba(43, 46, 74, 0.5);
}

/* and more... */

Notice that a color named red.default will end up generating text-red and so we follow Tailwind's convention with bg-red-alpha-${opacity}

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].