Created
December 20, 2018 20:56
-
-
Save yerassylad/f71cd36b743dde793667c24bcdd59b35 to your computer and use it in GitHub Desktop.
material-ui styling tabs with styled-components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import styled from 'styled-components'; | |
import { Tabs, Tab } from '@material-ui/core'; | |
const StyledTabs = styled(props => { | |
return <Tabs {...props} classes={{indicator: 'indicator'}}></Tabs> | |
})` | |
&& { | |
border-bottom: 1px solid yellow; | |
} | |
&& .indicator { | |
background-color: #1F6FF7; | |
} | |
`; | |
const StyledTab = styled(Tab)` | |
&& { | |
color: #1F6FF7; | |
text-transform: none; | |
} | |
`; | |
class MyTabs extends Component { | |
state = { tab: 0 } | |
handleChangeTab = (e, tab) => { | |
this.setState({ tab }) | |
} | |
render() { | |
const {tab} = this.state; | |
return ( | |
<StyledTabs centered value={tab} onChange={this.handleChangeTab}> | |
<StyledTab label="tab1"></StyledTab> | |
<StyledTab label="tab2"></StyledTab> | |
</StyledTabs> | |
); | |
} | |
} | |
export default MyTabs; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment