Skip to main content

This is a draft (version 0.5.0). The National Information Technology Agency (NITA) plans to make GGDS official guidance for government websites after independent accessibility testing. What this means

Ghana Government Design System Design system for Government of Ghana websites – home Search

Pattern

Search and show results

A search box that keeps the search, a count, results people can scan, and help when nothing is found.

When to use

  • For your website's search page, and for any long list people search: licensed providers, laws, tenders, news.

How it works

  1. The search box at the top, still holding what people searched for, so they can change it.
  2. A count: "24 results for courier licence".
  3. Results: each a heading that links to the page, one line from it, and a tag for its type or status.
  4. Pagination at the end, keeping the search in every link.
  5. No results: say so, repeat the search, and suggest what to try next, including how to ask a person.

Details

  • Use a GET form, so every search has an address people can share and bookmark. With Django, {% ggds_pagination page_obj %} keeps the search.
  • Put the search in the page title: "courier licence – Search – PCSRC".
  • Show 10 to 20 results a page. Order them by what people most likely want, not by date alone.

Accessibility

  • Give the search box a visible label, or a hidden one when the page's heading already says "Search".
  • Make the result count the first thing after the search box, so screen reader users hear it straight away.
  • Results are a list of headings, so people can move from one to the next.

Example: Search results

Open this example on its own page

HTML code for “Search results”
HTML
<h1>Search</h1>
<form action="/search/" method="get" role="search">
  <div class="ggds-field">
    <label class="ggds-label" for="results-q">Search this website</label>
    <input class="ggds-input ggds-input--width-long" id="results-q" name="q" type="search" value="courier licence" enterkeyhint="search">
  </div>
  <button class="ggds-button" type="submit">Search</button>
</form>
<p><strong>3 results</strong> for <strong>courier licence</strong></p>
<ol class="ggds-measure">
  <li>
    <h2><a href="/services/postal-courier-licence/">How to get a courier licence</a></h2>
    <p>Who needs a licence, the documents you need and what it costs. <strong class="ggds-tag ggds-tag--info">Service</strong></p>
  </li>
  <li>
    <h2><a href="/licensed-operators/">Licensed courier companies</a></h2>
    <p>Check that a courier company is licensed before you use it. <strong class="ggds-tag ggds-tag--info">List</strong></p>
  </li>
  <li>
    <h2><a href="/laws/courier-regulations/">Postal and Courier Services Regulations</a></h2>
    <p>The rules every licensed courier must follow. <strong class="ggds-tag ggds-tag--success">In force</strong></p>
  </li>
</ol>
<nav class="ggds-pagination" aria-label="Pages of results">
  <ul class="ggds-pagination__list">
    <li><a class="ggds-pagination__link" href="/search/?q=courier+licence" aria-label="Page 1" aria-current="page">1</a></li>
  </ul>
</nav>
JSX (React)
<>
  <h1>Search</h1>
  <form action="/search/" method="get" role="search">
    <div className="ggds-field">
      <label className="ggds-label" htmlFor="results-q">Search this website</label>
      <input className="ggds-input ggds-input--width-long" id="results-q" name="q" type="search" defaultValue="courier licence" enterKeyHint="search" />
    </div>
    <button className="ggds-button" type="submit">Search</button>
  </form>
  <p><strong>3 results</strong> for <strong>courier licence</strong></p>
  <ol className="ggds-measure">
    <li>
      <h2><a href="/services/postal-courier-licence/">How to get a courier licence</a></h2>
      <p>Who needs a licence, the documents you need and what it costs. <strong className="ggds-tag ggds-tag--info">Service</strong></p>
    </li>
    <li>
      <h2><a href="/licensed-operators/">Licensed courier companies</a></h2>
      <p>Check that a courier company is licensed before you use it. <strong className="ggds-tag ggds-tag--info">List</strong></p>
    </li>
    <li>
      <h2><a href="/laws/courier-regulations/">Postal and Courier Services Regulations</a></h2>
      <p>The rules every licensed courier must follow. <strong className="ggds-tag ggds-tag--success">In force</strong></p>
    </li>
  </ol>
  <nav className="ggds-pagination" aria-label="Pages of results">
    <ul className="ggds-pagination__list">
      <li><a className="ggds-pagination__link" href="/search/?q=courier+licence" aria-label="Page 1" aria-current="page">1</a></li>
    </ul>
  </nav>
</>

Example: No results

Open this example on its own page

HTML code for “No results”
HTML
<h1>Search</h1>
<form action="/search/" method="get" role="search">
  <div class="ggds-field">
    <label class="ggds-label" for="none-q">Search this website</label>
    <input class="ggds-input ggds-input--width-long" id="none-q" name="q" type="search" value="curier licnce" enterkeyhint="search">
  </div>
  <button class="ggds-button" type="submit">Search</button>
</form>
<p><strong>No results</strong> for <strong>curier licnce</strong></p>
<p>Try:</p>
<ul>
  <li>checking the spelling</li>
  <li>using fewer or different words, such as "courier"</li>
  <li>browsing <a href="/services/">all our services</a></li>
</ul>
<p>Or <a href="/contact/">ask us</a>: we reply within 2 working days.</p>
JSX (React)
<>
  <h1>Search</h1>
  <form action="/search/" method="get" role="search">
    <div className="ggds-field">
      <label className="ggds-label" htmlFor="none-q">Search this website</label>
      <input className="ggds-input ggds-input--width-long" id="none-q" name="q" type="search" defaultValue="curier licnce" enterKeyHint="search" />
    </div>
    <button className="ggds-button" type="submit">Search</button>
  </form>
  <p><strong>No results</strong> for <strong>curier licnce</strong></p>
  <p>Try:</p>
  <ul>
    <li>checking the spelling</li>
    <li>using fewer or different words, such as "courier"</li>
    <li>browsing <a href="/services/">all our services</a></li>
  </ul>
  <p>Or <a href="/contact/">ask us</a>: we reply within 2 working days.</p>
</>

Components used

  • Text input, textarea, select and file upload

    A single form question with a label, an optional hint and an error message.

  • Button

    Buttons do things: submit a form, save, continue.

  • Tag

    A short label that shows a status, such as "Open" or "Closed".

  • Pagination

    Links to move between pages of a long list.

  • Notice

    A message box for information, success, a warning or danger, and an urgent notice for the whole site.

Back to top

Something wrong, unclear or missing? Report a problem with this page or suggest a change to it on GitHub. You need a GitHub account.