question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extending createCustom with custom types

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
muhammadsammycommented, Apr 16, 2020

The CLI is now available for generating classes with colors and breakpoints. tailwindcss-classnames@next

1reaction
fabiokandradecommented, Apr 15, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found