UNPKG

tailwindcss-shadcn-utilities

Version:

A Tailwind CSS plugin to generate custom color utilities for background and foreground.

29 lines (28 loc) 1.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const plugin_1 = __importDefault(require("tailwindcss/plugin")); const shadcnUtilities = (0, plugin_1.default)(function ({ addUtilities, theme }) { const createColorUtilities = (name) => { const backgroundColor = theme(`colors.${name}.DEFAULT`); const foregroundColor = theme(`colors.${name}.foreground`); return { [`.${name}`]: { backgroundColor: backgroundColor, color: foregroundColor, }, }; }; addUtilities([ "card", "popover", "primary", "secondary", "muted", "accent", "destructive", ].reduce((acc, category) => (Object.assign(Object.assign({}, acc), createColorUtilities(category))), {})); }); exports.default = shadcnUtilities;