Skip to content

Banner: Allow Banner.Title to be set as <p> - #8275

Open
TylerJDev wants to merge 4 commits into
mainfrom
tylerjdev/adjust-as-banner-title
Open

Banner: Allow Banner.Title to be set as <p>#8275
TylerJDev wants to merge 4 commits into
mainfrom
tylerjdev/adjust-as-banner-title

Conversation

@TylerJDev

@TylerJDev TylerJDev commented Aug 6, 2026

Copy link
Copy Markdown
Member

Part of https://github.com/github/accessibility-audits/issues/16930

This PR allows Banner.Title to be rendered as a paragraph (<p>) in addition to the existing heading levels (h2h6).

In some contexts, a Banner is used where a heading is not appropriate. Rendering the title as a heading in those cases introduces an unnecessary heading into the document structure, which can be disorienting for screen reader users.

Allowing Banner.Title to be set as a <p> lets consumers avoid an unnecessary heading level while keeping the visual styling of the title.

The default remains h2, so this is a non-breaking, additive change.

Changelog

New

  • Banner.Title now supports as="p" to render the title as a paragraph instead of a heading.

Changed

  • Updated the as prop type for Banner.Title from 'h2' | 'h3' | 'h4' | 'h5' | 'h6' to also include 'p', and documented the default value of 'h2'.

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

  • Verify Banner.Title still renders as an h2 heading by default.
  • Verify Banner.Title as="p" renders a paragraph element (no heading role) — see the added test should support rendering as a paragraph element.
  • Confirm existing heading-level rendering (h2h6) is unchanged.

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad45be3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@TylerJDev
TylerJDev marked this pull request as ready for review August 6, 2026 15:15
@TylerJDev
TylerJDev requested a review from a team as a code owner August 6, 2026 15:15
@TylerJDev
TylerJDev requested review from siddharthkp and a lite review from Copilot and removed request for Copilot August 6, 2026 15:15
@primer

primer Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🤖 Lint and formatting issues have been automatically fixed and committed to this PR.

@TylerJDev TylerJDev added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Aug 6, 2026
Copilot AI lite review requested due to automatic review settings August 12, 2026 17:06
@primer-integration

primer-integration Bot commented Aug 12, 2026

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed  CI   Passed
Waiting  VRT   Waiting
Waiting  Projects   Waiting

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Banner.Title in @primer/react to support rendering as a paragraph (as="p") in addition to heading levels (h2h6), to avoid introducing unnecessary headings in document structure (accessibility-driven, additive API change).

Changes:

  • Expanded Banner.Title’s as prop type to include 'p' and set a default generic of 'h2'.
  • Added a unit test covering paragraph rendering.
  • Updated component docs metadata and added a minor changeset entry.
Show a summary per file
File Description
packages/react/src/Banner/Banner.tsx Extends Banner.Title element type union to include p and simplifies prop typing to ComponentPropsWithoutRef<As>.
packages/react/src/Banner/Banner.test.tsx Adds a test for as="p" rendering, but currently asserts an invalid ARIA role.
packages/react/src/Banner/Banner.docs.json Documents 'p' support and records default as value ('h2').
.changeset/tidy-banners-title-element.md Adds a minor-release changeset entry for the new as="p" support.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

<Banner.Title as="p">test paragraph</Banner.Title>
</Banner>,
)
expect(screen.getByText('test paragraph')).toHaveRole('paragraph')
@TylerJDev
TylerJDev added this pull request to the merge queue Aug 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 12, 2026

@siddharthkp siddharthkp left a comment

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.

Sorry, I think I disagree with this choice. If the issue mentioned in the description is the only instance that benefits from opening up the API, we shouldn't do it.

Have we considered that the instance mentioned in the issue should not be a Banner at all as it does not satisfy the 2 use cases from the docs

  1. Highlight important information.
  2. Provide feedback after a user action.

It looks like a Banner, but looks like we do not want it to act like a Banner. (for me, the design choice is debatable too. It's "information" that a section has moved, there is no need for it to be attention grabbing (visually too) 🤔

Image

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

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants