How to set hover styling for Typography component?
See original GitHub issueI want a normal text link to be underlined on hover. In order to that I’ve tried to style a Typography component nested inside a link component but this doesn’t work. I’ve searched through the entire documentation but can’t find anything about adjusting hover effects on typography/link components.
const styles = {
textDecoration: 'none',
'&:hover': {
textDecoration: 'underline',
}
<Link to="/mypage">
<Typography
color="secondary"
type="body1"
style={styles}>
{props.text}
</Typography>
</Link>;
Expected Behavior
I expect the link to underline on hover.
Current Behavior
Nothing happens.
Steps to Reproduce (for bugs)
The full code for the component:
import * as React from 'react';
import { Link } from "react-router-dom";
import Typography from 'material-ui/Typography';
import { withStyles } from 'material-ui/styles';
const styles = {
textDecoration: 'none',
'&:hover': {
color: 'white'
}
};
function TextLink(props) {
return (
<Link
to="/"
>
<Typography
color="secondary"
type="body1"
style={styles}>
{props.text}
</Typography>
</Link>;
)
}
export default withStyles(styles)(TextLink);
Your Environment
“material-ui”: “^1.0.0-beta.30”, “react”: “^16.2.0”, “react-dom”: “^16.2.0”,
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to set hover styling for Typography component? #10075
I want a normal text link to be underlined on hover. In order to that I've tried to style a Typography component nested...
Read more >MaterialUI Custom Hover Style - reactjs
You should define a key for TableRow as a className and then put your hover style right on that class name as an...
Read more >Add Hover Styling With MUI's SX Prop (4 Examples!) - YouTube
Do you want to build a full MUI app from beginning to end, learn every aspect of the sx prop, styled API, and...
Read more >How to Add Hover Styling with MUI's SX Prop (4 Examples)
Hover styling is a common requirement for UI components. ... how to add hover styling to the Box, Button, Paper, and TextField components....
Read more >How to customize - Material UI
In this case, the styles are applied with .css-ae2u5c-MuiSlider-thumb but you only really need to target the .MuiSlider-thumb , where Slider is the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You have use className and classes
@vdhieu Is right. We have some alternative APIs too: https://github.com/mui-org/material-ui/blob/v1-beta/docs/src/pages/customization/css-in-js.md#alternative-apis.