Skip to content

Button Block: Custom width support #73871

@jayclydeTags

Description

@jayclydeTags

What problem does this address?

The Button block currently offers only four preset width options (25%, 50%, 75%, 100%) accessible through the Settings sidebar. This limitation creates several UX and design challenges:

Specific pain points:

  1. Inflexible layout distribution - When designing button groups that require equal distribution across a row (e.g., 5 buttons = 20% each, 3 buttons = 33.33% each), the current presets don't accommodate these common use cases
  2. No custom unit support - Users cannot specify width values using other CSS units (px, rem, em, vw) that may be more appropriate for responsive design patterns
  3. Limited design control - Designers following specific brand guidelines or design systems that require precise button widths (e.g., 150px, 12rem) must resort to custom CSS workarounds
  4. Inconsistent with other blocks - Many Gutenberg blocks (Column, Spacer) allow custom dimension inputs, creating an inconsistent editing experience

What is your proposed solution?

Add a custom width input field in the Button block's Settings panel that accepts both numeric values and unit specifications.

Proposed UI changes:

  1. Replace or supplement the preset buttons with a unit control input (similar to the one used in Spacer, Column)

    • Input field accepting numeric values
    • Dropdown for unit selection (%, px, rem, em, vw, auto)
    • Presets could remain as quick-select options above the custom input
  2. Input field specifications:

    • Allow direct numeric input (e.g., "20", "150", "33.33")
    • Unit selector dropdown with common CSS units
    • Default unit: % (maintaining current behavior)
    • Support for "auto" to return to default/content-based width
    • Real-time preview in the editor
  3. Validation and boundaries:

    • For percentage: 0-100% range with optional warning for values >100%
    • For px/rem/em: Reasonable min/max values or no restriction with user responsibility

Spacer Settings

Image

Column block settings

Image

Example use case from screenshot:

In the provided example, 5 buttons need equal distribution. With custom width input, users could set each button to "20%" width, achieving perfect equal spacing that's currently impossible with the 25%/50%/75%/100% presets.

Image

Benefits:

  • Eliminates need for custom CSS workarounds for common layout patterns
  • Provides consistency with other Gutenberg blocks' dimension controls
  • Improves accessibility to advanced layouts for non-technical users
  • Supports responsive design workflows with multiple unit options

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] ButtonsAffects the Buttons Block[Status] DuplicateUsed to indicate that a current issue matches an existing one and can be closed[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions