Skip to content

refactor: apply content styles on part instead of slotted element#11458

Merged
sissbruecker merged 9 commits intomainfrom
refactor/app-layout-content-styles
Apr 14, 2026
Merged

refactor: apply content styles on part instead of slotted element#11458
sissbruecker merged 9 commits intomainfrom
refactor/app-layout-content-styles

Conversation

@sissbruecker
Copy link
Copy Markdown
Contributor

@sissbruecker sissbruecker commented Apr 8, 2026

Description

Updates Aura App Layout theme to apply content styles on the content part instead of slotted content elements:

  • Introduce a content part, update style rules to use it
  • Update Aura theme to style the content part instead of the slotted element
  • Modify the content offset mechanism so that the offset of the content from drawer / navbar is applied via padding on the host element
    • The previous approach used a padding on the content part, resulting in the content part stretching below the drawer, which does not give the correct visual result when applying a background / border on the content
    • Using a margin on the content part works as an alternative, however that makes customizing the margin of the content part more complex for users, as they would need to write CSS rules that account for the drawer offset

Fixes #11431

Type of change

  • Refactor

Comment thread packages/aura/src/components/app-layout.css Outdated
Comment thread packages/aura/src/components/app-layout.css
border-inline-width: min(var(--aura-app-layout-inset), var(--aura-app-layout-border-width));
}

vaadin-app-layout > vaadin-master-detail-layout:nth-child(1 of :not([slot])):nth-last-child(1 of :not([slot])) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this needs changes?

Copy link
Copy Markdown
Contributor Author

@sissbruecker sissbruecker Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the safe inset behavior doesn't work correctly for the Aura theme in most cases (only top works). This is also reproducable on main. Probably better to fix this as a follow up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the safe area insets are likely a bit broken, at least in the aura.html dev page, which has custom CSS to manage those.

@sissbruecker sissbruecker marked this pull request as ready for review April 9, 2026 07:55
@sissbruecker sissbruecker requested a review from jouni April 9, 2026 07:57
Comment on lines +140 to +141
:host([has-navbar]),
:host([has-navbar]:not([overlay])) [part='drawer'] {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong, as first selector always matches when a navbar is visible, and the second selector doesn't add anything. The custom property is inherited by the drawer part from the host.

The point of this rule is that app layout handles the safe area inset in certain cases, and then makes it unnecessary for other contained parts to handle it.

For example, when the navbar is visible, it handles the top safe area, so the drawer and content parts don't need to care about it anymore (there might be components within them that want to account for the safe area themselves).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the rule for the content part. The inset is now applied as padding on the host element itself. This works out as the padding for the host is the maximum of the navbar height or the safe inset. As the navbar includes the inset itself, the content is always properly offset due to the navbar height.

}

:host([has-drawer]:not([overlay])[drawer-opened]) [content] {
:host([has-drawer]:not([overlay])[drawer-opened]) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here: the drawer part wants to know about the left safe area inset (so we shouldn't change it to zero on the host), but prevent the content area from handling it again (so set it to zero on the content), as the drawer is already pushing the content out from under the safe area.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule should be obsolete now that the host handles the inset. Like above, this should work because it offsets the content to at least the drawer width (when drawer is visible) or the safe inset, whichever is greater.

Comment thread packages/app-layout/src/vaadin-app-layout.d.ts Outdated
Comment thread packages/app-layout/src/vaadin-app-layout.js Outdated
Comment thread packages/aura/src/components/app-layout.css Outdated
@sonarqubecloud
Copy link
Copy Markdown

@sissbruecker sissbruecker requested a review from jouni April 13, 2026 09:58
@sissbruecker sissbruecker merged commit 14ae3f8 into main Apr 14, 2026
10 checks passed
@sissbruecker sissbruecker deleted the refactor/app-layout-content-styles branch April 14, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[app-layout] introduce styleable content part

2 participants