Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IconButton with label

Tags:

material-ui

Is there something I can use in/with IconButton to define a label below the icon?

Maybe something similar to BottomNavigationAction but without it having to be inside of a BottomNavigation.

like image 995
mfulton26 Avatar asked Sep 20 '19 19:09

mfulton26


People also ask

How do you add a label to an icon button in flutter?

The simplest way to create a button with icon and text in Flutter is to use the new Material button called ElevatedButton with an icon constructor. ElevatedButton. icon() gives you the ability to add the icon and label parameter to the button.

How do I use IconButton material UI?

Create an icon buttonImport the IconButton component from the Material-UI core package. import IconButton from '@material-ui/core/IconButton'; Render the icon as a child component to the IconButton . You can also move the color prop to the IconButton .

What is an icon button?

An icon button is a picture printed on a Material widget that reacts to touches by filling with color (ink). Icon buttons are commonly used in the AppBar. actions field, but they can be used in many other places as well. If the onPressed callback is null, then the button will be disabled and will not react to touch.


1 Answers

You can add your label as a direct child of the IconButton (sibling of the Icon itself), and override the IconButton-label style to have flexDirection: column

import React from 'react';
import {IconButton} from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import SaveIcon from '@material-ui/icons/Save';

const useStyles = makeStyles(theme => ({
  iconButtonLabel: {
    display: 'flex',
    flexDirection: 'column',
  },
}));

export default function IconButtonWithLabel() {
  const classes = useStyles();

  return (
      <IconButton classes={{label: classes.iconButtonLabel}}>
        <SaveIcon/>
        <div>
          hello
        </div>
      </IconButton>
  );
}

Edit Invisible Backdrop

like image 112
Ido Avatar answered Jan 02 '23 19:01

Ido