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.

withStyle Selected tab doesn't work

See original GitHub issue

I follow the example to customize the tab text color when its selected, unfortunately, it seems doesn’t work at all. When tab is selected, the color didn’t change to blue.

any ideas?

"@material-ui/core": "^3.8.3",
"typescript": "^3.2.2"
import * as React from "react";
import {Tab} from '@material-ui/core';
import {MuiThemeProvider, createMuiTheme} from '@material-ui/core/styles';
import withStyles, { StyleRulesCallback, WithStyles } from '@material-ui/core/styles/withStyles';


const styles: StyleRulesCallback = theme => ({
    tabRoot: {
        color: "#bdc0c4",
        '&:hover': {
            color: '#ffffff',
            opacity: 1,
        },
        '&$tabSelected': {
            color: '#1890ff',
            fontWeight: theme.typography.fontWeightMedium,
        },
        textTransform: 'initial',
    },
    tabSelected: {
        color: '#1890ff'
    }
});
class NavBarItemsComponent extends React.Component<WithStyles<string> & Props>  {

public render(): React.ReactNode {
    
    const { classes } = this.props;
    const tabStyle = { root: classes.tabRoot, selected: classes.tabSelected };
    
    return (
        
            <Tab label={this.props.label} classes={tabStyle}/>
    )}
    
   
};

export default withStyles(styles)(NavBarItemsComponent);

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Jan 15, 2019

Oh, I see that the documentation example isn’t using this pattern. What do you think of updating it? It’s cleaner but requires more knowledge of how it works.

0reactions
BinitaBharaticommented, Nov 12, 2020

@oliviertassinari - Thanks for the sample code. It works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

withStyle Selected tab doesn't work · Issue #14184 - GitHub
It seems only selected doesn't work, hover works fine. UPDATE I applied customized tab to the project, and got such error message in...
Read more >
How can I override the selected style for a tab? - Stack Overflow
I could come up with a solution using overriding CSS using withStyles, <Tabs value={value} onChange={this.
Read more >
Fixed issues in InDesign - Adobe Support
InDesign becomes unresponsive while exporting a specific document to PDF. Panels are not loaded properly in custom workspace. Unable to copy and ...
Read more >
Swap style and component libraries – Figma Help Center
If a matching style or component isn't found in your selected library, Figma won't swap those assets. They'll stay connected to the original...
Read more >
Copy and paste text styles in Pages on Mac - Apple Support
In Pages on your Mac, copy just the style of selected text, then apply that style to ... If the document where you...
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