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.

How to add custom colors/attributes to the theme?

See original GitHub issue

Previously: #317, #568, #799, but I don’t think the question has been answered:

What is the recommended way to pass custom attributes (eg. custom accent colors besides the one accent property) through the theme? The typescript type currently makes this inconvenient.

One way is to make a separate auxTheme object and pass it through a custom context, but it would be nicer to be able to use a single theme object.

Perhaps adding a auxiliary: any key to the theme type will be sufficient? Perhaps we can make Provider take a generic type for the auxiliary object, or infer it?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kamui545commented, Jul 14, 2020

Support has been merged (#2002) and it is now available on react-native-paper@^4.0.0-alpha.2, just tried it out and it works like a charm.

Usage:

declare global {
  namespace ReactNativePaper {
    interface ThemeColors {
      myOwnColor: string;
    }
    interface Theme {
      myOwnProperty: boolean;
    }
  }
}
2reactions
stearrudacommented, Jun 17, 2021

Is there any workaround with the ESLint rule over typescript-eslint/no-namespace?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create a truly custom theme in Jetpack Compose
In the following sections, we will create our own theme in a very similar way, but it will contain: colors; typography; dimensions. Create...
Read more >
Create or delete a custom theme color - Microsoft Support
On the Themes tab, under Theme Options, click Colors, and then click Create Theme Colors. · Click a color that you want to...
Read more >
Creating Color Themes With Custom Properties, HSL, and a ...
Creating Color Themes With Custom Properties, HSL, and a Little calc() ... For example, here are variables defined on data attributes:.
Read more >
Building a Material Theme on Android: Color
Let's take a look at how you can add your chosen color palette to your app theme by overriding relevant attributes.
Read more >
Customizing Colors and Themes in Jetpack Compose ...
Update the Theme Colors of a Compose application. In this video, I add new colors to Colors.kt, then associate them with the Material...
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