Skip to content

fix(web-components): remove default MessageBar max-width#36389

Open
AKnassa wants to merge 1 commit into
microsoft:masterfrom
AKnassa:fix/36365-message-bar-max-width
Open

fix(web-components): remove default MessageBar max-width#36389
AKnassa wants to merge 1 commit into
microsoft:masterfrom
AKnassa:fix/36365-message-bar-max-width

Conversation

@AKnassa

@AKnassa AKnassa commented Jul 11, 2026

Copy link
Copy Markdown

Previous Behavior

<fluent-message-bar> capped its content at a hardcoded max-width: 520px. Per current Fabric design guidance that cap is no longer desired, and it doesn't match Fluent UI React v9 (whose MessageBarBody has no max-width).

New Behavior

The MessageBar content is no longer capped by default — it fills its container, matching React v9. Consumers who still want a cap can opt in with a new CSS custom property:

fluent-message-bar {
  --message-bar-content-max-width: 520px; /* or any length */
}

Why a custom property (rather than removing the cap outright)

The issue offered three options — remove entirely, a CSS custom property, or a CSS part. I went with the custom property because it delivers the requested default (no cap) while leaving a supported, on-convention escape hatch for anyone who relied on the 520px cap — no shadow-DOM piercing required. It mirrors the existing --drawer-width / --menu-max-height idiom and keeps the new public surface minimal (a single documented property), which felt appropriate for an issue still marked Needs: Discussion.

Happy to switch to a plain removal, or additionally expose part="content", if the team prefers — @chrisdholt.

What changed

  • message-bar.styles.tsmax-width: 520pxmax-width: var(--message-bar-content-max-width, none)
  • message-bar.styles.css — regenerated via yarn generate:ssr (the committed SSR mirror)
  • message-bar.ts — documented the new property with @cssproperty
  • message-bar.spec.ts — two tests: no cap by default, and it caps when the property is set (both run across CSR and SSR)
  • beachball change file (minor — introduces a new public CSS custom property)

How to verify

cd packages/web-components
yarn e2e src/message-bar/message-bar.spec.ts

48 pass (8 tests × chromium/firefox/webkit × CSR/SSR). Visually, in Storybook, a long single-line message no longer clamps at 520px; setting --message-bar-content-max-width re-introduces the cap.

Notes for the reviewer

  • Regenerating the SSR stylesheet also re-synced a small pre-existing drift: the committed message-bar.styles.css was missing color: var(--colorNeutralForeground3) on :host that the source (.styles.ts) already declares — so SSR text color differed from CSR. I kept the corrected output so check:ssr stays green for this component. This is the only incidental line beyond the max-width change.
  • apps/vr-tests-web-components has no MessageBar story, so this visual change has no VRT snapshot guard today — flagging as a possible follow-up.

Related Issue(s)

Drop the default 520px cap on MessageBar content so it fills its
container, matching Fluent React v9 (per Fabric design guidance).
Add an opt-in `--message-bar-content-max-width` CSS custom property
for consumers who still want to cap the content width.

Fixes microsoft#36365

Claude-Session: https://claude.ai/code/session_016KRzffUGCCC7w6YaAz9nbF
@AKnassa AKnassa marked this pull request as ready for review July 11, 2026 00:17
@AKnassa AKnassa requested a review from a team as a code owner July 11, 2026 00:17
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.

[Bug]: MessageBar max-width

1 participant