Page MenuHomePhabricator

[Button, ButtonGroup] Reconsider max-width
Open, Needs TriagePublic

Description

The CdxButton component currently has an explicit max-width of 448px via the @size-width-button component-level token. This token has a comment:

Note, that this is a slight amendment from WikimediaUI Base from 28.75em = 460px to 448px

This max-width keeps the button from being absurdly long, and T309825 improved Button styles at that max-width by truncating text via an ellipsis. However, the max-width can cause issues at smaller viewport widths or when a button exists in a narrow container. For example, here's the configurable Button demo on a small screen:

Screen Shot 2022-06-08 at 9.17.21 AM.png (278×864 px, 28 KB)

It the Button had a max-width of 100%, we'd get this instead:

Screen Shot 2022-06-08 at 9.17.31 AM.png (268×856 px, 27 KB)

This could also help in the circumstance of a centered, full-width button, as demonstrated in the Figma spec (note that this Button has a width of 624px):

image.png (190×1 px, 19 KB)

For historical context: the OOUI ButtonWidget has no max-width.


Acceptance criteria
  • Discuss the current max-width and determine if it should remain, if max-width should be 100%, or if it should be some other value
  • Make the change if needed

Event Timeline

@Volker_E do you know where the current max-width came from? I'm guessing WVUI, but would appreciate any context you have to share!

I think the button max-width shouldn't be fixed to a specific size but should have a 100% max-width to fit it with the demo box in all sizes and devices.

Captura de pantalla 2022-06-08 a las 17.24.51.png (1×1 px, 575 KB)

The problem has come up in mobile on tablet plus viewports as buttons have applied a display:block and the max-width has been around for 7+ years.

image.png (1×2 px, 189 KB)

Buttons should not go full length here. It looks confusing with the center alignment and it's also confusing to understand that it represents a button.

We should be able to decide when we want the buttons to be full width and when we want the buttons to increase with the length of the text. Or at least, we could implement a button max-width with the max-width of each screen where the button is placed (to avoid the button to be with more than 1 text line).

Captura de Pantalla 2022-06-10 a las 9.58.21.png (160×2 px, 65 KB)

The buttons currently grow in size until 448px. On a portrait phone they already take up nearly full-width. On landscape or a tablet I think a max-width similar to the status quo is useful to remain visually characteristic as a button.

The problem has come up in mobile on tablet plus viewports as buttons have applied a display:block and the max-width has been around for 7+ years.

image.png (1×2 px, 189 KB)

Buttons should not go full length here. It looks confusing with the center alignment and it's also confusing to understand that it represents a button.

Perhaps this is a problem that should be resolved in the mobile skin, then? If we provide, by default, an inline button with max-width: 100% and an implementation sets display: block, it seems like that implementation should handle adding a new max-width as well.

It seems critical that we prevent the situation documented in the task description.

It looks like this task is blocking the resolution of T306025 – any updates here?

ldelench_wmf renamed this task from Button: reconsider max-width to [ButtonGroup] Button: reconsider max-width.Dec 21 2022, 7:00 PM
egardner renamed this task from [ButtonGroup] Button: reconsider max-width to [Button, ButtonGroup] Reconsider max-width.Dec 21 2022, 7:06 PM
ldelench_wmf moved this task from Needs Refinement to Backlog on the Design-Systems-Team board.

We could use CSS's min() function to do something like this:

max-width: min( @max-width-button, 100% );

That way, it'll choose the value that is smaller, so when the button's container is smaller than @max-width-button, the max width becomes 100%.

Unfortunately, this is not supported in a few older browsers for which we offer basic support:

  • Safari < 11.1 (including iOS)
  • IE 11
  • Firefox < 75

For those browsers, we can default to max-width: 100%, which will prevent buttons from overflowing their containers and may just result in a few very wide buttons on desktop.

When refining this task, we should resolve the discussion in T337865: Buttons: Define a text truncation approach for buttons that prevents overflow. The addition of a Tooltip for truncated text makes sense to me, and would imply this is actually blocked on T340456: Tooltip: Add Tooltip component to Codex.

egardner raised the priority of this task from Lowest to Needs Triage.Oct 2 2023, 9:13 PM
egardner moved this task from Needs Refinement to Backlog on the Design-Systems-Team board.