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
- The search box at the top, still holding what people searched for, so they can change it.
- A count: "24 results for courier licence".
- Results: each a heading that links to the page, one line from it, and a tag for its type or status.
- Pagination at the end, keeping the search in every link.
- No results: say so, repeat the search, and suggest what to try next, including how to ask a person.
Details
- Use a
GETform, 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
<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><>
<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
<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><>
<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
Something wrong, unclear or missing? or suggest a change to it on GitHub. You need a GitHub account.