I'm not able to change the color of a Link inside a Button. When I apply the secondary color to the Button, it doesn't take effect. In other components it does work this way.
<AppBar position='fixed'>
<Toolbar>
<Button color='secondary'>
<Link to="/">Home</Link>
</Button>
</Toolbar>
</AppBar>
In App.js I create the custom Theme and wrap it around all components with
<ThemeProvider theme={customTheme}>
App.js:
const customTheme = createMuiTheme({
palette: {
primary: {
main: '#36454B',
contrastText: '#fff',
},
secondary: {
light: '#55dab3',
main: '#00a883',
dark: '#007856',
contrastText: '#000',
}
}
});
How do I add a link in material UI icon? First make sure you have added Material Icon library. If this library is added just add the HTML css class insert_link to any element to add the icon. Material Design Insert Link Icon can be resized as per your need.
Conditional Changing the Background Color in Reactimport React from 'react'; import './App. css'; function App() { const isBackgroundRed = true; return ( <div className={isBackgroundRed ? 'background-red' : 'background-blue'} /> ); } export default App; JSX allows us to write JavaScript inside of HTML.
What you can do is pass component={Link}
to button, so it will render the Link
as it base component. See the docs.
<Button color='secondary' href="/" component={Link}>
Home
</Button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With