Skip to content

FSE themes: Have theme.json handle minimum widths of blocks #34573

Closed

Description

@andersnoren

What problem does this address?

I had a hard time searching for this, so apologies if I missed an existing issue for it.

I’ve been thinking about FSE themes and container widths – specifically, the width of blocks when the screen is thinner than the max-width set by settings.layout.contentSize and settings.layout.wideSize. By default, if you resize your screen to be thinner than these values, the blocks simply extend all the way to the edge of the screen, like this:

tt1-blocks-screen-width

That means that themes need to include CSS to set a gutter between blocks and the edges of the screen when the screen is thinner than settings.layout.contentSize or settings.layout.wideSize.

Almost every FSE theme I’ve looked at seems to approach this a bit differently. These are the solutions I’ve seen:

  1. Setting a horizontal padding on containers, and a negative horizontal margin on alignfull elements and nested containers. This approach seems to break when nested containers are set to horizontal auto margins by the Core .wp-container-XXX styles. (Blockbase)
  2. Setting a horizontal padding on non-alignfull elements beneath a certain screen width threshold. (Armando)
  3. Requiring elements to be wrapped in certain container blocks (like alignfull groups, or groups with specific custom classes) for them to have horizontal spacing beneath the max-width, and setting a horizontal padding on .wp-block-post-content and other specific elements. (Aino, Clove)
  4. Not including any CSS for it, resulting in the blocks extending to the edge of the screen when the screen is thinner than the max-width. (TT1 Blocks, the screenshot above)

What is your proposed solution?

This seems like something that should be handled in theme.json by adding something like settings.layout.minimumWidth. When set (to, say, calc( 100% - 32px ), Core makes sure that the .wp-container-XXX inline style sets that as the width on the right blocks in the container, so those blocks have that width (with a gutter of 16px in this case) below settings.layout.contentSize and settings.layout.wideSize.

If isn’t handled by Core, every theme rolling their own solution to it seems like something that can lead to large layout issues when users switch between themes (esp. if some themes rely on custom class names) or when the markup structure in Core changes and the CSS targeting in themes break.

Activity

  1. added
    Global Styles
    on Sep 6, 2021
  2. added
    [Feature] Site Editor
    and removed on Jul 24, 2023
  3. added
    [Type] Enhancement
    on Sep 14, 2023
  4. ntsekouras commented on Sep 21, 2026

    @ntsekouras
    Contributor

    This was covered by root padding: styles.spacing.padding at the root (#35241) together with settings.useRootPaddingAwareAlignments (#42085) gives the gutter below the content width without theme CSS, and it's what the default themes use now. So I'm closing this one. Feel free to reopen if I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global Styles[Feature] Site Editor[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions