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.

Easier way to override not-selected tab color

See original GitHub issue

For a specific tab bar, I wanted to tweak the color of not-currently-selected tabs to make it more different from the disabled state. Using the classes system, I had to override rootPrimary (expected), but since that style is applied to all three states of the tab, I had to also override rootPrimaryDisabled and rootPrimarySelected.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

It would be easier if there was an extra class rootPrimaryUnselected that I could use to set just the attributes specific to the unselected state, while rootPrimary would contain attributes common to all three states.

Your Environment

Tech Version
Material-UI 1.0.0-beta.23
React 15.6.2
browser
etc

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
oliviertassinaricommented, Jan 5, 2018

@paour Bootstrap solves this issue by increasing the specificity of the disabled and selected state. It’s the only solution I can think of. To give an idea of what that looks like in practice.

Before

rootAccent: {
  color: theme.palette.text.secondary,
},
rootAccentSelected: {
  color: theme.palette.secondary.A200,
},
rootAccentDisabled: {
  color: theme.palette.text.disabled,
},
rootPrimary: {
  color: theme.palette.text.secondary,
},
rootPrimarySelected: {
  color: theme.palette.primary[500],
},
rootPrimaryDisabled: {
  color: theme.palette.text.disabled,
},

After

rootAccent: {
  color: theme.palette.text.secondary,
  '&$rootSelected': {
    color: theme.palette.secondary.A200,
  },
  '&$rootDisabled': {
    color: theme.palette.text.disabled,
  },
},
rootPrimary: {
  color: theme.palette.text.secondary,
  '&$rootSelected': {
    color: theme.palette.primary[500],
  }
  '&$rootDisabled': {
    color: theme.palette.text.disabled,
  },
},
rootSelected: {}
rootDisabled: {}

This would be an important a profound change.

0reactions
kgregorycommented, Jan 5, 2018

Sounds good

Read more comments on GitHub >

github_iconTop Results From Across the Web

Easier way to override not-selected tab color #9742 - GitHub
For a specific tab bar, I wanted to tweak the color of not-currently-selected tabs to make it more different from the disabled state....
Read more >
How do I override material-ui's tab selection color?
There are 2 ways to do this: METHOD 1: using style: {} import React from "react"; import PropTypes from "prop-types"; import { Tabs,...
Read more >
Tabs API - Material UI - MUI
Name Type Default action ref allowScrollButtonsMobile bool false aria‑label string
Read more >
How to control tab bar item color in Swift 4? - Apple Developer
I would like to have control over the color of a TabBar item based on some event. ... foregroundColor: UIColor.red], for:.selected) UITabBar.appearance().
Read more >
How to change the color of a selected tab? - Dash Python
hi, I would like to change the colour of a selected tab, to the background of left blue, and white color for letters....
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