Skip to content

Button: the small and compact sizes should not use a fixed width #63247

@afercia

Description

@afercia

Description

Splitting this out from #61761 (comment)

The compact and small sizes of the Button component use a fixed width. See the related CSS:

&.is-compact {
height: $button-size-compact;
&.has-icon:not(.has-text) {
padding: 0;
width: $button-size-compact;
min-width: $button-size-compact;
}
}
&.is-small {
height: $button-size-small;
line-height: 22px;
padding: 0 8px;
font-size: 11px;
&.has-icon:not(.has-text) {
padding: 0;
width: $button-size-small;
min-width: $button-size-small;
}
}

The fixed width is only applied when the buttons use an icon and don't contain text.

However, the current implementation of 'Show button text labels' preference in the editor doesn't use text. It uses CSS generated content. By setting a fixed width, these sizes aren't compatible with 'Show button text labels' as the CSS generated text will overlap the surrounding content.

I'm not sure why a fixed width is necessary in the first place. Unless I'm missing something, when the Button contains an icon and doesn't contain text, a min-width would be sufficient as the icon will not be greater than the button.

It appears the first fixed width was added long time ago for the small size in #19344

I'd tend to think all fixed widths should be removed, they seem unnecessary to me.

Step-by-step reproduction instructions

Emulating what would happen with the editor 'Show button text labels' preference enabled:

Screenshot 2024-07-08 at 15 43 21

More screenshots at #61761

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Components/packages/components[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions