{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "slider",
  "type": "registry:ui",
  "title": "Slider",
  "description": "Single-value and min/max range sliders with exact-value bubbles and keyboard controls.",
  "dependencies": [
    "react-aria-components@^1.17.0"
  ],
  "registryDependencies": [
    "cx"
  ],
  "files": [
    {
      "path": "components/base/slider/slider.tsx",
      "content": "\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport {\n  Label as AriaLabel,\n  Slider as AriaSlider,\n  SliderThumb as AriaSliderThumb,\n  SliderTrack as AriaSliderTrack,\n} from \"react-aria-components\";\nimport type { SliderProps as AriaSliderProps } from \"react-aria-components\";\nimport { cx } from \"@/utils/cx\";\n\ntype SliderValue = number | number[];\n\ntype SliderBaseProps<T extends SliderValue> = Omit<\n  AriaSliderProps<T>,\n  \"children\" | \"className\" | \"orientation\"\n> & {\n  /** Optional visible label associated with every thumb. */\n  label?: ReactNode;\n  /** Show the exact value in a persistent bubble above each thumb. Default `true`. */\n  showTooltip?: boolean;\n  /** Custom visual formatter for the value bubbles. */\n  formatValue?: (value: number, index: number) => ReactNode;\n  className?: string;\n};\n\nexport type SliderProps = SliderBaseProps<number> & {\n  /** Accessible name for the single thumb. */\n  thumbLabel?: string;\n};\n\nexport type RangeSliderProps = SliderBaseProps<number[]> & {\n  /** Accessible names for the lower and upper thumbs. */\n  thumbLabels?: [string, string];\n};\n\ntype SliderBaseInternalProps<T extends SliderValue> = SliderBaseProps<T> & {\n  thumbLabels: string[];\n};\n\n/**\n * Shared single and multi-thumb slider presentation.\n *\n * React Aria owns the value model, drag behavior, hidden range inputs,\n * keyboard controls, RTL handling, and collision rules. BoardUI owns the\n * visual track, selected range, thumbs, and exact-value bubbles.\n */\nfunction SliderBase<T extends SliderValue>({\n  className,\n  label,\n  showTooltip = true,\n  formatValue,\n  thumbLabels,\n  ...props\n}: SliderBaseInternalProps<T>) {\n  return (\n    <AriaSlider\n      {...props}\n      orientation=\"horizontal\"\n      className={({ isDisabled }) =>\n        cx(\n          \"group flex w-full min-w-0 flex-col gap-2\",\n          isDisabled && \"cursor-not-allowed opacity-50\",\n          className,\n        )\n      }\n    >\n      {({ state }) => {\n        const isRange = state.values.length > 1;\n        const startPercent = isRange ? state.getThumbPercent(0) : 0;\n        const endPercent = state.getThumbPercent(state.values.length - 1);\n\n        return (\n          <>\n            {label != null && (\n              <AriaLabel className=\"text-body-medium text-text-primary\">\n                {label}\n              </AriaLabel>\n            )}\n\n            <AriaSliderTrack\n              className={cx(\n                \"relative h-8 w-full touch-none\",\n                showTooltip && \"mt-8\",\n              )}\n            >\n              {({ isHovered }) => (\n                <>\n                  <span\n                    aria-hidden\n                    className={cx(\n                      \"absolute top-1/2 end-0 start-0 h-1.5 -translate-y-1/2 rounded-full\",\n                      \"bg-background-tertiary-default shadow-[inset_0_1px_1px_rgb(0_0_0/0.06)]\",\n                      \"transition-colors duration-150 ease\",\n                      isHovered && \"bg-background-tertiary-hover\",\n                    )}\n                  />\n                  <span\n                    aria-hidden\n                    className={cx(\n                      \"absolute top-1/2 h-1.5 -translate-y-1/2 rounded-full\",\n                      \"bg-linear-to-r from-accent-500 to-accent-600\",\n                      \"shadow-[inset_0_1px_0_rgb(255_255_255/0.24),0_1px_2px_rgb(4_80_226/0.16)]\",\n                    )}\n                    style={{\n                      insetInlineStart: `${startPercent * 100}%`,\n                      insetInlineEnd: `${(1 - endPercent) * 100}%`,\n                    }}\n                  />\n\n                  {state.values.map((value, index) => {\n                    const valueLabel =\n                      formatValue?.(value, index) ??\n                      state.getThumbValueLabel(index);\n\n                    return (\n                      <AriaSliderThumb\n                        key={index}\n                        index={index}\n                        aria-label={\n                          thumbLabels[index] ??\n                          (isRange ? `Value ${index + 1}` : \"Value\")\n                        }\n                        className={({\n                          isDragging,\n                          isHovered: isThumbHovered,\n                          isFocusVisible,\n                          isDisabled,\n                        }) =>\n                          cx(\n                            \"top-1/2 size-5 rounded-full border border-border-button-default outline-none\",\n                            \"flex items-center justify-center bg-control-indicator-background\",\n                            \"shadow-[0_2px_4px_rgb(0_0_0/0.10),inset_0_1px_0_rgb(255_255_255/0.8)]\",\n                            \"transition-[scale,box-shadow,border-color] duration-150 ease\",\n                            isThumbHovered && !isDragging && \"scale-105 border-border-button-hover\",\n                            isDragging && \"z-20 scale-110 border-accent-500 shadow-[0_3px_8px_color-mix(in_srgb,var(--color-accent-600)_22%,transparent)]\",\n                            isFocusVisible && \"ring-2 ring-border-focus-ring ring-offset-2\",\n                            isDisabled ? \"cursor-not-allowed\" : \"cursor-grab active:cursor-grabbing\",\n                          )\n                        }\n                      >\n                        {({ isDragging, isFocused }) => (\n                          <>\n                            {showTooltip && (\n                              <span\n                                aria-hidden\n                                className={cx(\n                                  \"pointer-events-none absolute bottom-[calc(100%+9px)] left-1/2 -translate-x-1/2\",\n                                  \"flex h-7 min-w-8 items-center justify-center rounded-lg border border-border-button-default\",\n                                  \"bg-background-primary-default px-2 text-caption-1-medium whitespace-nowrap text-text-primary shadow-xs\",\n                                  \"transition-[translate,box-shadow] duration-150 ease\",\n                                  (isDragging || isFocused) && \"-translate-y-0.5 shadow-dropdown\",\n                                )}\n                              >\n                                {valueLabel}\n                                <span\n                                  aria-hidden\n                                  className=\"absolute -bottom-[4.5px] left-1/2 size-2 -translate-x-1/2 rotate-45 border-r border-b border-border-button-default bg-background-primary-default\"\n                                />\n                              </span>\n                            )}\n                            <span\n                              aria-hidden\n                              className={cx(\n                                \"size-2 rounded-full bg-linear-to-b from-accent-500 to-accent-600\",\n                                \"shadow-[inset_0_1px_0_rgb(255_255_255/0.24)] transition-[filter] duration-150 ease\",\n                                (isDragging || isFocused) && \"brightness-110\",\n                              )}\n                            />\n                          </>\n                        )}\n                      </AriaSliderThumb>\n                    );\n                  })}\n                </>\n              )}\n            </AriaSliderTrack>\n          </>\n        );\n      }}\n    </AriaSlider>\n  );\n}\n\n/** A single-value slider with an exact-value bubble above the thumb. */\nexport function Slider({ thumbLabel = \"Value\", ...props }: SliderProps) {\n  return <SliderBase {...props} thumbLabels={[thumbLabel]} />;\n}\n\n/** A two-thumb slider for selecting a minimum and maximum value. */\nexport function RangeSlider({\n  thumbLabels = [\"Minimum\", \"Maximum\"],\n  ...props\n}: RangeSliderProps) {\n  return <SliderBase {...props} thumbLabels={thumbLabels} />;\n}\n",
      "type": "registry:component",
      "target": "components/base/slider/slider.tsx"
    }
  ],
  "meta": {
    "docsUrl": "https://www.boardui.com/components/slider",
    "example": "import { RangeSlider, Slider } from \"@/components/base/slider/slider\";\n\nexport function Example() {\n  return (\n    <div className=\"flex max-w-md flex-col gap-10\">\n      <Slider label=\"Volume\" defaultValue={42} />\n      <RangeSlider\n        label=\"Monthly budget\"\n        defaultValue={[25, 75]}\n        formatValue={(value) => `$${value}`}\n      />\n    </div>\n  );\n}",
    "snippets": [
      {
        "label": "range",
        "code": "<RangeSlider\n  label=\"Price range\"\n  defaultValue={[200, 800]}\n  minValue={0}\n  maxValue={1000}\n  step={50}\n  formatValue={(value) => currency.format(value)}\n/>"
      },
      {
        "label": "controlled",
        "code": "const [volume, setVolume] = useState(40);\nconst [priceRange, setPriceRange] = useState([200, 800]);\n\n<Slider value={volume} onChange={setVolume} />\n\n<RangeSlider\n  value={priceRange}\n  onChange={setPriceRange}\n  onChangeEnd={(range) => saveRange(range)}\n/>"
      },
      {
        "label": "states",
        "code": "<Slider defaultValue={64} />\n\n{/* Hide the exact-value bubble when the surrounding UI shows the value */}\n<Slider defaultValue={36} showTooltip={false} />\n\n<RangeSlider defaultValue={[20, 70]} isDisabled />"
      }
    ]
  }
}
