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.

Character count

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

Do not include personal information like your name, date of birth or NHS number
You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="example">
      Can you provide more detail?
    </label>
  </h1>
  <div class="nhsuk-hint" id="example-hint">
    Do not include personal information like your name, date of birth or NHS number
  </div>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="example" name="example" rows="5" aria-describedby="example-info example-hint"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="example-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "l"
  },
  hint: {
    text: "Do not include personal information like your name, date of birth or NHS number"
  },
  name: "example",
  maxlength: 200
}) }}

Do not include personal information like your name, date of birth or NHS number
You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="example">
      Can you provide more detail?
    </label>
  </h1>
  <div class="nhsuk-hint" id="example-hint">
    Do not include personal information like your name, date of birth or NHS number
  </div>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="example" name="example" rows="5" disabled aria-describedby="example-info example-hint"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="example-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "l"
  },
  hint: {
    text: "Do not include personal information like your name, date of birth or NHS number"
  },
  name: "example",
  maxlength: 200,
  disabled: true
}) }}

You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--s" for="custom-size">
      Can you provide more detail?
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="custom-size" name="example" rows="5" aria-describedby="custom-size-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="custom-size-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "s"
  },
  id: "custom-size",
  name: "example",
  maxlength: 200
}) }}

You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--m" for="custom-size">
      Can you provide more detail?
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="custom-size" name="example" rows="5" aria-describedby="custom-size-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="custom-size-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "m"
  },
  id: "custom-size",
  name: "example",
  maxlength: 200
}) }}

You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="custom-size">
      Can you provide more detail?
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="custom-size" name="example" rows="5" aria-describedby="custom-size-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="custom-size-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "l"
  },
  id: "custom-size",
  name: "example",
  maxlength: 200
}) }}

You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--xl" for="custom-size">
      Can you provide more detail?
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="custom-size" name="example" rows="5" aria-describedby="custom-size-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="custom-size-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "xl"
  },
  id: "custom-size",
  name: "example",
  maxlength: 200
}) }}

Do not include personal information like your name, date of birth or NHS number
Before
You can enter up to 200 characters
After
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="example">
      Can you provide more detail?
    </label>
  </h1>
  <div class="nhsuk-hint" id="example-hint">
    Do not include personal information like your name, date of birth or NHS number
  </div>
  <samp class="app-annotate">Before</samp>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="example" name="example" rows="5" aria-describedby="example-info example-hint"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="example-info">
    You can enter up to 200 characters
  </div>
  <samp class="app-annotate">After</samp>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "l"
  },
  hint: {
    text: "Do not include personal information like your name, date of birth or NHS number"
  },
  name: "example",
  maxlength: 200,
  formGroup: {
    beforeInput: {
      html: '<samp class="app-annotate">Before</samp>'
    },
    afterInput: {
      html: '<samp class="app-annotate">After</samp>'
    }
  }
}) }}

You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200" data-count-type="characters">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-characters-count-type">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-characters-count-type" name="example" rows="5" aria-describedby="with-characters-count-type-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-characters-count-type-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  id: "with-characters-count-type",
  name: "example",
  countType: "characters",
  maxlength: 200
}) }}

Character count with count type 'characters' and error message

Open this example in a new tab: Character count with count type 'characters' and error message

Error: Job description must be 200 characters or less

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350" data-count-type="characters">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-characters-count-type-error-message">
      Enter a job description
    </label>
  </h1>
  <p class="nhsuk-error-message" id="with-characters-count-type-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Job description must be 200 characters or less
  </p>
  <textarea class="nhsuk-textarea nhsuk-textarea--error nhsuk-js-character-count" id="with-characters-count-type-error-message" name="example" rows="5" aria-describedby="with-characters-count-type-error-message-info with-characters-count-type-error-message-error">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-characters-count-type-error-message-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  errorMessage: {
    text: "Job description must be 200 characters or less"
  },
  id: "with-characters-count-type-error-message",
  name: "example",
  countType: "characters",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format."
}) }}

Character count with count type 'characters' and threshold

Open this example in a new tab: Character count with count type 'characters' and threshold

You can enter up to 112 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="112" data-threshold="75" data-count-type="characters">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-characters-count-type-threshold">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-characters-count-type-threshold" name="example" rows="5" aria-describedby="with-characters-count-type-threshold-info">Type another letter into this field after this message to see the threshold feature</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-characters-count-type-threshold-info">
    You can enter up to 112 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  id: "with-characters-count-type-threshold",
  name: "example",
  countType: "characters",
  value:
    "Type another letter into this field after this message to see the threshold feature",
  maxlength: 112,
  threshold: 75
}) }}

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350" data-count-type="characters">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-characters-count-type-value">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-characters-count-type-value" name="example" rows="5" aria-describedby="with-characters-count-type-value-info">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-characters-count-type-value-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  id: "with-characters-count-type-value",
  name: "example",
  countType: "characters",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels."
}) }}

You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200" data-count-type="length">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-length-count-type">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-length-count-type" name="example" rows="5" aria-describedby="with-length-count-type-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-length-count-type-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  id: "with-length-count-type",
  name: "example",
  countType: "length",
  maxlength: 200
}) }}

You can enter up to 50 words
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="50" data-count-type="words">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-words-count-type">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-words-count-type" name="example" rows="5" aria-describedby="with-words-count-type-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-words-count-type-info">
    You can enter up to 50 words
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  id: "with-words-count-type",
  name: "example",
  countType: "words",
  maxlength: 50
}) }}

Character count with count type 'words' and error message

Open this example in a new tab: Character count with count type 'words' and error message

Error: Job description must be 40 words or less

You can enter up to 51 words
Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="51" data-count-type="words">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-words-count-type-error-message">
      Enter a job description
    </label>
  </h1>
  <p class="nhsuk-error-message" id="with-words-count-type-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Job description must be 40 words or less
  </p>
  <textarea class="nhsuk-textarea nhsuk-textarea--error nhsuk-js-character-count" id="with-words-count-type-error-message" name="example" rows="5" aria-describedby="with-words-count-type-error-message-info with-words-count-type-error-message-error">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-words-count-type-error-message-info">
    You can enter up to 51 words
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  errorMessage: {
    text: "Job description must be 40 words or less"
  },
  id: "with-words-count-type-error-message",
  name: "example",
  countType: "words",
  maxlength: 51,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format."
}) }}

You can enter up to 51 words
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="51" data-threshold="30" data-count-type="words">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-words-count-type-threshold">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-words-count-type-threshold" name="example" rows="5" aria-describedby="with-words-count-type-threshold-info">Type another word into this field after this message to see the threshold feature</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-words-count-type-threshold-info">
    You can enter up to 51 words
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  id: "with-words-count-type-threshold",
  name: "example",
  countType: "words",
  value:
    "Type another word into this field after this message to see the threshold feature",
  maxlength: 51,
  threshold: 30
}) }}

You can enter up to 51 words
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="51" data-count-type="words">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-words-count-type-value">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-words-count-type-value" name="example" rows="5" aria-describedby="with-words-count-type-value-info">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-words-count-type-value-info">
    You can enter up to 51 words
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  id: "with-words-count-type-value",
  name: "example",
  countType: "words",
  maxlength: 51,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels."
}) }}

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="custom-rows">
      Can you provide more detail?
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="custom-rows" name="example" rows="15" aria-describedby="custom-rows-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="custom-rows-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "l"
  },
  id: "custom-rows",
  name: "example",
  maxlength: 350,
  rows: 15
}) }}

Error: Job description must be 350 characters or less

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-error-message">
      Enter a job description
    </label>
  </h1>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Job description must be 350 characters or less
  </p>
  <textarea class="nhsuk-textarea nhsuk-textarea--error nhsuk-js-character-count" id="with-error-message" name="example" rows="5" aria-describedby="with-error-message-info with-error-message-error">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-error-message-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  errorMessage: {
    text: "Job description must be 350 characters or less"
  },
  id: "with-error-message",
  name: "example",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format."
}) }}

Do not include personal information like your name, date of birth or NHS number

Error: Job description must be 350 characters or less

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-error-message">
      Enter a job description
    </label>
  </h1>
  <div class="nhsuk-hint" id="with-error-message-hint">
    Do not include personal information like your name, date of birth or NHS number
  </div>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Job description must be 350 characters or less
  </p>
  <textarea class="nhsuk-textarea nhsuk-textarea--error nhsuk-js-character-count" id="with-error-message" name="example" rows="5" aria-describedby="with-error-message-info with-error-message-hint with-error-message-error">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-error-message-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  hint: {
    text: "Do not include personal information like your name, date of birth or NHS number"
  },
  errorMessage: {
    text: "Job description must be 350 characters or less"
  },
  id: "with-error-message",
  name: "example",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format."
}) }}

Do not include personal information like your name, date of birth or NHS number

Error: Job description must be 350 characters or less

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-error-message">
      Enter a job description
    </label>
  </h1>
  <div class="nhsuk-hint" id="with-error-message-hint">
    Do not include personal information like your name, date of birth or NHS number
  </div>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Job description must be 350 characters or less
  </p>
  <textarea class="nhsuk-textarea nhsuk-textarea--error nhsuk-js-character-count" id="with-error-message" name="example" rows="5" aria-describedby="with-error-message-info with-error-message-hint with-error-message-error">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-error-message-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  hint: "Do not include personal information like your name, date of birth or NHS number",
  errorMessage: "Job description must be 350 characters or less",
  id: "with-error-message",
  name: "example",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format."
}) }}

Character count with error message and hint, without heading

Open this example in a new tab: Character count with error message and hint, without heading

Do not include personal information like your name, date of birth or NHS number

Error: Job description must be 350 characters or less

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350">
  <label class="nhsuk-label" for="with-error-message">
    Enter a job description
  </label>
  <div class="nhsuk-hint" id="with-error-message-hint">
    Do not include personal information like your name, date of birth or NHS number
  </div>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Job description must be 350 characters or less
  </p>
  <textarea class="nhsuk-textarea nhsuk-textarea--error nhsuk-js-character-count" id="with-error-message" name="example" rows="5" aria-describedby="with-error-message-info with-error-message-hint with-error-message-error">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-error-message-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    text: "Enter a job description"
  },
  hint: {
    text: "Do not include personal information like your name, date of birth or NHS number"
  },
  errorMessage: {
    text: "Job description must be 350 characters or less"
  },
  id: "with-error-message",
  name: "example",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format."
}) }}

Error: Job description must be 350 characters or less

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350">
  <label class="nhsuk-label" for="with-error-message">
    Enter a job description
  </label>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Job description must be 350 characters or less
  </p>
  <textarea class="nhsuk-textarea nhsuk-textarea--error nhsuk-js-character-count" id="with-error-message" name="example" rows="5" aria-describedby="with-error-message-info with-error-message-error">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-error-message-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    text: "Enter a job description"
  },
  errorMessage: {
    text: "Job description must be 350 characters or less"
  },
  id: "with-error-message",
  name: "example",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format."
}) }}

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-error-only">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-textarea--error nhsuk-js-character-count" id="with-error-only" name="example" rows="5" aria-describedby="with-error-only-info">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-error-only-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  errorMessage: true,
  id: "with-error-only",
  name: "example",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels. They make sure appropriate content is shown to a user in the right place and in the best format."
}) }}

Do not include personal information like your name, date of birth or NHS number
You can enter up to 200 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-hint">
      Enter a job description
    </label>
  </h1>
  <div class="nhsuk-hint" id="with-hint-hint">
    Do not include personal information like your name, date of birth or NHS number
  </div>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-hint" name="example" rows="5" aria-describedby="with-hint-info with-hint-hint"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-hint-info">
    You can enter up to 200 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  hint: {
    text: "Do not include personal information like your name, date of birth or NHS number"
  },
  id: "with-hint",
  name: "example",
  maxlength: 200
}) }}
You can enter up to 150 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="150">
  <label class="nhsuk-label" for="without-heading">
    Tell us more about what happened
  </label>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="without-heading" name="example" rows="5" aria-describedby="without-heading-info"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="without-heading-info">
    You can enter up to 150 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: "Tell us more about what happened",
  id: "without-heading",
  name: "example",
  maxlength: 150
}) }}

You can enter up to 112 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="112" data-threshold="75">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-threshold">
      Can you provide more detail?
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-threshold" name="example" rows="5" aria-describedby="with-threshold-info">Type another letter into this field after this message to see the threshold feature</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-threshold-info">
    You can enter up to 112 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Can you provide more detail?",
    size: "l"
  },
  id: "with-threshold",
  name: "example",
  value:
    "Type another letter into this field after this message to see the threshold feature",
  maxlength: 112,
  threshold: 75
}) }}

Peidiwch Γ’ chynnwys gwybodaeth bersonol, fel eich enw, dyddiad geni na rhif y GIG
Gallwch ddefnyddio hyd at 200 nod
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="200" data-i18n.characters-under-limit.one="Mae gennych %{count} nod ar Γ΄l" data-i18n.characters-under-limit.two="Mae gennych %{count} nod ar Γ΄l" data-i18n.characters-under-limit.few="Mae gennych %{count} nod ar Γ΄l" data-i18n.characters-under-limit.many="Mae gennych %{count} nod ar Γ΄l" data-i18n.characters-under-limit.other="Mae gennych %{count} nod ar Γ΄l" data-i18n.characters-at-limit="Mae gennych 0 nod ar Γ΄l" data-i18n.characters-over-limit.one="Mae gennych %{count} nod yn ormod" data-i18n.characters-over-limit.two="Mae gennych %{count} nod yn ormod" data-i18n.characters-over-limit.few="Mae gennych %{count} nod yn ormod" data-i18n.characters-over-limit.many="Mae gennych %{count} nod yn ormod" data-i18n.characters-over-limit.other="Mae gennych chi %{count} nod yn ormod">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-translations">
      Allwch chi roi mwy o fanylion?
    </label>
  </h1>
  <div class="nhsuk-hint" id="with-translations-hint">
    Peidiwch Γ’ chynnwys gwybodaeth bersonol, fel eich enw, dyddiad geni na rhif y GIG
  </div>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-translations" name="example" rows="5" aria-describedby="with-translations-info with-translations-hint"></textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-translations-info">
    Gallwch ddefnyddio hyd at 200 nod
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Allwch chi roi mwy o fanylion?",
    size: "l"
  },
  hint: {
    text: "Peidiwch Γ’ chynnwys gwybodaeth bersonol, fel eich enw, dyddiad geni na rhif y GIG"
  },
  id: "with-translations",
  name: "example",
  maxlength: 200,
  textareaDescriptionText: "Gallwch ddefnyddio hyd at %{count} nod",
  charactersUnderLimitText: {
    one: "Mae gennych %{count} nod ar Γ΄l",
    two: "Mae gennych %{count} nod ar Γ΄l",
    few: "Mae gennych %{count} nod ar Γ΄l",
    many: "Mae gennych %{count} nod ar Γ΄l",
    other: "Mae gennych %{count} nod ar Γ΄l"
  },
  charactersAtLimitText: "Mae gennych 0 nod ar Γ΄l",
  charactersOverLimitText: {
    one: "Mae gennych %{count} nod yn ormod",
    two: "Mae gennych %{count} nod yn ormod",
    few: "Mae gennych %{count} nod yn ormod",
    many: "Mae gennych %{count} nod yn ormod",
    other: "Mae gennych chi %{count} nod yn ormod"
  }
}) }}

You can enter up to 350 characters
Code

Markup

<div class="nhsuk-form-group nhsuk-character-count" data-module="nhsuk-character-count" data-maxlength="350">
  <h1 class="nhsuk-label-wrapper">
    <label class="nhsuk-label nhsuk-label--l" for="with-value">
      Enter a job description
    </label>
  </h1>
  <textarea class="nhsuk-textarea nhsuk-js-character-count" id="with-value" name="example" rows="5" aria-describedby="with-value-info">πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels.</textarea>
  <div class="nhsuk-hint nhsuk-character-count__message" id="with-value-info">
    You can enter up to 350 characters
  </div>
</div>

Macro

{% from "character-count/macro.njk" import characterCount -%}

{{ characterCount({
  label: {
    heading: "Enter a job description",
    size: "l"
  },
  id: "with-value",
  name: "example",
  maxlength: 350,
  value:
    "πŸ‘©πŸ»β€πŸš€ A content designer works on the end-to-end journey of a service to help users complete their goal and government deliver a policy intent. Their work may involve the creation of, or change to, a transaction, product or single piece of content that stretches across digital and offline channels."
}) }}