Inputs

Price Range

A range on two native sliders: the bounds stop against each other, so "from" never exceeds "to".

  • range
  • filter
  • price
  • slider

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/range-001?lang=en

Price4 00014 000

020 000

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "range-001" (Price Range) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/range-001.json

Registry item: https://vibeui.ru/r/range-001.json
Installs to: components/vibeui/range-001.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A range on two native sliders: the bounds stop against each other, so "from" never exceeds "to".

A price range: two bounds on native sliders, a filled segment between them and the edge labels. Zero dependencies, one file.

## 3. How to use it
import { Range001 } from "@/components/vibeui/range-001"

<Range001 label="Price" min={0} max={20000} step={500} defaultFrom={4000} defaultTo={14000} />

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-range-001-* palette — do not swap it for your theme tokens
- two native sliders: a custom drag would need keyboard and touch support
- pointer-events on the thumbs only — otherwise the top slider eats the clicks
- the bounds stopping against each other: crossing them yields an empty result
- an aria-label on each bound: two identical sliders are indistinguishable by ear
- the current values in the heading, not just the handle positions

## 6. You may change
- label, min, max and step
- defaultFrom and defaultTo
- unit — the unit of measure
- the accent through the accent prop

## 7. Rules
- Thumbs at equal values overlap: step sets the minimum gap.
- Thumb styling is vendor-prefixed: ::-webkit- and ::-moz- rules cannot share a selector.
- For exact amounts keep two number fields beside the filter.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/range-001.json
https://vibeui.ru/r/range-001.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-range-001-*. Клиентский: "use client" ради двух границ. Ползунки лежат друг на друге: дорожка не ловит события, а ручки ловят, поэтому обе доступны мышью. Закрашенный отрезок рисуется градиентом по двум переменным процента.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

"use client"

import { useState } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Range001Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "defaultValue" | "onChange"
> & {
  label?: string
  min?: number
  max?: number
  step?: number
  defaultFrom?: number
  defaultTo?: number
  unit?: string
  accent?: string
}

// Идея компонента: диапазон двумя нативными ползунками. Один ползунок не умеет
// хранить две границы, а свой драг пришлось бы учить клавиатуре и касаниям.
// Ползунки лежат друг на друге: дорожка отключена для событий, а ручки — нет,
// поэтому обе доступны мышью. Границы не перепрыгивают: каждая упирается в
// соседнюю, иначе «от» становится больше «до» и фильтр возвращает пустоту.
const STYLES = `
:where([data-vibeui-block="range-001"]){
--vibeui-range-001-bg:oklch(1 0 0);
--vibeui-range-001-fg:oklch(0.24 0.014 265);
--vibeui-range-001-muted:oklch(0.56 0.014 265);
--vibeui-range-001-border:oklch(0.9 0.006 265);
--vibeui-range-001-track:oklch(0.92 0.006 265);
--vibeui-range-001-accent:oklch(0.55 0.2 262);
--vibeui-range-001-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
--vibeui-range-001-from:0%;
--vibeui-range-001-to:100%;
}
[data-vibeui-block="range-001"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:20rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-range-001-bg);
border:1px solid var(--vibeui-range-001-border);border-radius:0.875rem;
font-family:var(--vibeui-range-001-font);color:var(--vibeui-range-001-fg);
}
[data-vibeui-block="range-001"] [data-part="head"]{
display:flex;align-items:baseline;justify-content:space-between;gap:1rem;
margin:0;font-size:0.875rem;
}
[data-vibeui-block="range-001"] [data-part="value"]{font-weight:650;font-variant-numeric:tabular-nums}
[data-vibeui-block="range-001"] [data-part="rail"]{
position:relative;height:1.25rem;
}
/* Дорожка одна на два ползунка: закрашен отрезок между границами. */
[data-vibeui-block="range-001"] [data-part="rail"]::before{
content:"";position:absolute;left:0;right:0;top:0.4375rem;height:0.375rem;
border-radius:9999px;
background:linear-gradient(to right,
var(--vibeui-range-001-track) var(--vibeui-range-001-from),
var(--vibeui-range-001-accent) var(--vibeui-range-001-from),
var(--vibeui-range-001-accent) var(--vibeui-range-001-to),
var(--vibeui-range-001-track) var(--vibeui-range-001-to));
}
[data-vibeui-block="range-001"] input{
position:absolute;left:0;top:0;width:100%;height:1.25rem;margin:0;
appearance:none;background:none;pointer-events:none;
}
[data-vibeui-block="range-001"] input::-webkit-slider-runnable-track{background:none;height:0.375rem}
[data-vibeui-block="range-001"] input::-moz-range-track{background:none;height:0.375rem}
/* Дорожка событий не ловит, ручки ловят: иначе верхний ползунок съедает клики. */
[data-vibeui-block="range-001"] input::-webkit-slider-thumb{
appearance:none;pointer-events:auto;cursor:pointer;margin-top:-0.3125rem;
width:1rem;height:1rem;border-radius:9999px;
background:var(--vibeui-range-001-bg);border:2px solid var(--vibeui-range-001-accent);
box-shadow:0 1px 3px oklch(0.2 0.02 265 / 25%);
}
[data-vibeui-block="range-001"] input::-moz-range-thumb{
pointer-events:auto;cursor:pointer;box-sizing:border-box;
width:1rem;height:1rem;border-radius:9999px;
background:var(--vibeui-range-001-bg);border:2px solid var(--vibeui-range-001-accent);
}
[data-vibeui-block="range-001"] input:focus-visible{outline:2px solid var(--vibeui-range-001-accent);outline-offset:4px;border-radius:0.5rem}
[data-vibeui-block="range-001"] [data-part="scale"]{
display:flex;justify-content:space-between;margin:0;
font-size:0.6875rem;color:var(--vibeui-range-001-muted);font-variant-numeric:tabular-nums;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="range-001"] *{animation:none!important;transition:none!important}}
`

/**
 * Диапазон двумя нативными ползунками: границы не перепрыгивают друг друга.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Range001({
  label = "Цена",
  min = 0,
  max = 20000,
  step = 500,
  defaultFrom = 4000,
  defaultTo = 14000,
  unit = " ₽",
  accent,
  className,
  style,
  ...props
}: Range001Props) {
  const [from, setFrom] = useState(defaultFrom)
  const [to, setTo] = useState(defaultTo)
  const percent = (value: number) => `${((value - min) / (max - min)) * 100}%`

  const palette = {
    "--vibeui-range-001-from": percent(from),
    "--vibeui-range-001-to": percent(to),
    ...(accent ? { "--vibeui-range-001-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-range-001" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="range-001"
        className={className}
        style={palette}
      >
        <p data-part="head">
          {label}
          <span data-part="value">
            {from.toLocaleString("ru-RU")}
            {unit} — {to.toLocaleString("ru-RU")}
            {unit}
          </span>
        </p>
        <div data-part="rail">
          <input
            type="range"
            min={min}
            max={max}
            step={step}
            value={from}
            aria-label={`${label}: от`}
            onChange={(event) =>
              setFrom(Math.min(Number(event.target.value), to - step))
            }
          />
          <input
            type="range"
            min={min}
            max={max}
            step={step}
            value={to}
            aria-label={`${label}: до`}
            onChange={(event) =>
              setTo(Math.max(Number(event.target.value), from + step))
            }
          />
        </div>
        <p data-part="scale">
          <span>
            {min.toLocaleString("ru-RU")}
            {unit}
          </span>
          <span>
            {max.toLocaleString("ru-RU")}
            {unit}
          </span>
        </p>
      </div>
    </>
  )
}