Skip to content

[material-ui][Button] Variants don't consume the size prop #32427

Open
@cheesestringer

Description

@cheesestringer

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Creating a button variant doesn't seem to use the size prop. When a button and a variant button are placed next to each other they look misaligned.

export const components = {
  MuiButton: {
    defaultProps: {
      variant: 'contained'
    },
    variants: [
      {
        props: { variant: 'action' },
        style: {
          background: 'red'
        }
      }
    ]
  }
} as Components;
<div>
  <Button color="primary" size="large">
    Normal Button
  </Button>
  <Button color="secondary" size="large" variant="action">
    Variant Button
  </Button>
</div>

image

Expected behavior 🤔

I assumed size would be consumed so buttons and their variants could still be grouped together to have the same font sizes and padding etc.

Steps to reproduce 🕹

Steps:

  1. Create a button variant
  2. Try and use different sizes on the variant while comparing font size and padding to the normal button

Context 🔦

Create a button variant with different styles while still being able to consume the existing props like size. I'd like to be able to position the buttons next to each other and have them using the same font sizes and padding without looking misaligned.

Your environment 🌎

`npx @mui/envinfo` System: OS: Windows 10 10.0.19044 Binaries: Node: 16.13.2 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: Not Found Edge: Spartan (44.19041.1266.0), Chromium (100.0.1185.44) npmPackages: @emotion/react: ^11.9.0 => 11.9.0 @emotion/styled: ^11.8.1 => 11.8.1 @mui/base: 5.0.0-alpha.77 @mui/material: ^5.6.2 => 5.6.2 @mui/private-theming: 5.6.2 @mui/styled-engine: 5.6.1 @mui/system: 5.6.2 @mui/types: 7.1.3 @mui/utils: 5.6.1 @types/react: ^18.0.6 => 18.0.6 react: ^18.0.0 => 18.0.0 react-dom: ^18.0.0 => 18.0.0 typescript: ^4.6.3 => 4.6.3

Metadata

Metadata

Assignees

Labels

component: buttonThis is the name of the generic UI component, not the React module!customization: themeCentered around the theming featurespackage: material-uiSpecific to @mui/materialsupport: questionCommunity support but can be turned into an improvementv6.x

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions