Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Components: Deprecate outer margins #39358

Open
19 of 20 tasks
mirka opened this issue Mar 10, 2022 · 3 comments
Open
19 of 20 tasks

Components: Deprecate outer margins #39358

mirka opened this issue Mar 10, 2022 · 3 comments
Labels
[Package] Components /packages/components [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues.

Comments

@mirka
Copy link
Member

mirka commented Mar 10, 2022

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 }
/>
@mirka mirka added [Package] Components /packages/components [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. labels Mar 10, 2022
lipemat added a commit to lipemat/types-js-boilerplate that referenced this issue Oct 18, 2024
WP 6.7 decided to flood the browser console with deprecation warnings for a good
 portion of the most used components.

This means to clear the console you must.
- Opt into no margin
- Provide your own margin handling for bottom margins.

Hopefully one day we can revert this!!

WordPress/gutenberg#39358
@Ugoku
Copy link

Ugoku commented Oct 21, 2024

I'm the developer of a plugin that uses several of these components in a Gutenberg block. What is the proper way of using a component with some margin at the bottom? Should I add a class to the components, or add a wrapper, or something else?

@mirka
Copy link
Member Author

mirka commented Oct 24, 2024

@Ugoku Good question!

We are in a somewhat transitional state right now, so most components injected into the Block Inspector will continue to have an automatic bottom margin (see #65191 for context).

Otherwise, feel free to do whatever makes sense for your use case — put them in a flexbox wrapper div with gap, or add your own class name to certain components.

@Ugoku
Copy link

Ugoku commented Oct 24, 2024

Thanks for your reply @mirka ! If here's no preferred way, I will have a look to see what best suits us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues.
Projects
None yet
Development

No branches or pull requests

2 participants