Extending createCustom with custom types
See original GitHub issueThe Problem
Currently, it’s not easy (or possible?) to extend the default tailwind types with other types.
import { createCustom } from 'tailwindcss-classnames';
createCustom<CustomClasses>();
type CustomClasses = 'bg-smoke-100';
Produces an error:
Type '"bg-smoke-100"' does not satisfy the constraint 'TClasses'.
The Solution
There is probably a technical solution to this, but I couldn’t find it immediately and wanted advice before I send a PR to the repo.
It also struck me what a pain it would be to have to add custom types: to add a color, you’d have to specify:
bg-<color>-100
...etc
text-<color>-100
...etc
placeholder-<color>-100
...etc
And other variations I’m not considering.
Would it be useful to have a CLI tool which could target your tailwind config and generate these types?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Extending WordPress With Custom Content Types
We're going to explore the process of registering new data types in a fully compliant manner. WordPress does some pretty amazing things out...
Read more >How To Create Custom Types in TypeScript
This tutorial will show you how to use custom types with TypeScript, how to compose those types together with unions and intersections, and...
Read more >Define and extend custom types in TypeScript
I am trying to define custom types in TypeScript with some additional extension methods, also want to allow other uses of my library...
Read more >Creating Custom Types in Typescript
Let's look at how to create custom types in typescript. ... You can extend alias types, i.e. if you want to add a...
Read more >Chapter 17. Creating a custom type extension
In this chapter, we're going to do something very similar by creating a type extension. Unlike views, which only affect the visual presentation...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The CLI is now available for generating classes with colors and breakpoints.
tailwindcss-classnames@next
Great idea! Something like https://github.com/esamattis/postcss-ts-classnames