Skip to content

[material_ui] ElevatedButton.styleFrom uses Material 2 elevation offsets #196845

Open

Description

@QuncCccccc

ElevatedButton.styleFrom(elevation: e) derives these elevations (code):

  • disabled: 0
  • hovered or focused: e + 2
  • pressed: e + 6
  • otherwise: e

These offsets come from the Material 2 elevated button, which is 2 at rest, 4 when hovered or focused, and 8 when pressed. They don't match Material 3 or Material 3 Expressive, where the focused and pressed elevations are the same as the resting one:

State Material 3 (defaults) Material 3 Expressive (tokens) styleFrom(elevation: 1)
Resting 1 1 1
Hovered 3 1 3
Focused 1 1 3
Pressed 1 1 7
Disabled 0 0 0

So an app that uses styleFrom to set the Material 3 resting elevation gets a button that rises to 7 when it's pressed, while the default button stays at 1.

final WidgetStateProperty<double?> elevation = ElevatedButton.styleFrom(elevation: 1).elevation!;
elevation.resolve(<WidgetState>{WidgetState.pressed}); // 7.0, but 1.0 in Material 3
elevation.resolve(<WidgetState>{WidgetState.focused}); // 3.0, but 1.0 in Material 3

styleFrom is static and has no BuildContext, so it can't choose the offsets based on ThemeData.useMaterial3 or ElevatedButtonThemeData.variant. Some options:

  1. Keep the current behavior. [material_ui] Fix M3 doc errors in the ElevatedButton and FilledButton packages#13685 documents it, and apps can pass a WidgetStateProperty to ButtonStyle.elevation to set each state.
  2. Match Material 3: e + 2 when hovered, and e when focused or pressed. This changes existing apps that use styleFrom(elevation: ...), including Material 2 apps.
  3. Use e for every enabled state, and keep 0 when disabled. This matches Material 3 Expressive and is closer to FilledButton.styleFrom, OutlinedButton.styleFrom, and TextButton.styleFrom, which use one value for all states. It's also a behavior change.

Found while fixing the ElevatedButton docs in flutter/packages#13685.

Activity

  1. added
    p: material_ui
    a: fidelity
    package
    team-design
    on Nov 18, 2026
  2. added
    P2
    triaged-design
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2a: fidelityp: material_uipackageteam-designtriaged-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions