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.

[Badge] Support other theme colors

See original GitHub issue

Expected Behavior

When supplying the color attribute, you should be able to use any of the colors supplied in the theme.palette

Current Behavior

Only: default/primary/accent are supported.

Your Environment

Tech Version
Material-UI v1.0.0-beta.23

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
patorjkcommented, Aug 2, 2019

In case anyone comes across this and wants to change the color, here’s how to use makeStyles from @material-ui/styles to change the color:

import {makeStyles} from "@material-ui/styles";

const useStyles = makeStyles(theme => ({
    badge: {
        backgroundColor: "green",
    }
}));

... // Then later in your render method or in your component function

const classes = useStyles();

... // Then later in your JSX

<Badge badgeContent="100" classes={{badge: classes.badge}}>
    <SomeIcon />
</Badge>
6reactions
papasnippycommented, Dec 11, 2017

Type ‘string’ is not assignable to type ‘“disabled” | “inherit” | “primary” | “accent” | “default” | “contrast” | “action” | “error”’.

Forbidding using any color is really bad. It limits using this library. I not always need pure colors, I need gradients too. I even can’t use color from official palettes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Badge] Support other theme colors #9455 - mui/material-ui
js, RaisedButton.js, etc. and discovered they use "backgroundColor" as the CSS property to set the primary and accent color to the background.
Read more >
themeColor - API Reference - Kendo UI Badge - Documentation
themeColor String (default: 'secondary'). Specifies the theme color of the component. Valid options are. inherit : no coloring will be applied to the...
Read more >
Badge | Colors | JET Developer Cookbook - Oracle
This demo shows recommended mappings of states to colors ... NOTE : Badges are supported in the Redwood theme , they are not...
Read more >
How to customize badges color and text size [all free themes]
In this tutorial I'll be showing you how you can quickly customize these badges' colors and size in a just a few lines...
Read more >
Slack on Twitter: "@turoczy We're sorry to hear that. But good ...
We're sorry to hear that. But good news! You can change this back to red by going to Preferences > Themes > and...
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