tinkerers-labs

Range Histogram

Forms

About

A two-handle range filter drawn over the distribution it filters, so you can see where the results are before you cut them off.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Range Histogram to your project and fits it to your theme.

Code

How Range Histogram is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client"

import * as React from "react"

import { RangeHistogram } from "@/components/ui/mischief-range-histogram"

/** A repeatable spread of nightly rates: private rooms, then whole homes. */
function nightlyRates() {
  let seed = 412
  const random = () => {
    seed = (seed * 16807) % 2147483647
    return seed / 2147483647
  }
  const normal = () =>
    Math.sqrt(-2 * Math.log(random() || 1e-9)) *
    Math.cos(2 * Math.PI * random())

  return Array.from({ length: 412 }, (_, index) => {
    const wholeHome = index % 3 === 0
    const rate = wholeHome ? 240 + normal() * 70 : 95 + normal() * 32
    return Math.round(Math.min(Math.max(rate, 35), 480))
  })
}

const rates = nightlyRates()
const dollars = (value: number) => `$${value}`

export default function RangeHistogramDemo() {
  const [range, setRange] = React.useState<[number, number]>([70, 260])

  return (
    <div className="bg-background border-border w-full max-w-[28rem] rounded-[1.25rem] border p-5 shadow-sm sm:p-6">
      <h3 className="text-lg font-semibold">Filters</h3>
      <p className="text-muted-foreground mt-1 text-sm">
        Stays in Lisbon, 3 nights, 2 guests.
      </p>

      <RangeHistogram
        className="mt-6"
        label="Price per night"
        values={rates}
        min={30}
        max={480}
        step={5}
        value={range}
        onValueChange={setRange}
        formatValue={dollars}
        formatCount={(count, total) => `${count} of ${total} stays`}
        inputs
      />
    </div>
  )
}

More by tinkerers-labs

View all
  • Prompt Input

    Prompt Input

    11
  • Burst

    Burst

    4
  • Quantity Button

    Quantity Button

    1
  • Undo Button

    Undo Button

  • Tool Approval

    Tool Approval

  • Notification Stack

    Notification Stack

  • Swipe Actions

    Swipe Actions

  • Sparkline

    Sparkline

More in Forms

View all
  • Form

    Form

    7
  • Login 2

    Login 2

    16
  • Contact Form

    Contact Form

    33
  • Contact Card

    Contact Card

    1.1K
  • Book A Demo 1

    Book A Demo 1

    95
  • Premium Auth

    Premium Auth

    614
  • Onboarding Stepper

    Onboarding Stepper

    13
  • Authentication Card

    Authentication Card

    52