Created
February 19, 2022 12:32
-
-
Save hyunbinseo/ae648ffafcdafa1fed9afc28e4368ebe to your computer and use it in GitHub Desktop.
Typescript types for Tailwind CSS colors (background, text)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on Tailwind CSS v3.0.23 | |
// Requires TypeScript 4.1 or later (Template Literal Types) | |
// Reference https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#template-literal-types | |
type Name = | |
| 'amber' | |
| 'blue' | |
| 'cyan' | |
| 'emerald' | |
| 'fuchsia' | |
| 'gray' | |
| 'green' | |
| 'indigo' | |
| 'lime' | |
| 'neutral' | |
| 'orange' | |
| 'pink' | |
| 'purple' | |
| 'red' | |
| 'rose' | |
| 'sky' | |
| 'slate' | |
| 'stone' | |
| 'teal' | |
| 'violet' | |
| 'yellow' | |
| 'zinc'; | |
type Level = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; | |
type Color = | |
| `${Name}-${Level}` | |
| 'inherit' | |
| 'current' | |
| 'transparent' | |
| 'black' | |
| 'white'; | |
export type BackgroundColor = `bg-${Color}`; | |
export type TextColor = `text-${Color}`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment