{
  "schemaVersion": 1,
  "target": "react",
  "name": "slider",
  "version": "0.1.0",
  "category": "forms",
  "title": "Slider",
  "description": "A single or range slider with a value readout, a value bubble on the thumb, labeled marks, and keyboard steps.",
  "tags": [
    "form",
    "slider",
    "range",
    "input",
    "base-ui"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {
    "@base-ui/react": "^1.9.0"
  },
  "registryDependencies": [],
  "docsPath": "/components/slider",
  "props": [
    {
      "name": "value / defaultValue",
      "type": "number | number[]",
      "description": "A number for one thumb, an array for a range."
    },
    {
      "name": "onValueChange / onValueCommitted",
      "type": "(value) => void",
      "description": "Called while dragging and when the change is final."
    },
    {
      "name": "min / max / step",
      "type": "number",
      "default": "0 / 100 / 1",
      "description": "Range and granularity."
    },
    {
      "name": "largeStep",
      "type": "number",
      "default": "10",
      "description": "Step for Shift + arrow and Page Up/Down."
    },
    {
      "name": "label",
      "type": "ReactNode",
      "description": "Visible label above the track; it names every thumb."
    },
    {
      "name": "showValue",
      "type": "boolean",
      "default": "true with a label",
      "description": "Shows the current value or range at the end of the label row."
    },
    {
      "name": "tooltip",
      "type": "\"auto\" | \"always\" | \"never\"",
      "default": "\"auto\"",
      "description": "A value bubble over the thumb on hover, keyboard focus, and drag."
    },
    {
      "name": "format / formatValue",
      "type": "Intl.NumberFormatOptions | (value) => string",
      "description": "How values are written in the readout and the bubble."
    },
    {
      "name": "marks",
      "type": "{ value: number; label?: ReactNode }[]",
      "description": "Labeled positions under the track."
    },
    {
      "name": "thumbLabels",
      "type": "string[]",
      "description": "Accessible names for the thumbs of a range slider."
    }
  ],
  "accessibility": [
    "Each thumb holds a native <input type=\"range\">, so screen readers announce its value and range.",
    "Arrow keys move by step, Shift + arrow and Page Up/Down by largeStep, Home and End jump to the ends.",
    "Slider.Label names single thumbs; range thumbs take thumbLabels as aria-label.",
    "The value bubble and marks are aria-hidden duplicates of the announced value.",
    "The thumb follows the pointer without easing; the bubble only fades under reduced motion."
  ],
  "states": [
    "default",
    "hover",
    "focus-visible",
    "dragging",
    "disabled"
  ],
  "files": [
    {
      "path": "ui/slider.tsx",
      "content": "\"use client\";\n\nimport { Slider as BaseSlider } from \"@base-ui/react/slider\";\nimport type { ReactNode } from \"react\";\n\ntype ClassName<State> = string | ((state: State) => string | undefined) | undefined;\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\n/** Prepends base classes while keeping Base UI's state-function form of className working. */\nfunction withBase<State>(base: string, className: ClassName<State>) {\n  return typeof className === \"function\" ? (state: State) => cx(base, className(state)) : cx(base, className);\n}\n\nexport interface SliderMark {\n  /** Where the mark sits, in the slider's own units. */\n  value: number;\n  /** Text under the track. Leave it out for an unlabeled tick. */\n  label?: ReactNode;\n}\n\nexport interface SliderProps<Value extends number | readonly number[]> extends Omit<BaseSlider.Root.Props<Value>, \"children\"> {\n  /** Visible label above the track. It names every thumb. */\n  label?: ReactNode;\n  /** Shows the current value (or range) at the end of the label row. */\n  showValue?: boolean;\n  /**\n   * A small bubble above each thumb with its value. `auto` shows it while the thumb is hovered,\n   * focused from the keyboard, or dragged; `always` keeps it up; `never` hides it.\n   */\n  tooltip?: \"auto\" | \"always\" | \"never\";\n  /** Formats values for the readout and the tooltip. Defaults to `Intl.NumberFormat` with `format`. */\n  formatValue?: (value: number) => string;\n  /** Labeled positions under the track, such as the ends of a scale or common presets. */\n  marks?: SliderMark[];\n  /** Accessible names for the thumbs of a range slider, in order, such as `[\"Minimum\", \"Maximum\"]`. */\n  thumbLabels?: string[];\n}\n\n/**\n * A single or range slider. Pass a number for one thumb or an array for a range. Arrow keys move\n * by `step`, Shift + arrow and Page Up/Down by `largeStep`, Home and End jump to the ends.\n * The thumb follows the pointer without easing; only its press scale and the tooltip animate.\n */\nexport function Slider<Value extends number | readonly number[]>({\n  label,\n  showValue = label != null,\n  tooltip = \"auto\",\n  formatValue,\n  marks,\n  thumbLabels,\n  min = 0,\n  max = 100,\n  format,\n  locale,\n  value,\n  defaultValue,\n  className,\n  ...props\n}: SliderProps<Value>) {\n  const initial = value ?? defaultValue;\n  const thumbCount = Array.isArray(initial) ? initial.length : 1;\n  const formatter = new Intl.NumberFormat(locale, format);\n  const display = formatValue ?? ((n: number) => formatter.format(n));\n  const percent = (n: number) => ((n - min) / (max - min)) * 100;\n\n  return (\n    <BaseSlider.Root<Value>\n      min={min}\n      max={max}\n      format={format}\n      locale={locale}\n      value={value}\n      defaultValue={defaultValue}\n      className={withBase(\"grid w-full gap-2.5 data-[disabled]:opacity-50\", className)}\n      {...props}\n    >\n      {label != null || showValue ? (\n        <div className=\"flex items-baseline justify-between gap-4\">\n          {label != null ? (\n            <BaseSlider.Label className=\"text-sm leading-5 font-medium text-zinc-950 select-none dark:text-white\">\n              {label}\n            </BaseSlider.Label>\n          ) : (\n            <span />\n          )}\n          {showValue ? (\n            <BaseSlider.Value aria-live=\"off\" className=\"font-mono text-xs text-zinc-500 tabular-nums dark:text-zinc-400\">\n              {(_formatted, values) => values.map(display).join(\" – \")}\n            </BaseSlider.Value>\n          ) : null}\n        </div>\n      ) : null}\n      <BaseSlider.Control className=\"relative flex h-5 w-full cursor-pointer touch-none items-center select-none data-[disabled]:cursor-not-allowed\">\n        <BaseSlider.Track className=\"relative h-1 w-full rounded-full bg-zinc-950/10 dark:bg-white/15\">\n          <BaseSlider.Indicator className=\"rounded-full bg-zinc-950 dark:bg-white\" />\n          {Array.from({ length: thumbCount }, (_, index) => (\n            <BaseSlider.Thumb\n              key={index}\n              index={index}\n              aria-label={thumbLabels?.[index]}\n              className={cx(\n                \"group/thumb relative size-4 rounded-full outline-none\",\n                \"border border-zinc-950/20 bg-white shadow-[0_1px_3px_rgb(0_0_0/0.18)]\",\n                \"dark:border-white dark:shadow-[0_0_0_3px_rgb(0_0_0),0_1px_3px_rgb(0_0_0/0.5)]\",\n                \"transition-[scale,box-shadow] duration-150 ease-out motion-reduce:transition-none\",\n                \"motion-safe:data-[dragging]:scale-110\",\n                \"has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-sky-500\",\n                // A larger invisible hit area around the 16px thumb.\n                \"after:absolute after:-inset-2 after:rounded-full after:content-['']\",\n              )}\n              render={(thumbProps, state) => (\n                <div {...thumbProps}>\n                  {thumbProps.children}\n                  {tooltip === \"never\" ? null : (\n                    <span\n                      aria-hidden=\"true\"\n                      className={cx(\n                        \"pointer-events-none absolute bottom-full left-1/2 mb-2.5 -translate-x-1/2 origin-bottom\",\n                        \"rounded-md px-1.5 py-1 font-mono text-[11px] leading-none whitespace-nowrap tabular-nums\",\n                        \"bg-zinc-950 text-white shadow-[0_4px_12px_-4px_rgb(0_0_0/0.3)] dark:bg-white dark:text-black\",\n                        \"transition-[opacity,scale] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none\",\n                        tooltip === \"always\"\n                          ? \"opacity-100\"\n                          : cx(\n                              \"opacity-0 motion-safe:scale-90\",\n                              \"group-hover/thumb:opacity-100 group-hover/thumb:scale-100\",\n                              \"group-has-[:focus-visible]/thumb:opacity-100 group-has-[:focus-visible]/thumb:scale-100\",\n                              \"group-data-[dragging]/thumb:opacity-100 group-data-[dragging]/thumb:scale-100\",\n                            ),\n                      )}\n                    >\n                      {display(state.values[index] ?? min)}\n                    </span>\n                  )}\n                </div>\n              )}\n            />\n          ))}\n        </BaseSlider.Track>\n      </BaseSlider.Control>\n      {marks?.length ? (\n        <div aria-hidden=\"true\" className=\"relative h-4\">\n          {marks.map((mark) => (\n            <span\n              key={mark.value}\n              style={{ left: `${percent(mark.value)}%` }}\n              className={cx(\n                \"absolute top-0 text-xs leading-none whitespace-nowrap text-zinc-500 tabular-nums dark:text-zinc-500\",\n                // Labels at the ends align to the track's edges instead of hanging past them.\n                mark.value <= min ? \"translate-x-0\" : mark.value >= max ? \"-translate-x-full\" : \"-translate-x-1/2\",\n              )}\n            >\n              {mark.label}\n            </span>\n          ))}\n        </div>\n      ) : null}\n    </BaseSlider.Root>\n  );\n}\n"
    }
  ],
  "example": {
    "content": "\"use client\";\n\nimport { Slider } from \"@/components/shaken/ui/slider\";\n\nexport default function SliderExample() {\n  return (\n    <div className=\"grid w-full max-w-sm gap-9\">\n      <Slider\n        label=\"Temperature\"\n        defaultValue={0.7}\n        min={0}\n        max={2}\n        step={0.1}\n        largeStep={0.5}\n        formatValue={(value) => value.toFixed(1)}\n        marks={[\n          { value: 0, label: \"Precise\" },\n          { value: 1, label: \"Balanced\" },\n          { value: 2, label: \"Creative\" },\n        ]}\n      />\n      <Slider\n        label=\"Monthly budget\"\n        defaultValue={[200, 1200]}\n        min={0}\n        max={2000}\n        step={50}\n        largeStep={250}\n        minStepsBetweenValues={2}\n        format={{ style: \"currency\", currency: \"USD\", maximumFractionDigits: 0 }}\n        thumbLabels={[\"Minimum budget\", \"Maximum budget\"]}\n      />\n      <Slider label=\"Context window\" defaultValue={64} max={200} formatValue={(value) => `${value}k tokens`} disabled />\n    </div>\n  );\n}\n"
  }
}
