Add label and legend headingLevel option#1670
Conversation
f6a49ba to
ba27930
Compare
ba27930 to
af64586
Compare
packages/nhsuk-frontend/src/nhsuk/components/label/template.njk
Outdated
Show resolved
Hide resolved
af64586 to
2780988
Compare
|
I support adding a We don't expect users to navigate form pages by heading - they typically need to complete the entire form. I'll note GOV.UK does not have such an option, and only added More generally on the web I don't think forms tend to mark up every legend as a heading, and I worry that if this @selfthinker have you looked at this at all before? |
|
I like the I don't have strong views on |
It does indeed. The same point was made in alphagov/govuk-frontend#5240 (comment) Makes sense |
|
I shared an example with the GOV.UK Design System team:
An update from the GOV.UK team has been passed back in return They're using custom heading levels in smart answers and (internal) publishing applications But other than that the heading level options are not widely used
|
|
HTML examples shared with the GOV.UK Design System team We've reached an early agreement that custom heading levels should be limited to:
They'd like to discuss this further at their dev catch up sessions, with emphasis on guiding people to only use Main content with asideE.g. Search sidebar alongside main content <main>
<h1><label for="question">Question</label></h1>
<input id="question">
<!-- // … -->
</main>
<aside>
<h2><label for="search">Search</label></h2>
<input id="search">
<label for="sort-by">Sort by</label></h2>
<select id="sort-by">
<!-- // … -->
</aside>Main content with multiple sectionsE.g. Staff facing team profile page with editable sections per team member <main>
<h1>Your team</h1>
<!-- // … -->
</main>
<section>
<h2><label for="person1-question1">What about Colin?</label></h2>
<input id="person1-question1">
<label for="person1-question2">Another question</label>
<input id="person1-question2">
<!-- // … -->
</section>
<section>
<h2><label for="person2-question1">What about Romaric?</label></h2>
<input id="person2-question1">
<label for="person2-question2">Another question</label>
<input id="person2-question2">
<!-- // … -->
</section> |
9410511 to
403b7a8
Compare
size and headingLevel optionsheadingLevel option
570fd96 to
83d856e
Compare
564250a to
f93c89c
Compare
83d856e to
345d8c1
Compare
f93c89c to
8380cf6
Compare
345d8c1 to
fe9fc5d
Compare
8380cf6 to
539b0e2
Compare
fe9fc5d to
56d1b05
Compare
539b0e2 to
ea589a1
Compare
ea589a1 to
abe8702
Compare
abe8702 to
f00d4b7
Compare
f00d4b7 to
b495038
Compare
b495038 to
5cf5067
Compare
5cf5067 to
12e5fcd
Compare
12e5fcd to
65ace82
Compare
|



Description
The Nunjucks option
isPageHeadingsets whether the label or legend also acts as the heading for the page.This PR adds a new
headingLevelNunjucks option as a replacement forisPageHeadingwhen a custom heading level is necessary, for example when a label or legend acts as the heading for a landmark:<aside> {{ input({ label: { text: 'Search', - isPageHeading: true + headingLevel: 2 } }) }} <!-- // … --> </aside>This aligns with support already in NHS.UK React components
See related PR and issue over on GOV.UK Frontend
headingLevelalphagov/govuk-frontend#5240<h2>or deeper headings as label or legend of fields alphagov/govuk-frontend#6471Checklist