# WIP: Contextual Spacing: "Apply Spacing Inside" does not work with mobile-first breakpoints

**URL:** <https://forum.bricksbuilder.io/t/wip-contextual-spacing-apply-spacing-inside-does-not-work-with-mobile-first-breakpoints/40881>\
**Category:** Bugs\
**Tags:** v2-4-6\
**Created:** [November 26, 2026, 4:24pm UTC](https://forum.bricksbuilder.io/t/wip-contextual-spacing-apply-spacing-inside-does-not-work-with-mobile-first-breakpoints/40881 "2026-11-26T16:24:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HExSM](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/h/bbce88/32.png) [@HExSM](https://forum.bricksbuilder.io/u/HExSM)\
**Post date:** [November 26, 2026, 4:24pm UTC](https://forum.bricksbuilder.io/t/wip-contextual-spacing-apply-spacing-inside-does-not-work-with-mobile-first-breakpoints/40881/1 "2026-11-26T16:24:46Z")

</div>

When using a mobile-first breakpoint configuration, Heading, Paragraph and Fallback Spacing are not applied to custom CSS selectors defined under **Theme Styles → Contextual Spacing → Apply Spacing Inside**.

Contextual Spacing works correctly for regular WordPress post content. Additional Target Elements also work as expected within custom selectors.

## Steps to reproduce

1. Configure Bricks to use mobile-first breakpoints.
2. Open Theme Styles → Contextual Spacing.
3. Set values for Heading, Paragraph and Fallback Spacing at the base breakpoint (Mobile Portrait).
4. Enter `.prose` in the Apply Spacing Inside field.
5. Add a Container element and assign the class `prose`.
6. Set the container’s row gap to `0`.
7. Add several Heading and Basic Text elements, using `p` as the HTML tag for Basic Text.
8. Inspect the result and the generated CSS in the frontend.

## Expected behavior

Heading, Paragraph and Fallback Spacing should be applied within `.prose`, respecting the configured breakpoint values.

## Actual behavior

No corresponding CSS rules are generated for `.prose`. Rules for Additional Target Elements, however, are generated correctly.

## Root cause

I investigated the source code of Bricks and found that the implementation in `includes/assets.php`, lines 4812–4851, within `generate_inline_css_from_element()`, retrieves the spacing values without considering breakpoint suffixes:

```php
$heading_spacing = isset( $settings['contextualSpacingHeading'] ) ? $settings['contextualSpacingHeading'] : '';

```

The same applies to `contextualSpacingParagraph` and `contextualSpacingFallback`.

With a mobile-first configuration, however, these settings are stored with the `:mobile_portrait` suffix, as confirmed by my Theme Style export:

```json
"contextualSpacingHeading:mobile_portrait": "var(--heading-spacing)",
"contextualSpacingParagraph:mobile_portrait": "var(--paragraph-spacing)",
"contextualSpacingFallback:mobile_portrait": "var(--flow-spacing)",
"contextualSpacingApplyTo": ".prose"

```

As a result, the spacing values are not retrieved and the corresponding CSS rules are not generated.

The CSS generation for custom selectors appears to assume a desktop base breakpoint and does not account for breakpoint-specific values.

## Suggested fix

Ensure that Heading, Paragraph and Fallback Spacing are correctly applied to the selectors defined under **Apply Spacing Inside** , taking the active base breakpoint and breakpoint-specific spacing values into account.

The existing implementation for Additional Target Elements already handles this correctly and could serve as a reference.

---

<div class="post-metadata">

**Author:** ![timmse](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/timmse/32/1192_2.png) [@timmse](https://forum.bricksbuilder.io/u/timmse)\
**Post date:** [November 27, 2026, 6:51am UTC](https://forum.bricksbuilder.io/t/wip-contextual-spacing-apply-spacing-inside-does-not-work-with-mobile-first-breakpoints/40881/3 "2026-11-27T06:51:20Z")

</div>

Thanks for the detailed report. We reproduced the missing contextual spacing rules for custom wrappers when Mobile Portrait is the base breakpoint. We’ll update this thread once it’s fixed.
