Reactjs Material-UI Floating action button component
YouTube video:
Component:
Fab is the component used to create a floating action button. We can import it from material-ui/core as like below:
import { Fab } from "@material-ui/core";
Changing the color of a Fab:
Color can be changed by using the color props.For example, we can change it to primary color as like below:
<Fab color='primary'><AddIcon /></Fab>
Changing the size of a Fab:
Size of a floating action button can be change by using the size props in Material-UI. It can be small, large or mid.
import { Fab } from "@material-ui/core";import AddIcon from "@material-ui/icons/Add";import "./App.css";function App() {return (<div className="App"><Fab style={{ marginRight: 10 }} color="primary" size="small"><AddIcon /></Fab><Fab style={{ marginRight: 10 }} color="secondary" size="mid"><AddIcon /></Fab><Fab color="primary" size="large"><AddIcon /></Fab></div>);}export default App;
This will create three buttons with three sizes.