Skip to content

Material 3 - Regular chip and Action chip templates using invalid tokens #141288

@davidmartos96

Description

@davidmartos96

Steps to reproduce

To reproduce run the gen_defaults tool (#140872 improves some false positives and the output)
Here is the result:

image

Filter chip and input chip token usages are being fixed in #140573
The assist-chip token (called ActionChip in Flutter) is being referenced in both the chip_template and the action_chip_template files.

More specifically, the token is referenced for the checkmarkColor and deleteIconColor values. Since the gen tool was reading non existing tokens, the resulting value is a null color.

Color? get checkmarkColor => ${color("$tokenGroup.with-icon.selected.icon.color")};

Color? get checkmarkColor => ${color("$tokenGroup.with-icon.selected.icon.color")};


Action Chip

To fix the action chip template I propose the following:

deleteIconColor

Action chips don't have an onDeleted callback in the Flutter API, so we could leave the value explicitly as null

checkmarkColor

We could do the same here, because action chips in the Flutter API cannot be selected and they don't have a showCheckmark parameter. Alternatively we can use the same tokens as the leading icon. Any of the solutions would result in the same output, as there is an iconTheme above the leading icon, which takes the correct token already.


(Regular) Chip

The regular Chip template is taking the token values from the assist-chip specification. This can fall short when we try to pick values from the assist-chip spec for the delete and the checkmark icons.

static const String tokenGroup = 'md.comp.assist-chip';

To fix the chip template I propose the following:

deleteIconColor

For this type of chip, Flutter provides an onDeleted callback, so we need to find an appropiate token. The problem is that assist-chip doesn't contemplate having a trailing icon, only a leading icon with the primary color. So if we would use assist-chip icon color, it would turn the delete icon purple/pink instead of dark grey (default Material 3 theme). I propose that we change the chip template to read from filter-chip instead, which is more general, contemplating the possibility of a leading icon and a trailing icon (delete/dropdown) with appropriate colors.
Changing the base of the chip template with filter-chip doesn't really have much changes visually. The delete icon color would go from black to (onSurfaceVariant) dark grey in a light theme. The leading icon color stays the same, as well as the chip borders.

checkmarkColor

Same as the Action Chip proposed changes.


Common changes

Same as #140573 we can update the label color with the correct token. The color token for the label is not currently being used.


Regular chip visual differences

A regular Chip would change as follows. Essentially, black -> dark grey (onSurfaceVariant) for both the label and the delete icon.

Before

image

After (picture from the M3 spec)

Ignore the icon difference. Flutter picks a different delete icon for the regular Chip.

image

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.found in release: 3.19Found to occur in 3.19frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions