Skip to main content
Preview This is a design system preview environment for main branch

Internal review app NHS.UK frontend

Use design system guidance and examples to build consistent, accessible NHS services for the public and staff.

Label

These examples are used for automated tests and may not follow service manual best practice.

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--l">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: "What is your full name?",
  size: "l"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--s">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: "What is your full name?",
  size: "s"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--m">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: "What is your full name?",
  size: "m"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--l">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: "What is your full name?",
  size: "l"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--xl">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: "What is your full name?",
  size: "xl"
}) }}
Code

Markup

<label class="nhsuk-label nhsuk-label--s">
  <span class="nhsuk-caption">
    About you
  </span>
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: "About you",
  size: "s"
}) }}
Code

Markup

<label class="nhsuk-label nhsuk-label--m">
  <span class="nhsuk-caption-m">
    About you
  </span>
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: "About you",
  size: "m"
}) }}
Code

Markup

<label class="nhsuk-label nhsuk-label--l">
  <span class="nhsuk-caption-l">
    About you
  </span>
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: "About you",
  size: "l"
}) }}
Code

Markup

<label class="nhsuk-label nhsuk-label--xl">
  <span class="nhsuk-caption-xl">
    About you
  </span>
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: "About you",
  size: "xl"
}) }}

Label with size S text and caption "after" as a paragraph

Open this example in a new tab: Label with size S text and caption "after" as a paragraph

About you

Code

Markup

<label class="nhsuk-label nhsuk-label--s">
  What is your full name?
</label>
<p class="nhsuk-caption nhsuk-caption--bottom">
  About you
</p>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: {
    text: "About you",
    placement: "after",
    element: "p"
  },
  size: "s"
}) }}

Label with size M text and caption "after" as a paragraph

Open this example in a new tab: Label with size M text and caption "after" as a paragraph

About you

Code

Markup

<label class="nhsuk-label nhsuk-label--m">
  What is your full name?
</label>
<p class="nhsuk-caption-m nhsuk-caption--bottom">
  About you
</p>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: {
    text: "About you",
    placement: "after",
    element: "p"
  },
  size: "m"
}) }}

Label with size L text and caption "after" as a paragraph

Open this example in a new tab: Label with size L text and caption "after" as a paragraph

About you

Code

Markup

<label class="nhsuk-label nhsuk-label--l">
  What is your full name?
</label>
<p class="nhsuk-caption-l nhsuk-caption--bottom">
  About you
</p>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: {
    text: "About you",
    placement: "after",
    element: "p"
  },
  size: "l"
}) }}

Label with size XL text and caption "after" as a paragraph

Open this example in a new tab: Label with size XL text and caption "after" as a paragraph

About you

Code

Markup

<label class="nhsuk-label nhsuk-label--xl">
  What is your full name?
</label>
<p class="nhsuk-caption-xl nhsuk-caption--bottom">
  About you
</p>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: {
    text: "About you",
    placement: "after",
    element: "p"
  },
  size: "xl"
}) }}

Label with size S text and caption "before" as a paragraph

Open this example in a new tab: Label with size S text and caption "before" as a paragraph

About you

Code

Markup

<p class="nhsuk-caption">
  About you
</p>
<label class="nhsuk-label nhsuk-label--s">
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: {
    text: "About you",
    placement: "before",
    element: "p"
  },
  size: "s"
}) }}

Label with size M text and caption "before" as a paragraph

Open this example in a new tab: Label with size M text and caption "before" as a paragraph

About you

Code

Markup

<p class="nhsuk-caption-m">
  About you
</p>
<label class="nhsuk-label nhsuk-label--m">
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: {
    text: "About you",
    placement: "before",
    element: "p"
  },
  size: "m"
}) }}

Label with size L text and caption "before" as a paragraph

Open this example in a new tab: Label with size L text and caption "before" as a paragraph

About you

Code

Markup

<p class="nhsuk-caption-l">
  About you
</p>
<label class="nhsuk-label nhsuk-label--l">
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: {
    text: "About you",
    placement: "before",
    element: "p"
  },
  size: "l"
}) }}

Label with size XL text and caption "before" as a paragraph

Open this example in a new tab: Label with size XL text and caption "before" as a paragraph

About you

Code

Markup

<p class="nhsuk-caption-xl">
  About you
</p>
<label class="nhsuk-label nhsuk-label--xl">
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  caption: {
    text: "About you",
    placement: "before",
    element: "p"
  },
  size: "xl"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--m">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  size: "m",
  isPageHeading: true
}) }}
Code

Markup

<label class="nhsuk-label">
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: {
    text: "What is your full name?",
    level: 3,
    size: "s"
  },
  isPageHeading: false
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--l">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  size: "l",
  heading: {
    level: 1
  }
}) }}

Code

Markup

<h2 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--m">
    What is your full name?
  </label>
</h2>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  size: "m",
  heading: {
    level: 2
  }
}) }}

Code

Markup

<h3 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--s">
    What is your full name?
  </label>
</h3>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?",
  size: "s",
  heading: {
    level: 3
  }
}) }}

Code

Markup

<h3 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--s">
    What is your full name?
  </label>
</h3>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: {
    text: "What is your full name?",
    level: 3,
    size: "s"
  }
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--l">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  html: "What is your full name?",
  heading: true,
  size: "l"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--l">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{% call label({
  heading: true,
  size: "l"
}) -%}
What is your full name?
{%- endcall %}
Code

Markup

<label class="nhsuk-label nhsuk-label--l">
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{% call label({
  size: "l"
}) -%}
What is your full name?
{%- endcall %}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--l" id="custom-id">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  id: "custom-id",
  heading: "What is your full name?",
  size: "l"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper" id="custom-id">
  <label class="nhsuk-label nhsuk-label--l">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: {
    text: "What is your full name?",
    id: "custom-id"
  },
  size: "l"
}) }}
Code

Markup

<label class="nhsuk-label">
  What is your full name?
</label>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  text: "What is your full name?"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--l">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: "What is your full name?",
  classes: "nhsuk-label--l"
}) }}

Code

Markup

<h1 class="nhsuk-label-wrapper">
  <label class="nhsuk-label nhsuk-label--l">
    What is your full name?
  </label>
</h1>

Macro

{% from "label/macro.njk" import label -%}

{{ label({
  heading: "What is your full name?",
  classes: "nhsuk-label--l",
  size: "s"
}) }}