Skip to content

TypeScript Support

Renderlesskit provides a full typesafe theming system which can help you get better intellisense while working with the components.

In this guide we are going to see how to setup TypeScript, and see how we can add extra typesafe variants to component themes.

First, we need to extract our custom theme object into it's own file so that we can infer it's types.

Creating theme file

extendTheme is an identity function which helps us infer the type of the customTheme, and provide intellisense.

Creating declaration file

TypeScript definitions for the Renderlesskit's theme can be extended by using declaration merging. So the first step is creating a declarations file. Let's name it global.d.ts for example.

For CRA projects you can put this content inside react-app-env.d.ts

Thats It!

Now if you create a new Button you'll see that there is a new variant called red

TypeScript intellisense showing a Button with a new red variant