Custom theme keys with typescript
See original GitHub issueAre custom theme keys currently supported with typescript?
Using the following code:
export const theme = {
Collapse: {},
};
const defaultTheme = makeTheme(theme);
type MyTheme = typeof defaultTheme;
declare module 'dripsy' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface DripsyCustomTheme extends MyTheme {}
}
I get the error { Collapse: {} } has no property in common w/ the theme.
I thought I had it working in a separate project. Could the error be because of where I’m creating my custom components?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
TypeScript - Theme UI
The Theme type represents all possible themes. It might be what you need when you're writing a library of reusable components or an...
Read more >Typescript Typings and Custom Theme props #480 - GitHub
I'd like to know if you think it would be possible to add a custom generics to types like ColorProps? That way it...
Read more >Material UI custom theme and TypeScript - Dragosh Mocrii
We use a mapped type CustomTheme to take the possible properties and their value types from our actual theme object. And we use...
Read more >How to use Material UI custom theme in React with Typescript
Material UI custom theme in React with Typescript v4->v5 migration guide. create separate file for declaration. theme.d.ts import { Theme ...
Read more >Extend Material-UI theme in TypeScript - In Plain English
Of course, there is no “success” in PaletteOptions keys. But now, you might guess that if you add keys to PaletteOptions, you can...
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

I’ve been thinking about this in general: is Dripsy theming enough to be the backbone of a scalable design system?
For example, take a card:
I think that works pretty well. The issue is, Dripsy’s variant system follows the theme-ui spec, which is a bit static. They want your theme represented as a JSON file. This has its benefits: what you see is what you get.
But there are, of course, some limitations.
From the outside, I think the Stitches approach to variants is better: you can have many variant options, such as
size,color, etc.A key example is a
Button, like @cmaycumber mentioned.Say your color scheme looks like this:
Here we have a
primaryand asecondary. The palette I have in mind comes from Radix Colors.So, how do we compose a button from this color scheme, such that the label uses the
${color}Text, and the button uses the${color}.A few options:
styledAPI.And, perhaps you’d wrap your button to pass the
colorprop to all of them together.However, for a theme-based style system, I’m not sure if this is the optimal solution. Perhaps it is. But I wonder, could this logic, for such a reused component that literally every app needs, live in a theme instead?
After all, every React Native button needs a container and a label.
In the spirit of a theme-centric design system, I wonder if something more like this could work. It’s similar to the Card, except that it allows props to be passed to the theme…
This would be more inspired by the Stitches variants option in
styled.Notice here that
buttons.containertakes a function.The difference with stitches being, you define these styles in theme, so you can port them from project to project easily. Now, I’m not sure if that’s the best thing to optimize around or not. But maybe it is. I’m thinking out loud a bit here.
I mentioned this idea to @axeldelafosse a bit back. I’ll keep playing with it…
You should be writing the theme directly inside of makeTheme, rather than as a separate variable.
that said, I don’t know if this is valid. I think you have to use the keys provided by the theme