FreeMIT LicenseFeatured

Roofline — Real Estate Map Search for React, shadcn/ui & Tailwind (Property Listings)

A complete real estate property search for React and shadcn/ui: a clustered MapLibre map with price pills, synced to a fast listings panel, smart search, filters with a price histogram, a property page with gallery, reviews and a visit request form, favourites and compare.

by UpFork, built by Ramin ValadanComponentUpdated 26 Oct 2026

Read how it was madeBehind the build6 lessons
Watch0
Preview of Roofline — Real Estate Map Search for React, shadcn/ui & Tailwind (Property Listings)

Code

31 files · 16 packages · 298 assets

"use client"

import { Check, Minus } from "lucide-react"
import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog"
import type { Property } from "./types"
import { amenities, amenityMeta, typeMeta } from "./lib/meta"
import { formatArea, formatPrice } from "./lib/format"
import { agentPhoto } from "./lib/photos"
import { useExplorer, useExplorerStore } from "./store"
import { Person, Photo } from "./parts"

type Row = { label: string; value: (p: Property) => React.ReactNode; score?: (p: Property) => number }

/** Two or three saved properties side by side; the best value in each row is highlighted. */
export function CompareDialog() {
  const store = useExplorerStore()
  const open = useExplorer((s) => s.compareOpen)
  const ids = useExplorer((s) => s.compareIds)
  const byId = useExplorer((s) => s.byId)
  const unit = useExplorer((s) => s.unit)
  const base = useExplorer((s) => s.assetBase)
  const list = ids.map((id) => byId.get(id)).filter((p): p is Property => Boolean(p))

  const rows: Row[] = [
    {
      label: "Price / month",
      value: (p) => <span className="font-mono tabular-nums">{formatPrice(p.price)}</span>,
      score: (p) => -p.price,
    },
    { label: "Area", value: (p) => formatArea(p.sqft, unit), score: (p) => p.sqft },
    {
      label: "Price per sq ft",
      value: (p) => <span className="font-mono tabular-nums">${(p.price / p.sqft).toFixed(2)}</span>,
      score: (p) => -p.price / p.sqft,
    },
    { label: "Bedrooms", value: (p) => (p.bedrooms ? p.bedrooms : "Open plan"), score: (p) => p.bedrooms },
    { label: "Bathrooms", value: (p) => p.bathrooms, score: (p) => p.bathrooms },
    { label: "Rating", value: (p) => `★ ${p.rating.toFixed(1)} (${p.reviewCount})`, score: (p) => p.rating },
    { label: "Type", value: (p) => typeMeta[p.type].label },
    ...amenities.map((a) => ({
      label: amenityMeta[a].label,
      value: (p: Property) =>
        p.amenities.includes(a) ? (
          <Check className="size-4 text-primary dark:text-chart-2" aria-label="Yes" />
        ) : (
          <Minus className="size-4 text-muted-foreground" aria-label="No" />
        ),
      score: (p: Property) => +p.amenities.includes(a),
    })),
    {
      label: "Agent",
      value: (p: Property) => (
        <span className="flex items-center gap-2">
          <Person src={agentPhoto(p.agent.id, base)} name={p.agent.name} className="size-7" />
          <span className="truncate">{p.agent.name}</span>
        </span>
      ),
    },
  ]

  const best = (row: Row, p: Property) => {
    if (!row.score || list.length < 2) return false
    const scores = list.map(row.score)
    const top = Math.max(...scores)
    return row.score(p) === top && scores.some((s) => s !== top)
  }

  return (
    <Dialog open={open} onOpenChange={(o) => store.getState().set({ compareOpen: o })}>
      <DialogContent className="max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-3xl p-0 sm:max-w-3xl">
        <div className="sticky top-0 z-10 border-b border-border/60 bg-background/95 px-6 pt-6 pb-4 backdrop-blur">
          <DialogTitle>Compare properties</DialogTitle>
          <DialogDescription>The best value in each row is highlighted.</DialogDescription>
        </div>
        <div className="overflow-x-auto px-6 pb-6">
          <table className="w-full min-w-[34rem] border-separate border-spacing-0 text-sm">
            <thead>
              <tr>
                <th className="w-32" />
                {list.map((p) => (
                  <th key={p.id} scope="col" className="p-1.5 text-left align-top font-normal">
                    <Photo photo={p.photos[0]} alt="" sizes="200px" className="aspect-[16/10] rounded-xl" />
                    <p className="mt-2 line-clamp-2 font-semibold">{p.name}</p>
                    <p className="text-xs text-muted-foreground">
                      {p.neighbourhood}, {p.city}
                    </p>
                  </th>
                ))}
              </tr>
            </thead>
            <tbody>
              {rows.map((row) => (
                <tr key={row.label}>
                  <th scope="row" className="border-t border-border/60 py-2 pr-3 text-left text-xs font-medium text-muted-foreground">
                    {row.label}
                  </th>
                  {list.map((p) => (
                    <td key={p.id} className="border-t border-border/60 p-1.5">
                      <span
                        className={cn(
                          "flex min-h-8 items-center rounded-lg px-2",
                          best(row, p) && "bg-primary/10 font-medium dark:bg-chart-2/15",
                        )}
                      >
                        {row.value(p)}
                      </span>
                    </td>
                  ))}
                </tr>
              ))}
              <tr>
                <td />
                {list.map((p) => (
                  <td key={p.id} className="p-1.5 pt-3">
                    <Button
                      size="sm"
                      variant="outline"
                      className="w-full rounded-full"
                      onClick={() => {
                        store.getState().set({ compareOpen: false })
                        store.getState().openDetail(p.id)
                      }}
                    >
                      View details
                    </Button>
                  </td>
                ))}
              </tr>
            </tbody>
          </table>
        </div>
      </DialogContent>
    </Dialog>
  )
}
31 files298 assets16 packages

From the workbench

Written about Roofline — Real Estate Map Search for React, shadcn/ui & Tailwind (Property Listings)

By the developer who built it: how it works, with its real code and live preview in the text, and the lessons learned along the way.

About

A full-screen map of listings with a floating listings panel, filters and a property detail panel, built on shadcn/ui (Radix), Tailwind CSS 4, MapLibre GL in the mapcn way, supercluster, TanStack Virtual, Embla, vaul, react-hook-form + zod, motion and sonner. Light and dark, phone to wide desktop.

pnpm install
pnpm dev                     # http://localhost:5301
pnpm build && pnpm start     # review build on http://localhost:5300
import { PropertyExplorer } from "@/components/explorer/explorer"

export default function Page() {
  return (
    <main className="h-dvh">
      <PropertyExplorer brand="Roofline" onRequestVisit={async (request) => api.post("/visits", request)} />
    </main>
  )
}
PropDefault
listingsthe 60 demo listingsyour data, ListingSeed[] (see types.ts); reviews, nearby places and price history are derived
brand"Roofline"the wordmark and the agency name on agent cards
storagePrefix"roofline"localStorage keys: ${prefix}-favourites, ${prefix}-public-filters (versioned, migrated)
assetBase""prefix for the photos under /images (a CDN)
stadiaApiKey—the Outdoors style outside localhost (Stadia Maps); without it Outdoors falls back to Default
syncUrltruemirror filters, the open property and the camera in the address bar
dashboardHref, buyHref/agent/dashboard, /pricingthe footer buttons
onRequestVisit—receives a validated visit request; the success card shows when it resolves
toastertruemounts a sonner <Toaster />; pass false if your app has one

| initialFilters | — | filters to open with ({ city: "Dubai" } for a /rent/dubai page), over saved ones; the address bar wins | | initialPropertyId | — | a property to open on load |

The explorer fills its parent: give the parent a height. Its layout follows its own width (under 768 px it is the phone layout with a bottom sheet), so it also works inside a page section.

What is in it

  • Map: CARTO Positron / Dark Matter that follows the theme, OpenFreeMap Streets and Stadia Outdoors with real previews in the style menu, a loading bar, and a fallback to Default when a style stays blank; clusters with a type ring and breakdown, spiderfied listings that share an address, 32 px type circles below zoom 11 and price pills from it, a pulsing halo on the selected listing, muted pills for viewed ones, hover previews, named and focusable markers, fit-to-results that respects the floating panels, fly-to with panel-aware offsets, "Search this area" and "Search as I move the map", 3D buildings, my location with sort by distance, a legend that filters, themed credits.
  • Listings panel: context title ("Villas · Dubai") with an animated, announced count, sort, card and list views, favourites, filters badge, a search combobox (cities, neighbourhoods, properties, recent searches, /), quick chips, removable active filters, a virtualized list with photo carousels (only the first photo loads up front), hover sync with the map, keyboard navigation, skeletons, an empty state with ways out, collapse to a rail, drag to resize.
  • Filters: docked beside the panel on wide screens, over it below; sort, availability (switch and status kept in sync), type tiles with counts, a price histogram with a two-thumb slider and exact inputs, bedrooms, bathrooms, furnishing, parking, rating, amenities, changed-section dots, a live "Show N properties", Save search.
  • Property detail: gallery with thumbnails, a full-screen lightbox (keys, swipe, zoom) and "Show all photos"; price with savings, deposit, move-in cost and a six-month trend; key facts with sq ft / m²; Overview, Location (mini map and walking times), Reviews (breakdown and reviewer photos) and Similar tabs; agent card with real listing count, call, email, message and "View listings"; Request a Visit (zod validation, past and booked days disabled, time slots, success card with an .ics); previous / next, share, save, full-listing view; a sticky action bar.
  • Also: compare two or three saved properties, a keyboard cheat sheet (?), toasts with Undo, URL state, reduced motion everywhere, a phone layout with a snapping bottom sheet and a card row that follows the markers.

Where things live

Path
components/explorer/explorer.tsxPropertyExplorer: providers, persistence, URL state, layout, shortcuts
components/explorer/store.tsthe zustand store (filters, favourites, UI) and localStorage migration
components/explorer/lib/filtering and sorting, formatting, URL state, photo paths, labels and colours
components/explorer/map/the MapLibre map (adapted from mapcn), clusters and markers, controls and overlays
components/explorer/panel/, filters/, detail/the listings panel, the filters panel, the property detail
components/explorer/data/listings.tsthe demo listings, agents and reviewers
components/explorer/data/enrich.tsderived fields, seeded per listing (stable between visits)
components/explorer/data/media.tsgallery assignment and blur previews, generated by pnpm media
public/images/photos (pnpm media, credits in public/images/CREDITS.md) and style previews

The components/ui/* files are standard shadcn/ui (new-york, Radix). Installed, the explorer follows your own shadcn/ui theme; for Roofline's emerald look, copy the :root and .dark variables from app/globals.css (also in registry/demos/roofline-theme.css).

MapLibre's worker. MapLibre GL 6 draws on a Web Worker kept in a file of its own (node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs) that app bundlers don't ship. Unless you set one, the explorer fetches the same version's file from unpkg (jsDelivr as a fallback) once and starts it from a blob. To serve it yourself, copy that file to public/ and call setWorkerUrl("/maplibre-gl-worker.mjs") from maplibre-gl before the explorer renders. Under a Content-Security-Policy, allow worker-src blob:, data: in connect-src and the map servers (basemaps.cartocdn.com, tiles.openfreemap.org, tiles.stadiamaps.com).

Scripts

pnpm media downloads and processes every photo (scripts/media-picks.json), node scripts/style-thumbs.mjs renders the style previews from a running server, pnpm shots takes review screenshots (light and dark, 1440 → 390 px) into .review/, and node scripts/e2e.mjs clicks through the main interactions, node scripts/a11y.mjs runs axe on the main screens, pnpm registry writes registry/ (what UpFork lists) and pnpm zip packs roofline.zip (see LISTING.md).

Map data © OpenStreetMap contributors, © CARTO, OpenFreeMap / OpenMapTiles, © Stadia Maps. The map component is adapted from mapcn (MIT). Photos from Unsplash (see public/images/CREDITS.md). Listings, agents and reviews are fictional.

Reviews and bugs

0 reviews · 0 bugs

Ship it0With fixes0Skip0· 0 reviews

0 bugs0 open0 fixed

Members who have it review it and report its bugs. Sign in

No reviews or bugs yet.

Manual installation

Without the CLI

  1. 01

    Install the packages

    npm install @hookform/resolvers @tanstack/react-virtual cmdk date-fns embla-carousel-react lucide-react maplibre-gl motion next-themes radix-ui react-hook-form sonner supercluster vaul zod zustand
  2. 02

    Add the shadcn/ui components it uses

    npx shadcn@latest add avatar button calendar collapsible dialog dropdown-menu kbd popover skeleton sonner switch tabs toggle-group tooltip
  3. 03

    Copy the files into your project

    • components/explorer/compare-dialog.tsx
    • components/explorer/context.ts
    • components/explorer/data/enrich.ts
    • components/explorer/data/listings.ts
    • components/explorer/data/media.ts
    • components/explorer/detail/detail-panel.tsx
    • components/explorer/detail/lightbox.tsx
    • components/explorer/detail/request-visit.tsx
    • components/explorer/detail/sections.tsx
    • components/explorer/explorer.css
    • components/explorer/explorer.tsx
    • components/explorer/filters/filters-panel.tsx
    • components/explorer/hooks.ts
    • components/explorer/lib/filter.ts
    • components/explorer/lib/format.ts
    • components/explorer/lib/meta.ts
    • components/explorer/lib/photos.ts
    • components/explorer/lib/url.ts
    • components/explorer/map/basemaps.ts
    • components/explorer/map/explorer-map.tsx
    • components/explorer/map/map-controls.tsx
    • components/explorer/map/map.tsx
    • components/explorer/map/markers.tsx
    • components/explorer/mobile-sheet.tsx
    • components/explorer/panel/listings-panel.tsx
    • components/explorer/panel/property-card.tsx
    • components/explorer/panel/search-combobox.tsx
    • components/explorer/parts.tsx
    • components/explorer/shortcuts-dialog.tsx
    • components/explorer/store.ts
    • components/explorer/types.ts

    The paths follow the shadcn/ui layout, with @/ as your project’s import alias.

  4. 04

    Its pictures load from UpFork

    The code above points at UpFork’s copies (19 MB), so there’s nothing to copy. To host them yourself, use Download source: its ZIP has the files where the code expects them, and a README on the switch.

Before you buy

Everything you need to know

How this component gets from the preview into your project, and what buyers ask most.

How to use it

From the preview to your project

  1. 01

    Try it in the preview

    Switch between light and dark, and resize it to phone and tablet widths, before you decide.

  2. 02

    Get it

    Free products are yours with a free account. Paid ones settle in USDT on TRON, sent straight to the wallet on your order.

  3. 03

    Install it

    Components go into your project with one shadcn command, dependencies included. Everything else downloads with a checksum.

  4. 04

    Make it yours

    It's your code now: rename it, restyle it and wire in your real data.

  5. 05

    Or hand it to your AI

    Copy the prompt and let your coding assistant place it in your project, following your conventions.

Building with an AI assistant?

Copy a ready-made prompt with the code, its dependencies and a demo, and your assistant can put it in place for you.

Copy AI prompt

Selling your own work?

Get approved once, then publish components, templates and mobile components, paid in USDT straight to your own wallet.