FormsResultsHead
Searchastronomic.dev# ResultsHead
For the heading over search results, with the live count and the sort.
Static: no JavaScript.
## Usage
```astro
import ResultsHead from "@astronomic-dev/ui/components/ResultsHead.astro";
```
## Examples
### Over a list
The heading, the count and the sort. The sort belongs to the Filters form named by filtersId.
```astro
---
import ResultsHead from "@astronomic-dev/ui/components/ResultsHead.astro";
import { sorts } from "../_data/vega.ts";
---
<ResultsHead heading="Homes for sale in Denver" count={6} countText={{ one: "home", other: "homes" }} sorts={sorts} filtersId="homes-filters" />
```
### As the page title
headingTag h1, on a search page where the heading is the page's title. One home: the count says "1 home".
```astro
---
import ResultsHead from "@astronomic-dev/ui/components/ResultsHead.astro";
import { sorts } from "../_data/vega.ts";
---
<ResultsHead headingTag="h1" heading="Homes for rent in Denver" count={1} countText={{ one: "home", other: "homes" }} sorts={sorts} filtersId="rent-filters" />
```
### With a note
The meta slot follows the count.
```astro
---
import ResultsHead from "@astronomic-dev/ui/components/ResultsHead.astro";
import { sorts } from "../_data/vega.ts";
---
<ResultsHead heading="Homes in Washington Park" count={2} countText={{ one: "home", other: "homes" }} sorts={sorts} filtersId="park-filters">
<span slot="meta">· Updated today at 9:40 am</span>
</ResultsHead>
```
## Props
### ResultsHead
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `string` | None | The heading, such as "Homes for sale in Denver". |
| `headingTag` | `"h1" \| "h2" \| "h3"` | `"h2"` | The heading's level: h1 where it is the page's title (a search page). |
| `count` | `number` | None | The count the server knows (every listing, with no filter). Unset: the count line waits for the search. |
| `countText` | `{ one: string; other: string }` | None | The count's noun, such as { one: "home", other: "homes" }. Default { one: "listing", other: "listings" }. |
| `sorts` | `{ value: string; label: string }[]` | None | The sorts, as passed to Filters. |
| `sort` | `string` | None | The sort picked at first (the Filters default). Default: the first. |
| `sortLabel` | `string` | `"Sort"` | The sort's visible label. |
| `sortPicker` | `boolean` | `false` | Draws the sort as a Select with picker. Filters' dropdown does not reach it: pass both. |
| `filtersId` | `string` | None | The Filters form's id. The sort belongs to it (its form attribute), so the filters keep it in the address bar. |
| `headingId` | `string` | None | The heading's id, for a list named by it (ListingResults' headingId). Default: a page-unique id. |
| `headingClass` | `string` | None | More classes for the heading, merged with cn(). |
| `class` | `string` | None | More classes for the root, merged with cn(). |
| Slot | Description |
| --- | --- |
| `meta` | A note after the count, such as "· Updated today at 9:40 am". |
Any other attribute goes on the root. A search writes the count with setResultsCount() from lib/filters.ts.
## Accessibility
- The heading has tabindex="-1", so a search can move focus to it (after a filter removes the open pin card, say).
- The visible count is not a live region. A separate status line, visually hidden, is written only after a reader's change or Back and Forward ("15 homes"), so a page load says nothing.
- The sort is a native select with a visible label. With no JavaScript it is hidden, as the filters are.
ResultsHead
FreeFor the heading over search results, with the live count and the sort.
- File
- ResultsHead.astro
- Group
- Forms
- Kind
- Static: no JavaScript
- Examples
- 3
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Over a list
The heading, the count and the sort. The sort belongs to the Filters form named by filtersId.
Homes for sale in Denver
6 homes
Force statemain.astro
examples/resultshead/main.astro
---
import ResultsHead from "@astronomic-dev/ui/components/ResultsHead.astro";
import { sorts } from "../_data/vega.ts";
---
<ResultsHead heading="Homes for sale in Denver" count={6} countText={{ one: "home", other: "homes" }} sorts={sorts} filtersId="homes-filters" />As the page title
headingTag h1, on a search page where the heading is the page's title. One home: the count says "1 home".
Homes for rent in Denver
1 home
Force stateh1.astro
examples/resultshead/h1.astro
---
import ResultsHead from "@astronomic-dev/ui/components/ResultsHead.astro";
import { sorts } from "../_data/vega.ts";
---
<ResultsHead headingTag="h1" heading="Homes for rent in Denver" count={1} countText={{ one: "home", other: "homes" }} sorts={sorts} filtersId="rent-filters" />With a note
The meta slot follows the count.
Homes in Washington Park
2 homes
· Updated today at 9:40 am
Force statewith-meta.astro
examples/resultshead/with-meta.astro
---
import ResultsHead from "@astronomic-dev/ui/components/ResultsHead.astro";
import { sorts } from "../_data/vega.ts";
---
<ResultsHead heading="Homes in Washington Park" count={2} countText={{ one: "home", other: "homes" }} sorts={sorts} filtersId="park-filters">
<span slot="meta">· Updated today at 9:40 am</span>
</ResultsHead>Minimal · Light