# Recipe components

Source: https://help.ruuster.com/idx/recipe-components

> Every React component in @ruuster/idx-recipes, including every screen of the listing page and the search page, what it renders, its props, whether it runs on the server or in the browser, and the GA4 events it sends.

`@ruuster/idx-recipes` is a set of React components that draw your listings the way the Ruuster
listing search draws them: the same cards, photo grid, map pins, filters and listing page, in your
brand colors and fonts. They work with React 18 and React 19, in Next.js and any other React
framework. Most of them render on the server, so search engines read every listing on the page.

Every component takes data exactly as the Ruuster Listings API returns it. You fetch with
[`@ruuster/idx`, the TypeScript SDK](https://help.ruuster.com/idx/guide-sdk) on your server and pass the answer in.

The components that ask the API from the browser (the search box, the filter choices and the mortgage
calculator) carry no key. Point them at your own listings route, which adds your secret key on your
server:

```ts
// app/api/idx/[...path]/route.ts
import { createListingsRoute } from "@ruuster/idx/route";

export const GET = createListingsRoute({ basePath: "/api/idx" });
```

Then give `SearchBox`, `Filters`, `FiltersDrawer` and `MortgageCalculator` the prop
`baseUrl="/api/idx"`, and `ListingDetail` the prop `apiBaseUrl="/api/idx"`. [No key in
your pages](https://help.ruuster.com/idx/keys-and-domains) explains the route, and the keyless way
for sites with no server of their own.

On a site without React, such as PHP, Python, Ruby on Rails, Go or plain HTML, [Build without React: HTML, CSS and JavaScript](https://help.ruuster.com/idx/recipe-html-css) gives you the same markup, the stylesheet and the script for every widget.

## Install

```sh
npm install @ruuster/idx @ruuster/idx-recipes
```

Then add the stylesheet once, in your root layout. `RecipesStyles` prints the recipes' CSS together
with your Ruuster brand kit, so every component matches your site from the first render.
[Match your brand](https://help.ruuster.com/idx/theming) explains the colors and fonts.

<p class="code-title"><code>packages/ruuster-idx-recipes/snippets/layout.tsx</code></p>

```tsx
// app/layout.tsx: load the recipes' stylesheet with your brand kit once, and your own Google Tag Manager container.
import type { ReactNode } from "react";
import Script from "next/script";
import { createClient } from "@ruuster/idx";
import { RecipesStyles } from "@ruuster/idx-recipes";

const idx = createClient({ secretKey: process.env.IDX_SECRET_KEY, baseUrl: process.env.IDX_BASE_URL || undefined, next: { revalidate: 3600 } });
const GTM_ID = process.env.NEXT_PUBLIC_GTM_ID;

export default async function RootLayout({ children }: { children: ReactNode }) {
  // #region theme
  // themeVars is your Ruuster brand kit as --rw-* CSS variables. Without it the recipes use the default look.
  const meta = await idx.meta();
  const themeVars = meta.ok ? meta.data.themeVars : undefined;
  // #endregion
  return (
    <html lang="en">
      <head>
        <RecipesStyles themeVars={themeVars} />
      </head>
      <body>
        {GTM_ID ? (
          <Script id="gtm" strategy="afterInteractive">
            {`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${GTM_ID}');`}
          </Script>
        ) : null}
        {children}
      </body>
    </html>
  );
}
```

## A complete search page

This page uses seven of the components together. It reads the visitor's filters from the page URL
with `fromSearchParams`, asks the API for one page of results, and renders the search box, the
filters, the map, the cards, the page links, the MLS notices and the JSON-LD.

<p class="code-title"><code>packages/ruuster-idx-recipes/snippets/search-page.tsx</code></p>

```tsx
// app/search/page.tsx: a server-rendered search page built from the recipe components. The search box
// asks your own listings route (app/api/idx, made with @ruuster/idx/route), so the page carries no key.
import { createClient, fromSearchParams } from "@ruuster/idx";
import { AreaMap, Filters, JsonLd, ListingGrid, MlsDisclaimers, Pagination, SearchBox } from "@ruuster/idx-recipes";

const idx = createClient({
  secretKey: process.env.IDX_SECRET_KEY,
  baseUrl: process.env.IDX_BASE_URL || undefined,
  detailHref: "/homes/{slug}",
  siteOrigin: process.env.SITE_ORIGIN,
  next: { revalidate: 300 },
});

type PageProps = { searchParams: Record<string, string | string[] | undefined> };

export default async function SearchPage({ searchParams }: PageProps) {
  const query = fromSearchParams(searchParams);
  const r = await idx.search({ ...query, limit: 24, pageHref: "/search" });
  if (!r.ok) return <p>{r.error.message}</p>;
  const mls = r.meta?.mls ?? [];
  return (
    <main>
      <SearchBox action="/search" baseUrl="/api/idx" />
      <Filters value={query} action="/search" />
      <AreaMap googleMapsKey={process.env.NEXT_PUBLIC_GOOGLE_MAPS_KEY ?? ""} mapId={process.env.NEXT_PUBLIC_GOOGLE_MAP_ID} viewport={r.data.viewport} listings={r.data.listings} mls={mls} />
      <ListingGrid listings={r.data.listings} mls={mls} ga4ListName={r.data.location?.label ?? "Search results"} />
      <Pagination page={r.data.page} pages={r.data.pages ?? 1} basePath="/search" searchParams={searchParams} />
      <MlsDisclaimers mls={mls} asOf={r.meta?.freshness.asOf} />
      <JsonLd docs={r.data.jsonLd ?? []} />
    </main>
  );
}
```

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-grid-1440.png" alt="Listing grid with the disclaimers under it, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The listing grid with the disclaimers under it.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-grid-375.png" alt="Listing grid with the disclaimers under it, on a phone (375 px wide)" width="375" height="1403" loading="lazy" decoding="async"><figcaption>The listing grid with the disclaimers under it.</figcaption></figure>

The markup is `static/html/listing-grid.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

## Server and browser components

| Component | Runs on | Sends GA4 events |
|---|---|---|
| `ListingCard` | Server | No |
| `ListingGrid` | Server | `view_item_list` |
| `Pagination` | Server | No |
| `ListingDetail` | Server, with the browser screens inside | `view_item` |
| `PhotoGrid`, `PriceBlock`, `MiniSummary`, `AgentCard`, `TourCard`, `ContactCards`, `AgentInfo`, `MobileActionBar` | Server | No |
| `ListingDetailSkeleton`, `ListingUnavailable`, `ListingGridSkeleton`, `ListingCardSkeleton`, `ResultsCountSkeleton` | Server | No |
| `ResultsToolbar` | Server, with a small browser enhancement | No |
| `Icon` | Server | No |
| `MlsDisclaimers` | Server | No |
| `MlsAttribution` | Server | No |
| `MarketStats` | Server | No |
| `Filters` | Server, with a small browser enhancement | No |
| `JsonLd` | Server | No |
| `RecipesStyles` | Server | No |
| `AreaMap` | Browser | No |
| `DetailHeader`, `OpenHouses`, `LocationMap` | Browser | No |
| `FullGallery`, `Lightbox`, `ShareModal` | Browser | No |
| `ContactAgentModal`, `RequestTourModal` | Browser | `generate_lead` |
| `MortgageCalculator` | Browser | No |
| `FiltersDrawer` | Browser | No |
| `SearchBox` | Browser | `search` |
| `TourForm`, `ContactForm`, `RegistrationForm` | Browser | `generate_lead` |
| `Ga4Event` | Browser | The event you give it |

The browser components carry the `"use client"` directive, so you can place them inside server
components as they are. [Analytics: GA4 and Google Tag Manager](https://help.ruuster.com/idx/guide-analytics)
lists the fields of each event.

## ListingCard

One listing as a card: the photo, one badge (an upcoming open house first, then New, Back on market,
Price change, Coming soon or Sold), the price, beds, baths and square feet, and the address. A sold
listing always shows "Sold" with its close date, such as "Sold Sep 1, 2026", and its sold price. The
address is a real link to the listing page that covers the whole card, so a click, a middle click or
the keyboard opens the listing. When a listing has more than one photo, arrows and swipes move
through the photos, and up to five dots show the position.

When the listing's board requires an office, agent or courtesy line on cards, the card prints it
under the address, read from `meta.mls`. When the board requires its logo on cards, the logo sits on
the photo. When the address is hidden, the card shows the city, state and ZIP code. A listing with no
photos shows a light panel with a house icon and "No photo available" in place of the photo.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-card-1440.png" alt="Listing card with photos and the attribution its board requires on cards, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>A listing card in the docs brand.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-card-375.png" alt="Listing card with photos and the attribution its board requires on cards, on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>A listing card in the docs brand.</figcaption></figure>

The markup is `static/html/listing-card.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `listing` | `ListingCard` | Yes | One item of `data.listings` from a search, a collection or similar homes |
| `href` | `string \| null` | No | The card's link. Default `listing.href`, then `/homes/{slug}` |
| `priority` | `boolean` | No | Set it on the first card above the fold: its photo loads first with `fetchpriority="high"` |
| `mls` | `MlsCompliance[]` | No | `meta.mls` from the same answer, so the card knows what its board requires |

## ListingGrid

The cards in a responsive grid: one column on phones, two from 768 pixels, three from 1280 pixels
and four from 1920 pixels, with 20 pixel gaps. The first card's photo loads with high priority.
When `listings` is empty, the grid shows `emptyText`.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `listings` | `ListingCard[]` | Yes | `data.listings` |
| `mls` | `MlsCompliance[]` | No | `meta.mls`, passed to every card |
| `ga4ListName` | `string \| false` | No | The GA4 `item_list_name`. Default "Listings". `false` sends no event |
| `emptyText` | `string` | No | The sentence shown when there are no listings |
| `hrefOf` | `(listing) => string \| null` | No | Your own link for each card |

Events: `view_item_list` once, with every card as an item.

## Pagination

Numbered page links under the grid: Previous page, the page numbers with gaps, and Next page. Each
one is a real link, so search engines follow them. Page 1 links to your path without `?page=`, every
other parameter in the URL stays on every link, the previous and next links carry `rel="prev"` and
`rel="next"`, and the current page carries `aria-current="page"`. With one page or none, it renders
nothing.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/pagination-1440.png" alt="Page links (page 2 of 7), on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The pagination row.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/pagination-375.png" alt="Page links (page 2 of 7), on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>The pagination row.</figcaption></figure>

The markup is `static/html/pagination.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `page` | `number` | Yes | `data.page` |
| `pages` | `number` | Yes | `data.pages`, how many pages you can link to |
| `basePath` | `string` | Yes | Your page's own path, for example `/neighborhoods/lincoln-park` |
| `searchParams` | `Record<string, string \| string[] \| undefined>` | No | The page's current parameters, kept on every link |
| `pageParam` | `string` | No | The parameter name. Default `page` |

## ListingDetail

The whole listing page with every screen: the sticky header with Back and, once the price scrolls
away, the price, address and facts with an X; the photo grid (one photo on phones, up to five from
768 pixels) with the share button, "Street view" and "N photos"; the price block with the status, the
price, beds, baths, square feet and the address; the description with Show more and the virtual tour
link; Agent information; open houses in the listing's own time zone with "Schedule a tour"; the
property details in sections with icons, the first one open; the mortgage calculator; the location
map; and the MLS block with the attribution line, the MLS number and the board's notice, which always
renders. From 992 pixels the page has two columns and the sidebar, with your agent card and the tour
card, stays in view; under 992 pixels the same two buttons sit in a bar fixed to the bottom. The full
gallery and the share, contact and tour screens are mounted once at the end and open from those
buttons.

The address is the page's `h1`. When the address is hidden, it is the city, state and ZIP code, and
the page shows no map and no Street view.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-detail-1440.png" alt="Listing page with every screen: the header, the photo grid, the price block, the description, agent information, open houses, the property details, the mortgage calculator, the location map, the contact and tour cards, the mobile bar, and the closed full gallery, share, contact and tour dialogs, on a desktop (1440 px wide)" width="1440" height="3125" loading="lazy" decoding="async"><figcaption>The listing page.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-detail-375.png" alt="Listing page with every screen: the header, the photo grid, the price block, the description, agent information, open houses, the property details, the mortgage calculator, the location map, the contact and tour cards, the mobile bar, and the closed full gallery, share, contact and tour dialogs, on a phone (375 px wide)" width="375" height="4044" loading="lazy" decoding="async"><figcaption>The listing page.</figcaption></figure>

The markup is `static/html/listing-detail.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/full-gallery-1440.png" alt="The full gallery dialog, closed, on its Photos tab, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The gallery opens from any photo or from the photo count.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/full-gallery-375.png" alt="The full gallery dialog, closed, on its Photos tab, on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>The gallery opens from any photo or from the photo count.</figcaption></figure>

The markup is `static/html/full-gallery.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

<p class="code-title"><code>packages/ruuster-idx-recipes/snippets/listing-page.tsx</code></p>

```tsx
// app/homes/[slug]/page.tsx: one listing with every screen of the listing page. The header, the photo
// grid and full gallery, the price block, Agent information, open houses, the property details, the
// mortgage calculator, the location map, the contact and tour cards, the mobile action bar, and the
// share, contact and tour screens all come from ListingDetail and its props.
import { notFound } from "next/navigation";
import { createClient, parseListingSlug } from "@ruuster/idx";
import { JsonLd, ListingDetail } from "@ruuster/idx-recipes";

const idx = createClient({
  secretKey: process.env.IDX_SECRET_KEY,
  baseUrl: process.env.IDX_BASE_URL || undefined,
  detailHref: "/homes/{slug}",
  siteOrigin: process.env.SITE_ORIGIN,
  next: { revalidate: 300 },
});

type PageProps = { params: { slug: string } };

export default async function ListingPage({ params }: PageProps) {
  const parsed = parseListingSlug(params.slug);
  if (!parsed) notFound();
  const r = await idx.get(parsed.id);
  if (!r.ok) notFound();
  const listing = r.data;
  return (
    <main>
      <ListingDetail
        listing={listing}
        mls={r.meta?.mls ?? []}
        backHref="/search"
        agent={{ name: "Jordan Lee", phone: "(404) 555-0134", email: "jordan@peachrealty.example", brokerage: "Peach Realty", license: "GA 412233" }}
        leadAction="/api/leads/fub"
        consentText="I agree that Peach Realty may call, text or email me about this home and other homes for sale. Message and data rates may apply. I can opt out at any time."
        alertsConsentText="Email me new listings like this one."
        googleMapsKey={process.env.NEXT_PUBLIC_GOOGLE_MAPS_KEY || null}
        mapId={process.env.NEXT_PUBLIC_GOOGLE_MAP_ID || null}
        // The mortgage calculator asks your own listings route (app/api/idx), so the page carries no key.
        apiBaseUrl="/api/idx"
      />
      <JsonLd docs={listing.jsonLd} />
    </main>
  );
}
```

| Prop | Type | Required | What it does |
|---|---|---|---|
| `listing` | `ListingDetail` | Yes | `data` from `GET /v1/listings/{listingId}` (`idx.get(id)`) |
| `mls` | `MlsCompliance[]` | No | `meta.mls`, for the board's logo, notice and placement rules |
| `backHref` | `string \| null` | No | The header's Back link and its X: your search page |
| `agent` | `DetailAgent \| null` | No | Your agent or office: `name`, `photoUrl`, `phone`, `email`, `brokerage`, `license` |
| `leadAction` | `string \| null` | No | Your lead route. With `consentText` it turns on the agent and tour cards, the action bar, "Schedule a tour" and the contact and tour screens |
| `consentText` | `ReactNode` | No | Your consent wording beside the unchecked box in the contact and tour screens |
| `alertsConsentText` | `ReactNode` | No | Your wording for the separate listing-alerts box |
| `shareUrl` | `string \| null` | No | The link the share screen shares. Default `head.canonical`, then `href`. `null` turns sharing off |
| `googleMapsKey` | `string \| null` | No | Your Google Maps key: the location map, the "Street view" pill and the gallery's Street view tab |
| `mapId` | `string \| null` | No | Your Map ID, for the location map's pin |
| `apiBaseUrl` | `string` | No | Where the mortgage calculator asks: your listings route, such as `/api/idx`. Setting it shows the calculator |
| `mortgage` | `boolean` | No | Default `true` when `apiBaseUrl` is set. `true` with no `apiBaseUrl` asks `https://idx.ruuster.com/v1` with no key (a site builder page on an approved address). `false` leaves the calculator off |
| `publishableKey` | `string \| null` | No | Leave out. Kept only for pages built before keyless requests |
| `aside` | `ReactNode` | No | Your own sidebar in place of the agent and tour cards |
| `ga4` | `boolean` | No | Default `true`. `false` sends no event |
| `now` | `Date` | No | The time open houses and tour days are read against. Leave it out on a live site |

Events: `view_item` once. [Listing detail page](https://help.ruuster.com/idx/recipe-listing-detail)
says what each prop turns on and what renders without it.

## The listing page's pieces

`ListingDetail` is built from these components. Each is exported, so a layout of your own can use
them. A screen opens from any button with `data-rw-open="gallery"`, `"share"`, `"contact"` or
`"tour"` inside the element that carries `data-rw-detail`, so put that attribute (with the listing's
id) on your own root element and mount each screen once inside it:

<p class="code-title"><code>packages/ruuster-idx-recipes/snippets/own-listing-layout.tsx</code></p>

```tsx
// Your own listing layout from the pieces ListingDetail is made of. The screens open from any button
// with data-rw-open inside the element that carries data-rw-detail, so mount each screen once inside
// that element and put your buttons anywhere in it.
import type { ListingDetail as ListingDetailData } from "@ruuster/idx";
import { ContactAgentModal, ContactCards, FullGallery, PhotoGrid, PriceBlock, RequestTourModal, ShareModal } from "@ruuster/idx-recipes";

const AGENT = { name: "Jordan Lee", phone: "(404) 555-0134", email: "jordan@peachrealty.example", brokerage: "Peach Realty" };
const CONSENT = "I agree that Peach Realty may call, text or email me about this home. I can opt out at any time.";

export function MyListingLayout({ listing, pageUrl }: { listing: ListingDetailData; pageUrl: string }) {
  return (
    <article className="rw-recipes my-listing" data-rw-detail={listing.id}>
      <PhotoGrid photos={listing.photos} fallbackAlt={listing.address.display} streetView={false} share />
      <div className="my-listing__columns">
        <PriceBlock listing={listing} />
        <aside>
          <ContactCards agent={AGENT} />
          {/* Any button of your own opens a screen the same way. */}
          <button type="button" className="my-button" data-rw-open="tour">
            Pick a tour time
          </button>
        </aside>
      </div>
      <FullGallery listing={listing} share />
      <ShareModal listing={listing} url={pageUrl} />
      <ContactAgentModal listing={listing} agent={AGENT} action="/api/leads/fub" consentText={CONSENT} />
      <RequestTourModal listing={listing} action="/api/leads/fub" consentText={CONSENT} />
    </article>
  );
}
```

| Component | Runs on | What it renders | Props |
|---|---|---|---|
| `DetailHeader` | Browser | The sticky header: Back, then the pinned summary and X | `summary` (from `miniSummaryOf(listing)`), `backHref`, `closeHref` (default `backHref`) |
| `MiniSummary`, `miniSummaryOf` | Server | The price, address, beds, baths and square feet on two lines | `data` |
| `PhotoGrid` | Server | The photo grid with its buttons | `photos`, `fallbackAlt`, `streetView`, `share`, `logo` |
| `PriceBlock` | Server | The status, price, facts and address | `listing`, `addressAs` (`"h1"` by default, or `"p"`) |
| `OpenHouses` | Browser | Open houses in the next 30 days, three then "Show all open houses" | `openHouses`, `tour` (the "Schedule a tour" row), `now` |
| `LocationMap` | Browser | The map with the price pin, the Street view switch and full screen | `googleMapsKey`, `mapId`, `lat`, `lng`, `priceLabel`, `address` |
| `AgentCard`, `TourCard`, `ContactCards` | Server | The sidebar's agent card and tour card, stacked by `ContactCards` | `agent`; `ContactCards` also takes `tour` (default `true`) |
| `AgentInfo` | Server | Agent information: name, photo, brokerage, license, email and phone | `agent` |
| `MobileActionBar` | Server | The bar fixed to the bottom under 992 pixels | `agent`, `tour` (default `true`) |
| `ListingDetailSkeleton` | Server | The page's outline while it loads, for `loading.tsx` | none |
| `ListingUnavailable` | Server | "This home is not available right now." and a Back link, for `not-found.tsx` | `backHref` |

## FullGallery and Lightbox

The full-screen gallery: Photos and Street view tabs, the photo mosaic, the sidebar with the price
block and your cards, and the lightbox that shows one photo at a time with the arrow keys and swipes.
[Photo gallery](https://help.ruuster.com/idx/recipe-gallery) has both props tables.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `listing` | `ListingDetail` or `ListingCard` | Yes | The listing whose photos it shows |
| `share` | `boolean` | Yes | Shows the Share button |
| `googleMapsKey` | `string \| null` | No | Adds the Street view tab for a shown address with coordinates |
| `sidebar` | `ReactNode` | No | Under the price block from 992 pixels |
| `mobileBar` | `ReactNode` | No | Fixed to the bottom under 992 pixels |

## ShareModal

Shares your own listing URL through the device's share sheet, or a screen with "Copy link" and
Facebook, WhatsApp and email buttons. [Share a listing](https://help.ruuster.com/idx/recipe-share).

| Prop | Type | Required | What it does |
|---|---|---|---|
| `listing` | `ListingDetail` or `ListingCard` | Yes | The listing being shared |
| `url` | `string` | Yes | Your listing URL |
| `nativeShare` | `boolean` | No | Default `true`. `false` always opens the share screen |

## ContactAgentModal

"Contact Jordan Lee": the visitor's name, email, phone and message with your consent wording, then a
thank-you with a tour time picker. [Contact the agent](https://help.ruuster.com/idx/recipe-contact-agent).

| Prop | Type | Required | What it does |
|---|---|---|---|
| `listing` | `ListingDetail` or `ListingCard` | Yes | The listing the visitor asks about |
| `action` | `string` | Yes | Your lead route |
| `consentText` | `ReactNode` | Yes | Your consent wording |
| `agent` | `DetailAgent \| null` | No | Your agent or office |
| `alertsConsentText` | `ReactNode` | No | Your wording for the listing-alerts box |
| `now` | `Date` | No | For tests. Leave it out on a live site |

Events: `generate_lead` after each request your route accepts.

## RequestTourModal

"Ready to tour?": a day from the next 16 days and a time of day, then the visitor's details with your
consent wording, then a summary. [Book a tour](https://help.ruuster.com/idx/recipe-tour-booking).

| Prop | Type | Required | What it does |
|---|---|---|---|
| `listing` | `ListingDetail` or `ListingCard` | Yes | The home to tour |
| `action` | `string` | Yes | Your lead route |
| `consentText` | `ReactNode` | Yes | Your consent wording |
| `alertsConsentText` | `ReactNode` | No | Your wording for the listing-alerts box |
| `now` | `Date` | No | For tests. Leave it out on a live site |

Events: `generate_lead` after a request your route accepts.

## MortgageCalculator and mortgagePrefill

The monthly payment for the home, line by line, from `GET /v1/mortgage/estimate` through your
listings route. `mortgagePrefill(listing)` reads the price, state, ZIP code, monthly HOA dues and
yearly tax from a listing. [Mortgage calculator](https://help.ruuster.com/idx/recipe-mortgage-calculator)
has the full props table and a first answer from your server.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/mortgage-calculator-1440.png" alt="The mortgage calculator with the first answer for the listing (its own tax and HOA figures, an estimated insurance line), on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The calculator on a listing page.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/mortgage-calculator-375.png" alt="The mortgage calculator with the first answer for the listing (its own tax and HOA figures, an estimated insurance line), on a phone (375 px wide)" width="375" height="1337" loading="lazy" decoding="async"><figcaption>The calculator on a listing page.</figcaption></figure>

The markup is `static/html/mortgage-calculator.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `price` | `number` | Yes | The listing's price |
| `state`, `zip` | `string \| null` | One of the two | Where the home is |
| `hoaMonthly`, `propertyTaxAnnual`, `insuranceAnnual` | `number \| null` | No | The listing's own figures |
| `initial` | `{ downPaymentPercent?, loanType?, termYears? }` | No | The starting choices |
| `baseUrl` | `string` | No | Your listings route, such as `/api/idx`. Default `https://idx.ruuster.com/v1`, with no key |
| `debounceMs` | `number` | No | Default 350 |
| `initialEstimate` | `MortgageEstimate \| null` | No | A first answer from `idx.mortgage()` on your server |
| `publishableKey` | `string` | No | Leave out. Kept only for pages built before keyless requests |

## Icon

`<Icon name="calendar-minimalistic" size={20} />` prints one of the icons the components use as an
inline SVG in the current text color. Without `label` it is hidden from screen readers; with `label`
it is an image with that name. `IconName` lists the names.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `name` | `IconName` | Yes | The icon |
| `size` | `number` | No | Width and height in pixels. Default 20 |
| `label` | `string` | No | An accessible name, for an icon that carries meaning on its own |
| `className` | `string` | No | Your own class |

The icons come from the Solar icon set, licensed under the Creative Commons Attribution 4.0 license;
the package's `NOTICE` file carries the credit.

## MlsDisclaimers

The notices every results page shows under the listings: each board in `meta.mls` once, with its
logo, its disclaimer and its other notices, then "Data last updated" with the time of the answer.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `mls` | `MlsCompliance[]` | Yes | `meta.mls` |
| `asOf` | `string \| null` | No | `meta.freshness.asOf` |
| `placement` | `"page" \| "map"` | No | `"map"` uses the compact style inside the map frame |

## MlsAttribution

One listing's attribution line and courtesy line, with its board's logo. `ListingDetail` already
includes it; use it on your own listing layouts.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `compliance` | `ListingCompliance` | Yes | `data.compliance` of a listing |
| `mls` | `MlsCompliance \| null` | No | The listing's board from `meta.mls` |

## AreaMap

A Google map of the search with a price pin for each listing, the outline of the area, and the
boards' notice inside the frame. It loads the Google Maps JavaScript API with your own key and Map
ID once the map scrolls into view and the browser is idle, so it adds nothing to the page's first
paint, and its height is reserved from the start. Pins show the short price ("$485K") with a dot in
the status color, and open the listing page. Listings with a hidden address have no pin. The map
needs your own Google Maps key and Map ID: [Get your Google Maps key](https://help.ruuster.com/idx/google-maps-key)
shows how, step by step.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `googleMapsKey` | `string` | Yes | Your Google Maps JavaScript API key, restricted to your domains (`NEXT_PUBLIC_GOOGLE_MAPS_KEY`) |
| `mapId` | `string \| null` | No | Your Map ID (`NEXT_PUBLIC_GOOGLE_MAP_ID`), for the styled price pins |
| `viewport` | `Bbox \| null` | Yes | `data.viewport` of the search. With `null` the map fits the pins |
| `boundary` | `BoundaryGeometry \| null` | No | The outline: `geometry` from `idx.boundary(id)`, or a saved shape's geometry |
| `listings` | `ListingCard[]` or `ListingPin[]` | Yes | The cards, or a `view: "map"` search for up to 200 pins |
| `mls` | `MlsCompliance[]` | No | `meta.mls`, shown inside the frame |
| `height` | `number \| string` | No | Default 360 pixels on phones and 560 pixels from 768 pixels |
| `searchHref` | `string` | No | Your page's own path and query. "Search this area" and the drawing tools start from it, and with it the page prints "Clear the drawn area" from the server |
| `drawing` | `boolean` | No | Default `true`: the tools to draw an area or a circle and lock it. The map and satellite switch always shows |
| `boundaryKind` | `string \| null` | No | `kind` from `idx.boundary(id)`. A school adds the school pin at the outline's center |

Pins close together group into a circle with the number of homes, and a click zooms in on them.
After the visitor pans or zooms, "Search this area" reloads your page with `bbox=` for the box on
screen. A drawn area or circle reloads it with `polygon=`.

## SearchBox

The location search box. After three characters and a short pause it asks `GET /v1/suggest`
through your listings route, and lists places in groups: City, ZIP code,
Neighborhood, Address, School and the rest. Picking one opens your search page with
`?where=` and that place, which `fromSearchParams` reads on the server. It works with the arrow keys,
Enter and Escape, and screen readers hear how many places match.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `action` | `string` | Yes | Your search page's path, for example `/search` |
| `baseUrl` | `string` | No | Your listings route, such as `/api/idx`. Default `https://idx.ruuster.com/v1`, with no key |
| `publishableKey` | `string` | No | Leave out. Kept only for pages built before keyless requests |
| `groups` | `string[]` | No | Which suggestion groups to ask for. Default: the API's default groups |
| `placeholder` | `string` | No | Default "City, address or ZIP code" |
| `minChars` | `number` | No | Default 3 |
| `debounceMs` | `number` | No | Default 300 |

Events: `search` with `search_term` set to the place the visitor picked.

## Filters

A filter form that works with JavaScript turned off: price range, bedrooms, bathrooms, home type,
property type, status and sort. It writes the API's own parameter names into your page's URL
(`priceMin`, `priceMax`, `bedsMin`, `bathsMin`, `subtype`, `type`, `status`, `sort`), so
`fromSearchParams(searchParams)` turns them into the next search without any mapping. The location
parameters stay as hidden fields. With JavaScript on, a change to a menu or a status box applies at
once and empty fields stay out of the URL. Every change starts again at page 1.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/filters-bar-1440.png" alt="The filter bar: the quick filters from 1741px and the More filters pill with its drawer, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The filter bar.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/filters-bar-375.png" alt="The filter bar: the quick filters from 1741px and the More filters pill with its drawer, on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>The filter bar.</figcaption></figure>

The markup is `static/html/filters-bar.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `value` | `SearchQuery` | Yes | The page's current query: `fromSearchParams(searchParams)` |
| `action` | `string` | Yes | Your page's own path |
| `fields` | `("price" \| "beds" \| "baths" \| "type" \| "status" \| "sort")[]` | No | Which controls to show. Default all |
| `keep` | `string[]` | No | Parameters kept as hidden fields. Default `where`, `boundariesId`, `zip`, `city`, `state`, `shape`, `soldPeriod`, `openHousePeriod` |
| `layout` | `"stack" \| "bar"` | No | `"stack"` (default) is the form above. `"bar"` is the search page's filter bar: Status, Price, Beds and baths, and Home type as small panels from 1741 pixels, then the "More filters" button with its drawer |
| `id` | `string` | No | The form's id. Set it when a page prints two `Filters` for the same path |
| `actions` | `boolean` | No | Default `true`. `false` hides the form's own Reset filters and Show results row |
| `activeCount` | `number` | No | With `layout="bar"`: the number on the "More filters" button |
| `filters` | `FilterInfo[]` | No | `data` from `idx.filters()`. Adds one row per filter your account offers (below) |
| `choices` | `Record<string, { value, label, count }[]>` | No | Choices you fetched on your server, by filter key: `data.options` from `idx.filterOptions()`. A list you leave out loads when the visitor opens it |
| `show` | `string[]` | No | Only these filter keys |
| `hide` | `string[]` | No | Every filter except these keys |
| `sections` | `("based" \| "advanced")[]` | No | Which sections to print. Default both |
| `baseUrl` | `string` | No | Your listings route, such as `/api/idx`, so a pick list can load its choices in the browser. Default `https://idx.ruuster.com/v1`, with no key |
| `publishableKey` | `string` | No | Leave out. Kept only for pages built before keyless requests |

### Every filter your account offers

Pass `filters` and the form prints one row for each filter your account can use, after the basic
controls. You never write a field name: the list comes from `GET /v1/filters`, with each filter's
label, its type and the order your own Ruuster filter panel shows it in. The filters of your panel
come first. Every other filter your MLSs offer sits under "Advanced filters", which opens on a click
and has a "Find a filter" box when the list is long.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/filters-drawer-dynamic-1440.png" alt="The More filters drawer built from the account's filter list, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The drawer with a filter list: your panel's filters, then &quot;Advanced filters&quot;.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/filters-drawer-dynamic-375.png" alt="The More filters drawer built from the account's filter list, on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>The drawer with a filter list: your panel's filters, then &quot;Advanced filters&quot;.</figcaption></figure>

The markup is `static/html/filters-drawer-dynamic.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

Each row gets the control its type calls for:

| The filter's `type` | What the visitor gets |
|---|---|
| `Min/Max/Range - Number`, `Min/Max/Range - $`, `Min/Max/Range - List` | Two number boxes, "No min" and "No max" |
| `Drop Down - Yes No` | A menu: Any, Yes, No |
| `Drop Down - Single Select`, `Drop Down - Predefined Single-Select` | A menu of the choices |
| `Drop Down - Multi-Select`, `Drop Down - Predefined Multi-Select`, `Free Text Field`, `Free Text Field Custom` | A list of checkboxes that opens, with a box to narrow it as you type |
| `Date Select` | A menu of periods, such as "In the past 7 days" |
| `Date Picker` | A date box |

A filter that takes an operator gets a "More options" link on its row: all of these, any of these or
none of these for a list, and a box to also show homes with no value for a number or a date.

The choices of a list load from `GET /v1/filters/options` when the visitor opens it, through your
listings route, and the box above the list narrows them as the visitor types. To have a list ready
in the first HTML, fetch it on your server and pass it in `choices`.

The form still works with JavaScript turned off: every control is a plain field, named as
`GET /v1/listings` takes it (`f.<key>`, `f.<key>Min`, `f.<key>Max`, `f.<key>_o`), so
`fromSearchParams(searchParams)` reads the next search straight from the URL. With `filters`,
the form applies when the visitor presses "Show results", so they can set several filters in one
go. `show`, `hide` and `sections` make a smaller panel: `sections={["based"]}` prints only
your panel's own filters.

```tsx
import { fromSearchParams } from "@ruuster/idx";
import { Filters } from "@ruuster/idx-recipes";
import { idx } from "@/lib/idx";

export default async function SearchPage({ searchParams }: { searchParams: Record<string, string | string[] | undefined> }) {
  const q = fromSearchParams(searchParams);
  // Your account's filters, in the order your panel shows them.
  const filters = await idx.filters();
  return (
    <Filters
      value={q}
      action="/search"
      layout="bar"
      filters={filters.ok ? filters.data : undefined}
      baseUrl="/api/idx"
    />
  );
}
```

The number on the "More filters" button counts these filters too. For a form of your own,
`DynamicFilterRows` prints only the rows, and `activeFilterCount(value, filters)` gives the
number.

## ResultsToolbar

The row above the results: "Showing 37 listings", the "Sort by" menu and the Grid and Map switch. The
sort menu is a small form on your page's own path that keeps every other parameter, starts again at
page 1 and applies as soon as the visitor picks an order. Grid and Map are links to the same search,
without `view` and with `view=map`; the current one carries `aria-current="page"`.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `total` | `number` | Yes | `data.total` |
| `view` | `"list" \| "map"` | Yes | The view the page shows |
| `basePath` | `string` | Yes | Your page's own path |
| `searchParams` | `Record<string, string \| string[] \| undefined>` | No | The page's parameters, kept by the sort form and the links |
| `sort` | `string` | No | The current order. Default `searchParams.sort` |
| `sortOptions` | `{ value, label }[]` | No | Default: the API's sort values with their labels |
| `listHref`, `mapHref` | `string` | No | Your own links for Grid and Map |

## FiltersDrawer

The "More filters" button and the drawer it opens from the right, with every filter, "Reset filters"
(which keeps the place) and "Show results". The button shows the number of filters that are on. The
drawer closes with its X, Escape or a click outside it, and the focus goes back to the button.
`Filters` with `layout="bar"` prints it for you.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/filters-drawer-1440.png" alt="The More filters pill and its drawer, closed, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The More filters drawer.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/filters-drawer-375.png" alt="The More filters pill and its drawer, closed, on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>The More filters drawer.</figcaption></figure>

The markup is `static/html/filters-drawer.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `value` | `SearchQuery` | Yes | The page's current query |
| `action` | `string` | Yes | Your page's own path |
| `fields` | `FilterField[]` | No | Which filters the drawer shows. Default all |
| `keep` | `string[]` | No | Parameters kept as hidden fields. Default the location parameters |
| `activeCount` | `number` | No | The number on the button. Default: the filters that are on |
| `id` | `string` | No | The base of the element ids |
| `filters`, `choices`, `show`, `hide`, `sections`, `baseUrl` | | No | As on `Filters`: with `filters`, the drawer lists every filter your account offers |

## ListingGridSkeleton, ListingCardSkeleton and ResultsCountSkeleton

Grey outlines of the cards and the count while a search runs, for `loading.tsx`. `ListingGridSkeleton`
lays out `count` cards (default 8) in the grid's own columns with one status for screen readers,
"Loading listings." The shimmer starts after 200 milliseconds and holds still under reduced motion.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `count` | `number` | No | `ListingGridSkeleton` only: how many cards. Default 8 |

## MarketStats

Market numbers for an area as tiles: median sold price, median price per square foot, median days on
market and months of supply. Each tile names its month, and prices show the change from the same
month a year earlier. A measure without a value has no tile, and the next measure from the homes for
sale takes its place (median list price, homes for sale, new listings), so an area with few recent
sales still shows four tiles. Under the tiles, a line names the boards and the time of the data.

<p class="code-title"><code>packages/ruuster-idx-recipes/snippets/market.tsx</code></p>

```tsx
// components/area-market.tsx: dated market numbers for one area, as tiles.
import { createClient } from "@ruuster/idx";
import { MarketStats } from "@ruuster/idx-recipes";

const idx = createClient({ secretKey: process.env.IDX_SECRET_KEY, baseUrl: process.env.IDX_BASE_URL || undefined, next: { revalidate: 86400 } });

export async function AreaMarket({ zip }: { zip: string }) {
  const m = await idx.market({ zip, months: 13 });
  if (!m.ok) return null;
  return <MarketStats market={m.data} mls={m.meta?.mls ?? []} />;
}
```

| Prop | Type | Required | What it does |
|---|---|---|---|
| `market` | `MarketData` | Yes | `data` from `GET /v1/market` (`idx.market(q)`) |
| `measures` | `MarketMeasure[]` | No | Default `medianSoldPrice`, `medianPricePerSqft`, `medianDaysOnMarket`, `monthsOfSupply`, filled to four tiles as above. Passing a list shows exactly those measures. |
| `mls` | `MlsCompliance[]` | No | `meta.mls` of the market answer |

## TourForm, ContactForm and RegistrationForm

Lead forms that post to your own server route, which sends the lead to your CRM. Each one sends a
`LeadSubmission` as JSON: the visitor's name, email, phone and message, the listing, the consent
the visitor gave with the exact wording they saw, the page, and the campaign ids from the URL the
visitor arrived on (UTM tags, `gclid`, `fbclid`). The tour form adds a preferred date and time of
day.

- The contact consent box and the listing alerts box both start unchecked. The send button turns on
  when the visitor checks the contact consent box.
- A hidden `website` field catches form robots. Your route drops any lead that fills it.
- After your route answers with a 2xx status, the form shows its thank-you text and sends the GA4
  `generate_lead` event. On any other answer it shows an error and keeps what the visitor typed.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/contact-form-1440.png" alt="Contact form (no listing), on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The contact form from the listing page's sidebar.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/contact-form-375.png" alt="Contact form (no listing), on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>The contact form from the listing page's sidebar.</figcaption></figure>

The markup is `static/html/contact-form.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `action` | `string` | Yes | Your route, for example `/api/leads/fub` |
| `consentText` | `ReactNode` | Yes | Your consent wording, shown beside the contact consent box |
| `alertsConsentText` | `ReactNode` | No | Your wording for the separate listing alerts box. Leave it out to leave the box out |
| `submitLabel` | `string` | No | Defaults: "Request a tour", "Send message", "Create my account" |
| `successText` | `string` | No | Your thank-you sentence |
| `listing` | `ListingCard` or `ListingDetail` | `TourForm`: yes. `ContactForm`: no | The listing the visitor asked about |

The routes for Follow Up Boss, Sierra Interactive and Sure Send are on
[Send leads and activity to your CRM](https://help.ruuster.com/idx/crm-overview).

## JsonLd

Puts schema.org JSON-LD in the page safely: one `<script type="application/ld+json">` per document,
with `<`, `>` and `&` escaped so listing remarks can never end the script early. Pass `data.jsonLd`
from a search, a listing's `jsonLd`, or `organization.jsonLd` from `/v1/meta`.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `docs` | one document or an array | Yes | The documents as the API returns them |

## Ga4Event and pushDataLayer

`<Ga4Event event="view_item" params={...} />` pushes one event to `window.dataLayer` after the page
loads. `pushDataLayer(event, params)` does the same from your own code. The recipes use them for the
four events; you can use them for your own pages.

## RecipesStyles and RECIPES_CSS

`RecipesStyles` prints the recipes' stylesheet and your brand variables in one `<style>`. If your
build prefers a CSS file, `RECIPES_CSS` is the same stylesheet as a string. Every rule starts with
`.rw-recipes`, the class on each component's outer element, so the stylesheet styles only the
recipes.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `themeVars` | `Record<string, string>` | No | `data.themeVars` from `GET /v1/meta` |

## COPY

Every sentence and label the components show is in one exported object, `COPY`. Use it to read
the wording, or to build your own translations.
