Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

search

Semantic landmark element for search functionality. Wraps search forms and controls to provide accessibility and structural meaning.

Description

The <search> element is a semantic landmark that identifies content related to searching or filtering. It's the recommended way to mark up search functionality, replacing the older pattern of <form role="search">.

As a landmark element, <search> allows screen reader users to quickly navigate to search functionality using landmark navigation.

When to Use

  • Site-wide search: Main search functionality in headers
  • Page search: Search within specific content (tables, lists)
  • Filter controls: Filter interfaces that narrow displayed content
  • Search results pages: Wrap the search input on results pages

When Not to Use

  • For login forms - use <form> with appropriate labels
  • For general data input - use standard form elements

Basic Examples

Simple Search Input

Search with Form

Wrap a form inside <search> for server-side search functionality.

Variants

Every variant styles the input and button as children of <search> or of its direct <form> child (:is(search, search > form) > input). Use the form version whenever there is a submit button: a <button type="submit"> does nothing without a form.

.inline

Search input with button side-by-side using flexbox.

.compact

Smaller search for headers or sidebars.

.rounded

Pill-shaped search input.

.expanded

Full-width search input.

.header

Constrained width for header placement.

.with-icon

A decorative icon positioned at the inline start of the input. The icon is a sibling placed before the input (svg, .icon or <icon-wc>), and the input gets extra start padding. Combine with .rounded for a pill field.

Variant Classes Summary

Class Description
.inline Flexbox layout with input and button side-by-side
.compact Smaller sizing for dense interfaces
.rounded Pill-shaped input with full border radius
.expanded Full-width search input
.header Constrained max-width for header placement
.with-icon Positioned icon inside the input

Styling

Each variant matches controls that are direct children of <search> or of its direct <form>. Abridged from src/native-elements/search/styles.css:

Form Patterns

GET Form for Server Search

Use GET method so search queries appear in the URL and can be bookmarked/shared.

Client-Side Filtering

For client-side filtering, omit the form and handle input events directly.

Accessibility

Landmark Navigation

The <search> element is a landmark, meaning screen reader users can jump directly to it using landmark navigation. This replaces the older pattern of <form role="search">.

Labeling

Always provide a label for the search input. Options include:

  • Visible <label> element
  • Visually hidden <label> using .visually-hidden
  • aria-label attribute on the input

input[type="search"] vs input[type="text"]

Always use type="search" for search inputs. It provides:

  • Clear button in some browsers
  • Appropriate keyboard on mobile (search button instead of enter)
  • Semantic meaning for assistive technologies
  • Search-specific styling opportunities

Multiple Search Landmarks

A page can have more than one search landmark, for example a site search in the header and a filter above a table. Give each one an aria-label so landmark lists can tell them apart:

Keyboard Support

Key Action
Enter Submit the search form (when in form context)
Escape Clear the search input (browser-dependent)

Site Search Component

<site-search> builds a full search experience (dialog, keyboard shortcut, results) on top of this element. For its no-JavaScript fallback, use a plain <search><form action="/search" method="get"> that submits to your search page, so the landmark and the form work before the component upgrades (not the older <form role="search">). Use <search> on its own for simple GET forms and filters; use <site-search> when you want the instant-results dialog.

Related

  • <site-search> - Site-wide search dialog that uses a search landmark as its fallback
  • <input type="search"> - The search input element inside the search landmark
  • <form> - For wrapping search with server submission
  • <button> - Submit button for search forms
  • <nav> - Another landmark element (for navigation)

Browser Support

The <search> element is supported in all modern browsers. For older browsers, it degrades gracefully as a generic container while still functioning correctly.

↑