my/ui

Command Palette

Search for a command to run...

All components

Price Range Slider

sliders

Origin UI component.

responsive · 600px

Install

Same command in any shadcn project — React (Vite/CRA), Next.js, Remix, Astro, and more:

$npx shadcn@latest add https://your-domain/r/comp-260.json

Usage

import Cmp from "@/registry/origin-ui/comp-260";

export default function Demo() {
  return <Cmp />;
}

Component source

"use client";

import { useState } from "react";

import { Button } from "@/components/ui/button";
import { Label } from "@/components/ui/label";
import { Slider } from "@/components/ui/slider";

export default function Component() {
  const min_price = 5;
  const max_price = 1240;
  const [value, setValue] = useState([min_price, max_price]);

  const formatPrice = (price: number) => {
    return price === max_price
      ? `$${price.toLocaleString()}+`
      : `$${price.toLocaleString()}`;
  };

  return (
    <div className="*:not-first:mt-3">
      <Label className="tabular-nums">
        From {formatPrice(value[0])} to {formatPrice(value[1])}
      </Label>
      <div className="flex items-center gap-4">
        <Slider
          aria-label="Price range slider"
          max={max_price}
          min={min_price}
          onValueChange={setValue}
          value={value}
        />
        <Button variant="outline">Go</Button>
      </div>
    </div>
  );
}

Source: Origin UI