Autosuggest

An enhanced text input that provides real-time search suggestions and matching results as users type.

Summary

Use the autosuggest component to display selectable options based on typed input. As users type, it filters and displays matching suggestions directly below the input field, reducing typing effort and preventing spelling errors.

Use autosuggest for known datasets, such as locations, courses or medical conditions. It helps users select standardised values quickly and accurately.

<div
  class="tel-auto-suggestion tel-auto-suggestion--page"
  data-module="tel-auto-suggestion"
  data-display-length="12"
>
  <div class="nhsuk-form-group tel-auto-suggestion__search-wrapper">
    <input
      class="nhsuk-input"
      id="auto-suggest-search-page-search-example"
      name="search-query"
      type="text"
      placeholder="Search the learning hub"
      autocomplete="off"
      aria-autocomplete="list"
    />
  </div>

  <div class="tel-auto-suggestion__menu" role="region" aria-live="polite">
    <div class="tel-auto-suggestion__list">
      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiovascular" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >vascular
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiology" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >logy
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiomyopathy" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >myopathy
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiologist" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >logist
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiothoracic" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >thoracic
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=270-reducing-cardio-vascular-risk-in-mh"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            270 Reducing
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >
            Vascular Risk in MH
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=cardiovascular-diseases-toolkit"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >vascular diseases toolkit
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=imt-teaching-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            IMT Teaching -
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy (06/05/26)
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=genomics-in-medical-specialties-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            Genomics in Medical Specialties:
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=genomics-in-medical-specialties-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            Genomics in Medical Specialties:
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>
    </div>
  </div>
</div>

Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

{% from 'tel/components/auto-suggestion/macro.njk' import telAutoSuggestion %}

{{ telAutoSuggestion({
  id: "page-search-example",
  input_name: "search-query",
  placeholder: "Search the learning hub",
  type: "page",
  search_text: "cardio",  

  menu_items: [
      {
        text: "cardiovascular",
        href: "/search?q=cardiovascular",
        icon: "search"
      },
      {
        text: "cardiology",
        href: "/search?q=cardiology",
        icon: "search"
      },
      {
        text: "cardiomyopathy",
        href: "/search?q=cardiomyopathy",
        icon: "search"
      },
      {
        text: "cardiologist",
        href: "/search?q=cardiologist",
        icon: "search"
      },
      {
        text: "cardiothoracic",
        href: "/search?q=cardiothoracic",
        icon: "search"
      },
      {
        text: "270 Reducing Cardio Vascular Risk in MH",
        href: "/search?q=270-reducing-cardio-vascular-risk-in-mh",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Cardiovascular diseases toolkit",
        href: "/search?q=cardiovascular-diseases-toolkit",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "IMT Teaching - Cardiology (06/05/26)",
        href: "/search?q=imt-teaching-cardiology",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Genomics in Medical Specialties: Cardiology",
        href: "/search?q=genomics-in-medical-specialties-cardiology",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Genomics in Medical Specialties: Cardiology",
        href: "/search?q=genomics-in-medical-specialties-cardiology",
        type: "Learning resource",
        category: "resources"
      }
    ]
  }) }}

This is the simplest variation of the autosuggest page pattern where suggestions are offered directly as the user types.

When to use

Use autosuggest when users need to find a specific item from a large or complex list.

It is useful when:

  • the list of available choices is too long for a standard select element or radio list
  • users might not know the exact spelling or precise name of what they are looking for
  • standardising the entered data is important for backend processing
  • speeding up input on mobile devices is beneficial

When not to use

Do not use autosuggest as a replacement for simple input controls when choices are limited.

It should not be used:

  • when there are fewer than 5 to 10 options (use radio buttons or a select dropdown instead)
  • for free-text inputs where suggestions could restrict or confuse the user
  • when users are likely to enter unique or unpredictable text that won't match a fixed list
  • during high-speed, minimal-interaction entry where predictive popups distract from completion

How it works

The autosuggest component overlays dynamic matching results directly beneath the text input field as the user types.

The component supports:

  • matching query strings against display titles, synonyms, or codes
  • keyboard navigation (using Up or Down arrow keys and Enter to select)
  • status text announcement for screen readers (for example, "5 results available")
  • an optional conditional reveal panel for user input when an item is not found

On smaller screens, the suggestion list scales to fit the viewport width to maintain touch target sizing.

Configuration

Common properties

  • id (string, required) : Unique HTML identifier for the input element
  • input_name (string, required) : Name attribute applied to the input field
  • type (string, required) : "page", "radio" or "checkbox"
  • placeholder (string) : Input field placeholder text
  • search_text (string) : Load component with pre-determined search string
  • menu_items (array) : Array of suggestion items rendered by the component

Suggestion menu item properties (menu_items)

  • text (string, required) : Item text
  • href (string) : Destination URL when the item is selected (used in page patterns)
  • type (string) : Item subtext displayed below main text
  • value (string) : Radio button or checkbox submitted form value
  • category (string) : Category identifier associated with quick filters
  • hint (string) : Secondary text below radio or checkbox items
  • icon (string) : Set to "search" for magnifying glass indicating search completion rather than link

Page search properties

  • show_search_button (boolean) : Determines whether search button is displayed next to the input field; defaults to false
  • show_filters (boolean) : Toggles quick-filters integration; defaults to false
  • filters (object) : Configuration object for quick-filters tags:
    • heading (string) : Heading text preceding the filter buttons
    • showAll (boolean) : Enables an "All" filter toggle option
    • allLabel (string) : Display text for the "All" filter option (for example "All")
    • activeTags (array) : Array of currently active filter tag value strings (for example ["all"])
    • tags (array) : List of filter tag objects:
      • label (string) : Visible display label for the filter tag
      • value (string) : Value used to filter menu items

Radio button and checkbox properties

  • show_other (boolean) : Enables a fallback option for users to manually enter an unlisted choice
  • other_text (string) : Hint text displayed between main list and other list item
  • other_buttontext (string) : Radio button display text; defaults to "Other"
  • other_label (string) : Label text for the other text input
  • selected_items (array) : Array of pre-selected values when rendering radio or checkbox options

Pagination properties

  • pagination (boolean) : Determines whether pagination controls are rendered below the results; defaults to false
  • pagination_previous_url (string) : Target URL for the "Previous" page link
  • pagination_previous_page (string) : Accessible label or link text for the "Previous" page control
  • pagination_next_url (string) : Target URL for the "Next" page link
  • pagination_next_page (string) : Accessible label or link text for the "Next" page control
  • pagination_items (array) : Array of page number objects and truncators:
    • number (number) : Page number value
    • href (string) : Target URL for the specific page link
    • current (boolean) : Set to true to highlight the current active page
    • ellipsis (boolean) : Set to true to render a pagination ellipsis (...) visual separator

Examples, variants and states including code and design assets

Below are the framework-specific macros and design file paths for the respective variations.

Default page pattern

<div
  class="tel-auto-suggestion tel-auto-suggestion--page"
  data-module="tel-auto-suggestion"
  data-display-length="12"
>
  <div class="nhsuk-form-group tel-auto-suggestion__search-wrapper">
    <input
      class="nhsuk-input"
      id="auto-suggest-search-page-search-example"
      name="search-query"
      type="text"
      placeholder="Search the learning hub"
      autocomplete="off"
      aria-autocomplete="list"
    />
  </div>

  <div class="tel-auto-suggestion__menu" role="region" aria-live="polite">
    <div class="tel-auto-suggestion__list">
      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiovascular" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >vascular
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiology" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >logy
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiomyopathy" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >myopathy
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiologist" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >logist
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiothoracic" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >thoracic
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=270-reducing-cardio-vascular-risk-in-mh"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            270 Reducing
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >
            Vascular Risk in MH
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=cardiovascular-diseases-toolkit"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >vascular diseases toolkit
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=imt-teaching-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            IMT Teaching -
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy (06/05/26)
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=genomics-in-medical-specialties-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            Genomics in Medical Specialties:
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=genomics-in-medical-specialties-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            Genomics in Medical Specialties:
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>
    </div>
  </div>
</div>

Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

{% from 'tel/components/auto-suggestion/macro.njk' import telAutoSuggestion %}

{{ telAutoSuggestion({
  id: "page-search-example",
  input_name: "search-query",
  placeholder: "Search the learning hub",
  type: "page",
  search_text: "cardio",  

  menu_items: [
      {
        text: "cardiovascular",
        href: "/search?q=cardiovascular",
        icon: "search"
      },
      {
        text: "cardiology",
        href: "/search?q=cardiology",
        icon: "search"
      },
      {
        text: "cardiomyopathy",
        href: "/search?q=cardiomyopathy",
        icon: "search"
      },
      {
        text: "cardiologist",
        href: "/search?q=cardiologist",
        icon: "search"
      },
      {
        text: "cardiothoracic",
        href: "/search?q=cardiothoracic",
        icon: "search"
      },
      {
        text: "270 Reducing Cardio Vascular Risk in MH",
        href: "/search?q=270-reducing-cardio-vascular-risk-in-mh",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Cardiovascular diseases toolkit",
        href: "/search?q=cardiovascular-diseases-toolkit",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "IMT Teaching - Cardiology (06/05/26)",
        href: "/search?q=imt-teaching-cardiology",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Genomics in Medical Specialties: Cardiology",
        href: "/search?q=genomics-in-medical-specialties-cardiology",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Genomics in Medical Specialties: Cardiology",
        href: "/search?q=genomics-in-medical-specialties-cardiology",
        type: "Learning resource",
        category: "resources"
      }
    ]
  }) }}

Use this variation for standard page layouts where users select a suggestion directly from the input without needing an explicit search submit button.

Page pattern with search button

Use this variation when the autosuggest input sits within an explicit search form. The search button allows users to submit a query manually if they choose not to select a suggested item or want to view full search results on a dedicated page.

Page pattern with search button and filters

<div
  class="tel-auto-suggestion tel-auto-suggestion--page"
  data-module="tel-auto-suggestion"
  data-display-length="12"
>
  <div
    class="nhsuk-form-group tel-auto-suggestion__search-wrapper tel-auto-suggestion__search-wrapper--has-button"
  >
    <input
      class="nhsuk-input"
      id="auto-suggest-search-page-search-example"
      name="search-query"
      type="text"
      placeholder="Search the learning hub"
      autocomplete="off"
      aria-autocomplete="list"
    />

    <button type="button" class="nhsuk-button tel-auto-suggestion__search-btn">
      <span class="nhsuk-u-visually-hidden">Search</span>
      <svg
        width="20"
        height="20"
        viewBox="0 0 20 20"
        fill="none"
        xmlns="http://www.w3.org/2000/svg"
        aria-hidden="true"
        class="tel-auto-suggestion__svg-icon"
      >
        <path
          fill-rule="evenodd"
          clip-rule="evenodd"
          d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
          fill="currentColor"
        />
      </svg>
    </button>
  </div>

  <div class="tel-auto-suggestion__filters-container">
    <nav
      class="tel-quick-filters"
      data-component="tel-quick-filters"
      data-module="tel-quick-filters"
    >
      <ul class="tel-quick-filters__list" role="list">
        <span class="tel-quick-filters__list-heading">Show</span>

        <li class="tel-quick-filters__list-item">
          <a
            href="#"
            class="tel-quick-filters__button tel-quick-filters__button--active"
            role="button"
            aria-pressed="true"
            data-filter-value="all"
          >
            <span>All</span>
          </a>
        </li>

        <li class="tel-quick-filters__list-item">
          <a
            href="#"
            class="tel-quick-filters__button"
            role="button"
            aria-pressed="false"
            data-filter-value="catalogues"
          >
            <span>Catalogues</span>
          </a>
        </li>

        <li class="tel-quick-filters__list-item">
          <a
            href="#"
            class="tel-quick-filters__button"
            role="button"
            aria-pressed="false"
            data-filter-value="courses"
          >
            <span>Courses</span>
          </a>
        </li>

        <li class="tel-quick-filters__list-item">
          <a
            href="#"
            class="tel-quick-filters__button"
            role="button"
            aria-pressed="false"
            data-filter-value="resources"
          >
            <span>Resources</span>
          </a>
        </li>
      </ul>
    </nav>
  </div>

  <div class="tel-auto-suggestion__menu" role="region" aria-live="polite">
    <div class="tel-auto-suggestion__list">
      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiovascular" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >vascular
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiology" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >logy
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiomyopathy" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >myopathy
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiologist" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >logist
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="">
        <a href="/search?q=cardiothoracic" class="tel-auto-suggestion__link">
          <span class="tel-auto-suggestion__icon-container" aria-hidden="true">
            <svg
              width="16"
              height="16"
              viewBox="0 0 16 16"
              fill="none"
              xmlns="http://www.w3.org/2000/svg"
              aria-hidden="true"
              class="tel-auto-suggestion__svg-icon"
            >
              <path
                fill-rule="evenodd"
                clip-rule="evenodd"
                d="M11.8558 10.5296L15.7218 14.3861C15.8998 14.5627 16 14.8031 16 15.0539C16 15.3047 15.8998 15.5451 15.7218 15.7218C15.5451 15.8998 15.3047 16 15.0539 16C14.8031 16 14.5627 15.8998 14.3861 15.7218L10.5296 11.8558C7.76424 13.9254 3.86973 13.5064 1.60799 10.8959C-0.653748 8.28537 -0.513826 4.37088 1.92852 1.92852C4.37088 -0.513826 8.28537 -0.653748 10.8959 1.60799C13.5064 3.86973 13.9254 7.76424 11.8558 10.5296ZM6.58834 1.88537C3.9909 1.88537 1.88525 3.99101 1.88525 6.58846C1.88525 9.1859 3.9909 11.2915 6.58834 11.2915C9.18578 11.2915 11.2914 9.1859 11.2914 6.58846C11.2914 3.99101 9.18578 1.88537 6.58834 1.88537Z"
                fill="currentColor"
              />
            </svg>
          </span>

          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >cardio</span
            >thoracic
          </span>
        </a>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=270-reducing-cardio-vascular-risk-in-mh"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            270 Reducing
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >
            Vascular Risk in MH
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=cardiovascular-diseases-toolkit"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >vascular diseases toolkit
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=imt-teaching-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            IMT Teaching -
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy (06/05/26)
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=genomics-in-medical-specialties-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            Genomics in Medical Specialties:
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>

      <div class="tel-auto-suggestion__item" data-filter-categories="resources">
        <a
          href="/search?q=genomics-in-medical-specialties-cardiology"
          class="tel-auto-suggestion__link"
        >
          <span class="tel-auto-suggestion__link-text">
            Genomics in Medical Specialties:
            <span class="tel-auto-suggestion__search-text-highlight"
              >Cardio</span
            >logy
          </span>
        </a>

        <div class="tel-auto-suggestion__subtext">
          Type:
          <span class="tel-auto-suggestion__subtext-value"
            >Learning resource</span
          >
        </div>
      </div>
    </div>
  </div>
</div>

Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

{% from 'tel/components/auto-suggestion/macro.njk' import telAutoSuggestion %}

{{ telAutoSuggestion({
  id: "page-search-example",
  input_name: "search-query",
  placeholder: "Search the learning hub",
  type: "page",
  search_text: "cardio",
  show_other: false,
  show_search_button: true,
  show_filters: true,
  
  filters: {
    heading: "Show",
    showll: true,
    allLabel: "All",
    activeTags: ["all"],
    tags: [
      { label: "Catalogues", value: "catalogues" },
      { label: "Courses", value: "courses" },
      { label: "Resources", value: "resources" }
    ]
  },

  menu_items: [
      {
        text: "cardiovascular",
        href: "/search?q=cardiovascular",
        icon: "search"
      },
      {
        text: "cardiology",
        href: "/search?q=cardiology",
        icon: "search"
      },
      {
        text: "cardiomyopathy",
        href: "/search?q=cardiomyopathy",
        icon: "search"
      },
      {
        text: "cardiologist",
        href: "/search?q=cardiologist",
        icon: "search"
      },
      {
        text: "cardiothoracic",
        href: "/search?q=cardiothoracic",
        icon: "search"
      },
      {
        text: "270 Reducing Cardio Vascular Risk in MH",
        href: "/search?q=270-reducing-cardio-vascular-risk-in-mh",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Cardiovascular diseases toolkit",
        href: "/search?q=cardiovascular-diseases-toolkit",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "IMT Teaching - Cardiology (06/05/26)",
        href: "/search?q=imt-teaching-cardiology",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Genomics in Medical Specialties: Cardiology",
        href: "/search?q=genomics-in-medical-specialties-cardiology",
        type: "Learning resource",
        category: "resources"
      },
      {
        text: "Genomics in Medical Specialties: Cardiology",
        href: "/search?q=genomics-in-medical-specialties-cardiology",
        type: "Learning resource",
        category: "resources"
      }
    ]
  }) }}

Use this variation for complex search interfaces where users need to narrow down suggestions using specific filters alongside the autosuggest input field.

Radio button patterns

Radio button autosuggest

<div
  class="tel-auto-suggestion tel-auto-suggestion--radio"
  data-module="tel-auto-suggestion"
  data-display-length="12"
>
  <div class="nhsuk-form-group tel-auto-suggestion__search-wrapper">
    <input
      class="nhsuk-input"
      id="auto-suggest-search-radio-button-example"
      name="search-query"
      type="text"
      placeholder="Search roles"
      autocomplete="off"
      aria-autocomplete="list"
    />
  </div>

  <div class="tel-auto-suggestion__menu" role="region" aria-live="polite">
    <fieldset class="nhsuk-fieldset">
      <div class="nhsuk-radios">
        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-1"
            name="autosuggest-choice"
            type="radio"
            value="midwife-tutor"
            aria-describedby="item-radio-button-example-1-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-1"
          >
            Midwife - Tutor
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-1-hint"
          >
            Students
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-2"
            name="autosuggest-choice"
            type="radio"
            value="nursing-associate"
            aria-describedby="item-radio-button-example-2-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-2"
          >
            Nursing Associate
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-2-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-3"
            name="autosuggest-choice"
            type="radio"
            value="nurse"
            aria-describedby="item-radio-button-example-3-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-3"
          >
            Nurse
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-3-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-4"
            name="autosuggest-choice"
            type="radio"
            value="health-visitor"
            aria-describedby="item-radio-button-example-4-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-4"
          >
            Health Visitor
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-4-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>
      </div>
    </fieldset>
  </div>
</div>

Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

{% from 'tel/components/auto-suggestion/macro.njk' import telAutoSuggestion %}

{{ telAutoSuggestion({
  id: "radio-button-example",
  input_name: "search-query",
  placeholder: "Search roles",
  type: "Radio",
    
  menu_items: [
    {
      text: "Midwife - Tutor",
      value: "midwife-tutor",
      type: "Radio",
      hint: "Students"
    },
    {
      text: "Nursing Associate",
      value: "nursing-associate",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    },
    {
      text: "Nurse",
      value: "nurse",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    },
    {
      text: "Health Visitor",
      value: "health-visitor",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    }
  ],

  selected_items: [],
  filters: []
}) }}

Use this variation to implement the autosuggest pattern within a radio button selection flow, allowing users to filter down a list of mutually exclusive choices as radio options.

Radio button with "other" option

<div
  class="tel-auto-suggestion tel-auto-suggestion--radio"
  data-module="tel-auto-suggestion"
  data-display-length="12"
>
  <div class="nhsuk-form-group tel-auto-suggestion__search-wrapper">
    <input
      class="nhsuk-input"
      id="auto-suggest-search-radio-button-example"
      name="search-query"
      type="text"
      placeholder="Search roles"
      autocomplete="off"
      aria-autocomplete="list"
    />
  </div>

  <div class="tel-auto-suggestion__menu" role="region" aria-live="polite">
    <fieldset class="nhsuk-fieldset">
      <div class="nhsuk-radios">
        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-1"
            name="autosuggest-choice"
            type="radio"
            value="midwife-tutor"
            aria-describedby="item-radio-button-example-1-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-1"
          >
            Midwife - Tutor
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-1-hint"
          >
            Students
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-2"
            name="autosuggest-choice"
            type="radio"
            value="nursing-associate"
            aria-describedby="item-radio-button-example-2-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-2"
          >
            Nursing Associate
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-2-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-3"
            name="autosuggest-choice"
            type="radio"
            value="nurse"
            aria-describedby="item-radio-button-example-3-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-3"
          >
            Nurse
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-3-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-4"
            name="autosuggest-choice"
            type="radio"
            value="health-visitor"
            aria-describedby="item-radio-button-example-4-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-4"
          >
            Health Visitor
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-4-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>
      </div>
    </fieldset>
  </div>

  <div class="tel-auto-suggestion__escape-wrapper">
    <p class="nhsuk-body-s">
      If you cant find your role select other and enter your role manually
    </p>

    <div class="nhsuk-radios">
      <div class="nhsuk-radios__item">
        <input
          class="nhsuk-radios__input"
          id="other-choice-escape-radio-button-example"
          name="autosuggest-choice"
          type="radio"
          value="other"
          data-aria-controls="conditional-other-panel-radio-button-example"
        />

        <label
          class="nhsuk-label nhsuk-radios__label"
          for="other-choice-escape-radio-button-example"
        >
          Other
        </label>
      </div>

      <div
        class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden"
        id="conditional-other-panel-radio-button-example"
      >
        <div class="nhsuk-form-group">
          <label
            class="nhsuk-label"
            for="other-role-manual-input-radio-button-example"
          >
            Your role
          </label>
          <input
            class="nhsuk-input nhsuk-u-width-two-thirds"
            id="other-role-manual-input-radio-button-example"
            name="other-role-manual"
            type="text"
          />
        </div>
      </div>
    </div>
  </div>
</div>

Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

{% from 'tel/components/auto-suggestion/macro.njk' import telAutoSuggestion %}

{{ telAutoSuggestion({
  id: "radio-button-example",
  input_name: "search-query",
  placeholder: "Search roles",
  type: "Radio",

  show_other: true,
  other_text: "If you cant find your role select other and enter your role manually",
  other_buttontext: "Other",
  other_label: "Your role",
  
  menu_items: [
    {
      text: "Midwife - Tutor",
      value: "midwife-tutor",
      type: "Radio",
      hint: "Students"
    },
    {
      text: "Nursing Associate",
      value: "nursing-associate",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    },
    {
      text: "Nurse",
      value: "nurse",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    },
    {
      text: "Health Visitor",
      value: "health-visitor",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    }
  ],

  selected_items: [],
  filters: []
}) }}

Use this variation when using radio buttons with autosuggest while providing a fallback option for users to enter their own custom response if their choice is not listed in the suggestions.

Radio button with pagination

<div
  class="tel-auto-suggestion tel-auto-suggestion--radio"
  data-module="tel-auto-suggestion"
  data-display-length="12"
  data-pagination="true"
  data-current-page="1"
  data-total-pages="1"
>
  <div class="nhsuk-form-group tel-auto-suggestion__search-wrapper">
    <input
      class="nhsuk-input"
      id="auto-suggest-search-radio-button-example"
      name="search-query"
      type="text"
      placeholder="Search roles"
      autocomplete="off"
      aria-autocomplete="list"
    />
  </div>

  <div class="tel-auto-suggestion__menu" role="region" aria-live="polite">
    <fieldset class="nhsuk-fieldset">
      <div class="nhsuk-radios">
        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-1"
            name="autosuggest-choice"
            type="radio"
            value="midwife-tutor"
            aria-describedby="item-radio-button-example-1-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-1"
          >
            Midwife - Tutor
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-1-hint"
          >
            Students
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-2"
            name="autosuggest-choice"
            type="radio"
            value="nursing-associate"
            aria-describedby="item-radio-button-example-2-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-2"
          >
            Nursing Associate
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-2-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-3"
            name="autosuggest-choice"
            type="radio"
            value="nurse"
            aria-describedby="item-radio-button-example-3-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-3"
          >
            Nurse
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-3-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-4"
            name="autosuggest-choice"
            type="radio"
            value="health-visitor"
            aria-describedby="item-radio-button-example-4-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-4"
          >
            Health Visitor
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-4-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>
      </div>
    </fieldset>
  </div>

  <div class="tel-auto-suggestion__pagination">
    <nav
      class="nhsuk-pagination nhsuk-pagination--numbered"
      role="navigation"
      aria-label="Pagination"
    >
      <a href="/example?page=22" class="nhsuk-pagination__previous" rel="prev">
        <svg
          class="nhsuk-icon nhsuk-icon--arrow-left"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          width="16"
          height="16"
          focusable="false"
          aria-hidden="true"
        >
          <path
            d="M10.7 6.3c.4.4.4 1 0 1.4L7.4 11H19a1 1 0 0 1 0 2H7.4l3.3 3.3c.4.4.4 1 0 1.4a1 1 0 0 1-1.4 0l-5-5A1 1 0 0 1 4 12c0-.3.1-.5.3-.7l5-5a1 1 0 0 1 1.4 0Z"
          />
        </svg>
        <span class="nhsuk-pagination__title">
          Previous<span class="nhsuk-u-visually-hidden"> page</span>
        </span>
      </a>

      <ul class="nhsuk-pagination__list">
        <li class="nhsuk-pagination__item">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=1"
            aria-label="Page 1"
          >
            1
          </a>
        </li>

        <li class="nhsuk-pagination__item nhsuk-pagination__item--ellipsis">
          &ctdot;
        </li>

        <li class="nhsuk-pagination__item">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=22"
            aria-label="Page 22"
          >
            22
          </a>
        </li>

        <li class="nhsuk-pagination__item nhsuk-pagination__item--current">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=23"
            aria-label="Page 23"
            aria-current="page"
          >
            23
          </a>
        </li>

        <li class="nhsuk-pagination__item">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=24"
            aria-label="Page 24"
          >
            24
          </a>
        </li>

        <li class="nhsuk-pagination__item nhsuk-pagination__item--ellipsis">
          &ctdot;
        </li>

        <li class="nhsuk-pagination__item">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=42"
            aria-label="Page 42"
          >
            42
          </a>
        </li>
      </ul>

      <a href="/example?page=24" class="nhsuk-pagination__next" rel="next">
        <span class="nhsuk-pagination__title">
          Next<span class="nhsuk-u-visually-hidden"> page</span>
        </span>
        <svg
          class="nhsuk-icon nhsuk-icon--arrow-right"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          width="16"
          height="16"
          focusable="false"
          aria-hidden="true"
        >
          <path
            d="m14.7 6.3 5 5c.2.2.3.4.3.7 0 .3-.1.5-.3.7l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3H5a1 1 0 0 1 0-2h11.6l-3.3-3.3a1 1 0 1 1 1.4-1.4Z"
          />
        </svg>
      </a>
    </nav>
  </div>
</div>

Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

{% from 'tel/components/auto-suggestion/macro.njk' import telAutoSuggestion %}

{{ telAutoSuggestion({
  id: "radio-button-example",
  input_name: "search-query",
  placeholder: "Search roles",
  type: "Radio",
  
  pagination: true,
  pagination_previous_url: "/example?page=22",
  pagination_previous_page: "Previous page",
  pagination_next_url: "/example?page=24",
  pagination_next_page: "Next page",
  
  pagination_items: [
    {
      number: 1,
      href: "/example?page=1"
    },
    {
      ellipsis: true
    },
    {
      number: 22,
      href: "/example?page=22"
    },
    {
      number: 23,
      href: "/example?page=23",
      current: true
    },
    {
      number: 24,
      href: "/example?page=24"
    },
    {
      ellipsis: true
    },
    {
      number: 42,
      href: "/example?page=42"
    }
  ],
  
  menu_items: [
    {
      text: "Midwife - Tutor",
      value: "midwife-tutor",
      type: "Radio",
      hint: "Students"
    },
    {
      text: "Nursing Associate",
      value: "nursing-associate",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    },
    {
      text: "Nurse",
      value: "nurse",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    },
    {
      text: "Health Visitor",
      value: "health-visitor",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    }
  ],

  selected_items: [],
  filters: []
}) }}

Use this variation when autosuggest radio button choices span multiple pages, giving users controls to page through results when a search returns a large number of options.

Radio button with pagination and "other" option

<div
  class="tel-auto-suggestion tel-auto-suggestion--radio"
  data-module="tel-auto-suggestion"
  data-display-length="12"
  data-pagination="true"
  data-current-page="1"
  data-total-pages="1"
>
  <div class="nhsuk-form-group tel-auto-suggestion__search-wrapper">
    <input
      class="nhsuk-input"
      id="auto-suggest-search-radio-button-example"
      name="search-query"
      type="text"
      placeholder="Search roles"
      autocomplete="off"
      aria-autocomplete="list"
    />
  </div>

  <div class="tel-auto-suggestion__menu" role="region" aria-live="polite">
    <fieldset class="nhsuk-fieldset">
      <div class="nhsuk-radios">
        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-1"
            name="autosuggest-choice"
            type="radio"
            value="midwife-tutor"
            aria-describedby="item-radio-button-example-1-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-1"
          >
            Midwife - Tutor
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-1-hint"
          >
            Students
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-2"
            name="autosuggest-choice"
            type="radio"
            value="nursing-associate"
            aria-describedby="item-radio-button-example-2-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-2"
          >
            Nursing Associate
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-2-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-3"
            name="autosuggest-choice"
            type="radio"
            value="nurse"
            aria-describedby="item-radio-button-example-3-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-3"
          >
            Nurse
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-3-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>

        <div
          class="tel-auto-suggestion__item nhsuk-radios__item"
          data-filter-categories=""
        >
          <input
            class="nhsuk-radios__input"
            id="item-radio-button-example-4"
            name="autosuggest-choice"
            type="radio"
            value="health-visitor"
            aria-describedby="item-radio-button-example-4-hint"
          />
          <label
            class="nhsuk-label nhsuk-radios__label"
            for="item-radio-button-example-4"
          >
            Health Visitor
          </label>

          <div
            class="nhsuk-hint nhsuk-radios__hint"
            id="item-radio-button-example-4-hint"
          >
            Nursing and Midwifery Registered
          </div>
        </div>
      </div>
    </fieldset>
  </div>

  <div class="tel-auto-suggestion__pagination">
    <nav
      class="nhsuk-pagination nhsuk-pagination--numbered"
      role="navigation"
      aria-label="Pagination"
    >
      <a href="/example?page=22" class="nhsuk-pagination__previous" rel="prev">
        <svg
          class="nhsuk-icon nhsuk-icon--arrow-left"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          width="16"
          height="16"
          focusable="false"
          aria-hidden="true"
        >
          <path
            d="M10.7 6.3c.4.4.4 1 0 1.4L7.4 11H19a1 1 0 0 1 0 2H7.4l3.3 3.3c.4.4.4 1 0 1.4a1 1 0 0 1-1.4 0l-5-5A1 1 0 0 1 4 12c0-.3.1-.5.3-.7l5-5a1 1 0 0 1 1.4 0Z"
          />
        </svg>
        <span class="nhsuk-pagination__title">
          Previous<span class="nhsuk-u-visually-hidden"> page</span>
        </span>
      </a>

      <ul class="nhsuk-pagination__list">
        <li class="nhsuk-pagination__item">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=1"
            aria-label="Page 1"
          >
            1
          </a>
        </li>

        <li class="nhsuk-pagination__item nhsuk-pagination__item--ellipsis">
          &ctdot;
        </li>

        <li class="nhsuk-pagination__item">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=22"
            aria-label="Page 22"
          >
            22
          </a>
        </li>

        <li class="nhsuk-pagination__item nhsuk-pagination__item--current">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=23"
            aria-label="Page 23"
            aria-current="page"
          >
            23
          </a>
        </li>

        <li class="nhsuk-pagination__item">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=24"
            aria-label="Page 24"
          >
            24
          </a>
        </li>

        <li class="nhsuk-pagination__item nhsuk-pagination__item--ellipsis">
          &ctdot;
        </li>

        <li class="nhsuk-pagination__item">
          <a
            class="nhsuk-pagination__link"
            href="/example?page=42"
            aria-label="Page 42"
          >
            42
          </a>
        </li>
      </ul>

      <a href="/example?page=24" class="nhsuk-pagination__next" rel="next">
        <span class="nhsuk-pagination__title">
          Next<span class="nhsuk-u-visually-hidden"> page</span>
        </span>
        <svg
          class="nhsuk-icon nhsuk-icon--arrow-right"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          width="16"
          height="16"
          focusable="false"
          aria-hidden="true"
        >
          <path
            d="m14.7 6.3 5 5c.2.2.3.4.3.7 0 .3-.1.5-.3.7l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3H5a1 1 0 0 1 0-2h11.6l-3.3-3.3a1 1 0 1 1 1.4-1.4Z"
          />
        </svg>
      </a>
    </nav>
  </div>

  <div class="tel-auto-suggestion__escape-wrapper">
    <p class="nhsuk-body-s">
      If you cant find your role select other and enter your role manually
    </p>

    <div class="nhsuk-radios">
      <div class="nhsuk-radios__item">
        <input
          class="nhsuk-radios__input"
          id="other-choice-escape-radio-button-example"
          name="autosuggest-choice"
          type="radio"
          value="other"
          data-aria-controls="conditional-other-panel-radio-button-example"
        />

        <label
          class="nhsuk-label nhsuk-radios__label"
          for="other-choice-escape-radio-button-example"
        >
          Other
        </label>
      </div>

      <div
        class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden"
        id="conditional-other-panel-radio-button-example"
      >
        <div class="nhsuk-form-group">
          <label
            class="nhsuk-label"
            for="other-role-manual-input-radio-button-example"
          >
            Your role
          </label>
          <input
            class="nhsuk-input nhsuk-u-width-two-thirds"
            id="other-role-manual-input-radio-button-example"
            name="other-role-manual"
            type="text"
          />
        </div>
      </div>
    </div>
  </div>
</div>

Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

{% from 'tel/components/auto-suggestion/macro.njk' import telAutoSuggestion %}

{{ telAutoSuggestion({
  id: "radio-button-example",
  input_name: "search-query",
  placeholder: "Search roles",
  type: "Radio",

  show_other: true,
  other_text: "If you cant find your role select other and enter your role manually",
  other_buttontext: "Other",
  other_label: "Your role",
  
  pagination: true,
  pagination_previous_url: "/example?page=22",
  pagination_previous_page: "Previous page",
  pagination_next_url: "/example?page=24",
  pagination_next_page: "Next page",
  
  pagination_items: [
    {
      number: 1,
      href: "/example?page=1"
    },
    {
      ellipsis: true
    },
    {
      number: 22,
      href: "/example?page=22"
    },
    {
      number: 23,
      href: "/example?page=23",
      current: true
    },
    {
      number: 24,
      href: "/example?page=24"
    },
    {
      ellipsis: true
    },
    {
      number: 42,
      href: "/example?page=42"
    }
  ],
  
  menu_items: [
    {
      text: "Midwife - Tutor",
      value: "midwife-tutor",
      type: "Radio",
      hint: "Students"
    },
    {
      text: "Nursing Associate",
      value: "nursing-associate",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    },
    {
      text: "Nurse",
      value: "nurse",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    },
    {
      text: "Health Visitor",
      value: "health-visitor",
      type: "Radio",
      hint: "Nursing and Midwifery Registered"
    }
  ],

  selected_items: [],
  filters: []
}) }}

Use this variation to combine paginated radio button results with an option for users to manually enter their own response if the paginated options do not cover their selection.

Content guidance

Input labels and instructions should be clear and concise.

Use labels that:

  • clearly state what the user is searching for (for example, "Search for your GP surgery")
  • use hint text to explain how suggestions work if necessary (for example, "Type at least 3 letters to search")
  • keep option text concise and easy to scan
  • ensure synonym matches are intuitive and accurate

Avoid using technical terms or internal codes in user-facing suggestion results unless users actively search with them.