Skip to content

Components: Deprecate outer margins #39358

@mirka

Description

@mirka

What problem does this address?

A lot of components currently have inherent outer margins, making it hard to reuse in different contexts since it requires a style override (often of an internal element). This kind of style override is something we want to discourage.

What is your proposed solution?

Deprecate the bottom margin (similar to #37160), following the guidelines stipulated in the devdocs.

Components

Each component first needs a __nextHasNoMarginBottom prop to opt in, and then they also need to be officially deprecated after all in-repo usage has been migrated.

Block Editor Components

(Component lists may not be exhaustive, please add)


✍️ Dev Note (WordPress 6.7 release)

Bottom margin styles are deprecated

A number of UI components currently ship with styles that give them bottom margins. This can make it hard to reuse them in arbitrary layouts, where you want different amounts of gap or margin between components.

To better suit modern layout needs, we have gradually been deprecating these margins. A deprecation begins with an opt-in period where you can choose to apply the new margin-free styles on a given component instance. Eventually in a future version, the margins will be completely removed.

Continuing the effort started in previous releases, for the WordPress 6.7 release we will start logging deprecation warnings for the following components if they are not yet opting into the new margin-free styles:

  • BaseControl
  • CheckboxControl
  • ComboboxControl
  • DimensionControl
  • FocalPointPicker
  • FormTokenField
  • RangeControl
  • SearchControl
  • SelectControl
  • TextControl
  • TextareaControl
  • ToggleControl
  • ToggleGroupControl
  • TreeSelect

To start opting into the new margin-free styles, set the __nextHasNoMarginBottom prop to true.

<SelectControl
  options={ selectOptions }
  value={ selectValue }
  label={ __( 'Label' ) }
  onChange={ onSelectChange }
  __nextHasNoMarginBottom={ true }
/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Package] Components/packages/components[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions