{"id":15064836,"url":"https://github.com/thisisjuke/tailwindcss-css-variables-palette-plugin","last_synced_at":"2025-04-10T12:41:27.075Z","repository":{"id":42504058,"uuid":"446855671","full_name":"Thisisjuke/tailwindcss-css-variables-palette-plugin","owner":"Thisisjuke","description":"Generate a color palette 🎨 using CSS variables 🔡 for TailwindCSS 🍃","archived":false,"fork":false,"pushed_at":"2022-12-29T13:37:55.000Z","size":87,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T07:07:40.405Z","etag":null,"topics":["css-variables","palette-generation","tailwindcss","tailwindcss-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Thisisjuke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-11T14:32:01.000Z","updated_at":"2023-07-31T17:21:53.000Z","dependencies_parsed_at":"2023-01-31T09:01:07.375Z","dependency_job_id":null,"html_url":"https://github.com/Thisisjuke/tailwindcss-css-variables-palette-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thisisjuke%2Ftailwindcss-css-variables-palette-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thisisjuke%2Ftailwindcss-css-variables-palette-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thisisjuke%2Ftailwindcss-css-variables-palette-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thisisjuke%2Ftailwindcss-css-variables-palette-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thisisjuke","download_url":"https://codeload.github.com/Thisisjuke/tailwindcss-css-variables-palette-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217155,"owners_count":21066634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css-variables","palette-generation","tailwindcss","tailwindcss-plugin"],"created_at":"2024-09-25T00:27:04.742Z","updated_at":"2025-04-10T12:41:27.055Z","avatar_url":"https://github.com/Thisisjuke.png","language":"JavaScript","readme":"# Palette plugin using CSS variables for TailwindCSS\n\nAdds a color palette (from `100` to `900`) for each color of your tailwind configuration while using CSS variable for each.\n\nThis package has been designed to create **library components** where the theme (colors) are easily modifiable in the application, **using CSS variables**.\n\n## Installation\n\nUsing yarn :\n```bash\nyarn add -D tailwindcss-css-variables-palette-plugin\n```\n\nUsing npm : \n```bash\nnpm install --save-dev tailwindcss-css-variables-palette-plugin\n```\n\nThen set up your `tailwind.config.js` this way :\n\n```\nconst THEME_COLORS = {\n  primary: '#264653',\n  secondary: '#2A9D8F'\n};\n\nmodule.exports = {\n  /...\n  theme: {\n    colors: THEME_COLORS,\n    extend: {},\n  },\n  plugins: [\n    require('tailwindcss-css-variables-palette-plugin')({\n      colors: THEME_COLORS,\n    }),\n    /...\n  ],\n};\n```\n\nThe plugin then create the following configuration for you : \n\n```\n{\n  primary: {\n    '100': 'var(--color-primary-100, #e9edee)',\n    '200': 'var(--color-primary-200, #c9d1d4)',\n    '300': 'var(--color-primary-300, #a8b5ba)',\n    '400': 'var(--color-primary-400, #677e87)',\n    '500': 'var(--color-primary-500, #264653)',\n    '600': 'var(--color-primary-600, #223f4b)',\n    '700': 'var(--color-primary-700, #1d353e)',\n    '800': 'var(--color-primary-800, #172a32)',\n    '900': 'var(--color-primary-900, #132229)',\n    DEFAULT: 'var(--color-primary, #264653)'\n  },\n  secondary: {\n    '100': 'var(--color-secondary-100, #eaf5f4)',\n    '200': 'var(--color-secondary-200, #cae7e3)',\n    '300': 'var(--color-secondary-300, #aad8d2)',\n    '400': 'var(--color-secondary-400, #6abab1)',\n    '500': 'var(--color-secondary-500, #2A9D8F)',\n    '600': 'var(--color-secondary-600, #268d81)',\n    '700': 'var(--color-secondary-700, #20766b)',\n    '800': 'var(--color-secondary-800, #195e56)',\n    '900': 'var(--color-secondary-900, #154d46)',\n    DEFAULT: 'var(--color-secondary, #2A9D8F)'\n  },\n}\n```\n\nThe plugin is also adding the always needed following classes by default (same naming as default TailwindCSS properties) : \n\n```\n{\n  inherit: 'inherit',\n  current: 'currentColor',\n  transparent: 'transparent',\n  black: '#000',\n  white: '#fff',\n}\n```\n\n## Simple Usage\n\nNow in your application, you can use classes like `bg-primary-500` or `bg-primary-800` as usual.\n\n`DEFAULT` is the variable used to generate `bg-primary` without suffix.\n\n```html\n\u003cspan class=\"bg-primary text-secondary-400\"\u003e\n    Hello !\n\u003c/span\u003e\n```\n\n\u003e NOTE : `primary` and `primary-500` have the same color attributed. It's a better idea to use it without suffix in your code (ex: `bg-primary`) if the goal is to replace the color globally using its CSS variable.\n\n## CSS Variables usage\n\n### Addition in the DOM \n\nThis plugin uses [the `addBase` utility from `tailwindcss/plugin` package](https://tailwindcss.com/docs/adding-custom-styles#writing-plugins).\n\nSo in your DOM, under the `:root` attribute, you can now find all the css variables generated by the plugin :\n\n![css-variables.png](images/css-variables.png)\n\nSee more at : https://developer.mozilla.org/en-US/docs/Web/CSS/:root\n\n### Change scoped color in your component\n\nNow, if you need to modify one of the color of a property, you can do it globally or component scoped, using the default Css Variables API.\n\n```\n:root {\n  --color-primary: #D36060;\n}\n\n.my-custom-card {\n  --color-primary-300: #C2714F;\n  --color-secondary: #E0607E;\n}\n```\n\nDocumentation : https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties\n\n# Compatibility\n\nThis plugin is based on [CSS Custom Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/--*), which are [not compatible with IE11](https://caniuse.com/#feat=css-variables). You can have partial support for the browsers that do not support them by using a PostCSS plugin that add a fallback for CSS variables, such as [`postcss-css-variables`](https://github.com/MadLittleMods/postcss-css-variables) or [`postcss-custom-properties`](https://github.com/postcss/postcss-custom-properties).\n\n## License\n\nThis project is licensed under the [MIT License](/LICENSE).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthisisjuke%2Ftailwindcss-css-variables-palette-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthisisjuke%2Ftailwindcss-css-variables-palette-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthisisjuke%2Ftailwindcss-css-variables-palette-plugin/lists"}