Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6589f90
Add M3E IconButton
QuncCccccc May 29, 2026
ca7c3e4
Rename IconButton M3E template
QuncCccccc Aug 8, 2026
2bb61e1
Add IconButton xSmall tap target coverage
QuncCccccc Aug 17, 2026
2bc07db
Rename IconButton M3E style variants
QuncCccccc Aug 17, 2026
97329e3
Rename M3E IconButton default internals
QuncCccccc Aug 17, 2026
1cca05e
Use padded tap target for M3E IconButton defaults
QuncCccccc Aug 17, 2026
1753f51
Document M3E IconButton tap target defaults
QuncCccccc Aug 17, 2026
73e648f
Expand ButtonStyle variant documentation
QuncCccccc Aug 17, 2026
dafdf77
Clarify ButtonStyle variant enum docs
QuncCccccc Aug 18, 2026
0d748d9
Move IconButton variant defaults to IconButton docs
QuncCccccc Aug 18, 2026
2a96f0c
Refine ButtonSize API documentation
QuncCccccc Aug 18, 2026
84b2cd8
Rephrase ButtonStyle size variant docs
QuncCccccc Aug 18, 2026
9259994
Simplify ButtonStyle size variant docs
QuncCccccc Aug 18, 2026
bff0159
Clarify IconButton width variant docs
QuncCccccc Aug 18, 2026
e4228ec
Clarify ButtonStyle shape variant docs
QuncCccccc Aug 18, 2026
97a9f18
Polish IconButton variant style docs
QuncCccccc Aug 18, 2026
618b953
Clarify IconButton M3E option docs
QuncCccccc Aug 18, 2026
4971afc
Simplify IconButton M3E option docs
QuncCccccc Aug 18, 2026
7b22aae
Separate IconButton M3E default docs
QuncCccccc Aug 18, 2026
85289b9
Inline IconButton variant style lookup
QuncCccccc Aug 18, 2026
fd25bf9
Clean up IconButton M3E default variants
QuncCccccc Aug 18, 2026
cbdf5ac
Move IconButton M3E variant getters
QuncCccccc Aug 18, 2026
aa5eaaa
Clarify IconButton M3E default constructors
QuncCccccc Aug 18, 2026
8440664
Rename IconButton M3E variant enums
QuncCccccc Aug 18, 2026
a6f0d80
Clarify IconButton M3 defaults docs
QuncCccccc Aug 18, 2026
4c51797
Move IconButton useMaterial3 TODO
QuncCccccc Aug 18, 2026
85baafd
Simplify IconButton variant docs
QuncCccccc Aug 18, 2026
a772118
Clean up IconButton M3E tests
QuncCccccc Aug 18, 2026
ba4d52b
Apply M3E test theme defaults
QuncCccccc Aug 18, 2026
388e748
Simplify IconButton M3E test helper
QuncCccccc Aug 18, 2026
54f53d3
Remove blank line after IconButton template import
QuncCccccc Aug 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 114 additions & 1 deletion packages/material_ui/lib/src/button_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,55 @@ import 'theme_data.dart';
// late BuildContext context;
// typedef MyAppHome = Placeholder;

/// Defines size variants for Material 3 Expressive button components.
///
/// Each size variant represents a named visual scale. For example, a Material
/// 3 Expressive [IconButton] uses this value to choose its container size, icon
/// size, and padding.
enum ButtonSizeVariant {
/// The smallest button size.
xSmall,

/// A small button size.
small,

/// A medium button size.
medium,

/// A large button size.
large,

/// The largest button size.
xLarge,
}

/// Defines the width variants for Material 3 Expressive [IconButton].
enum IconButtonWidthVariant {
/// A narrower icon button.
narrow,

/// The standard icon button width.
standard,

/// A wider icon button.
wide,
}

/// Defines shape variants for Material 3 Expressive button components.
enum ButtonShapeVariant {
/// A rounded button shape.
///
/// For example, a Material 3 Expressive [IconButton] with this variant uses
/// rounder default container shapes.
round,

/// A squared button shape.
///
/// For example, a Material 3 Expressive [IconButton] with this variant uses
/// more squared default container shapes.
square,
}

/// The type for [ButtonStyle.backgroundBuilder] and [ButtonStyle.foregroundBuilder].
///
/// The [states] parameter is the button's current pressed/hovered/etc state. The [child] is
Expand Down Expand Up @@ -187,6 +236,9 @@ class ButtonStyle with Diagnosticable {
this.splashFactory,
this.backgroundBuilder,
this.foregroundBuilder,
this.sizeVariant,
this.iconButtonWidth,
this.shapeVariant,
});

/// The style for a button's [Text] widget descendants.
Expand Down Expand Up @@ -423,6 +475,42 @@ class ButtonStyle with Diagnosticable {
/// configuring clipping.
final ButtonLayerBuilder? foregroundBuilder;

/// The Material 3 Expressive size variant for this button.
///
/// A size variant selects a component-defined token set rather than a single
/// dimension. For example, an [IconButton] uses this value to choose its
/// default container size, padding, and icon size when it is using
/// [StyleVariant.material3Expressive].
///
/// Use [minimumSize], [fixedSize], [maximumSize], [padding], or [iconSize] to
/// directly override those individual style properties.
final ButtonSizeVariant? sizeVariant;

/// The Material 3 Expressive width variant for an [IconButton].
///
/// A width variant selects the leading and trailing space tokens used to
/// compute an icon button's default horizontal padding and minimum width when
/// it is using [StyleVariant.material3Expressive]. It does not change the
/// button's height or icon size.
///
/// This property is only used by icon buttons. Use [padding],
/// [minimumSize], [fixedSize], or [maximumSize] to directly override the
/// resulting layout.
final IconButtonWidthVariant? iconButtonWidth;

/// The Material 3 Expressive shape variant for this button.
///
/// A shape variant selects between component-defined token families, such as
/// round and square shapes. For [IconButton], this affects the default
/// container and selected-state shapes when it is using
/// [StyleVariant.material3Expressive]; state-specific tokens, such as the
/// pressed shape, are still resolved by the component defaults.
///
/// Use [shape] to provide a specific [OutlinedBorder] or stateful shape
/// override instead of selecting one of the Material 3 Expressive shape
/// variants.
final ButtonShapeVariant? shapeVariant;

/// Returns a copy of this ButtonStyle with the given fields replaced with
/// the new values.
ButtonStyle copyWith({
Expand Down Expand Up @@ -451,6 +539,9 @@ class ButtonStyle with Diagnosticable {
InteractiveInkFeatureFactory? splashFactory,
ButtonLayerBuilder? backgroundBuilder,
ButtonLayerBuilder? foregroundBuilder,
ButtonSizeVariant? sizeVariant,
IconButtonWidthVariant? iconButtonWidth,
ButtonShapeVariant? shapeVariant,
}) {
return ButtonStyle(
textStyle: textStyle ?? this.textStyle,
Expand Down Expand Up @@ -478,6 +569,9 @@ class ButtonStyle with Diagnosticable {
splashFactory: splashFactory ?? this.splashFactory,
backgroundBuilder: backgroundBuilder ?? this.backgroundBuilder,
foregroundBuilder: foregroundBuilder ?? this.foregroundBuilder,
sizeVariant: sizeVariant ?? this.sizeVariant,
iconButtonWidth: iconButtonWidth ?? this.iconButtonWidth,
shapeVariant: shapeVariant ?? this.shapeVariant,
);
}

Expand Down Expand Up @@ -516,6 +610,9 @@ class ButtonStyle with Diagnosticable {
splashFactory: splashFactory ?? style.splashFactory,
backgroundBuilder: backgroundBuilder ?? style.backgroundBuilder,
foregroundBuilder: foregroundBuilder ?? style.foregroundBuilder,
sizeVariant: sizeVariant ?? style.sizeVariant,
iconButtonWidth: iconButtonWidth ?? style.iconButtonWidth,
shapeVariant: shapeVariant ?? style.shapeVariant,
);
}

Expand Down Expand Up @@ -547,6 +644,9 @@ class ButtonStyle with Diagnosticable {
splashFactory,
backgroundBuilder,
foregroundBuilder,
sizeVariant,
iconButtonWidth,
shapeVariant,
];
return Object.hashAll(values);
}
Expand Down Expand Up @@ -584,7 +684,10 @@ class ButtonStyle with Diagnosticable {
other.alignment == alignment &&
other.splashFactory == splashFactory &&
other.backgroundBuilder == backgroundBuilder &&
other.foregroundBuilder == foregroundBuilder;
other.foregroundBuilder == foregroundBuilder &&
other.sizeVariant == sizeVariant &&
other.iconButtonWidth == iconButtonWidth &&
other.shapeVariant == shapeVariant;
}

@override
Expand Down Expand Up @@ -706,6 +809,13 @@ class ButtonStyle with Diagnosticable {
defaultValue: null,
),
);
properties.add(EnumProperty<ButtonSizeVariant>('sizeVariant', sizeVariant, defaultValue: null));
properties.add(
EnumProperty<IconButtonWidthVariant>('iconButtonWidth', iconButtonWidth, defaultValue: null),
);
properties.add(
EnumProperty<ButtonShapeVariant>('shapeVariant', shapeVariant, defaultValue: null),
);
}

/// Linearly interpolate between two [ButtonStyle]s.
Expand Down Expand Up @@ -769,6 +879,9 @@ class ButtonStyle with Diagnosticable {
splashFactory: t < 0.5 ? a?.splashFactory : b?.splashFactory,
backgroundBuilder: t < 0.5 ? a?.backgroundBuilder : b?.backgroundBuilder,
foregroundBuilder: t < 0.5 ? a?.foregroundBuilder : b?.foregroundBuilder,
sizeVariant: t < 0.5 ? a?.sizeVariant : b?.sizeVariant,
iconButtonWidth: t < 0.5 ? a?.iconButtonWidth : b?.iconButtonWidth,
shapeVariant: t < 0.5 ? a?.shapeVariant : b?.shapeVariant,
);
}
}
Loading