Home / File/ slider.tsx — ui Source File

slider.tsx — ui Source File

Architecture documentation for slider.tsx, a tsx file in the ui codebase. 3 imports, 0 dependents.

File tsx ComponentRegistry ChartRegistry 3 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  bed8b1a4_2e54_6e38_526f_10b9c94f7b0a["slider.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  bed8b1a4_2e54_6e38_526f_10b9c94f7b0a --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  9c463da6_747b_38dc_586b_cbb4873070b1["radix-ui"]
  bed8b1a4_2e54_6e38_526f_10b9c94f7b0a --> 9c463da6_747b_38dc_586b_cbb4873070b1
  79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"]
  bed8b1a4_2e54_6e38_526f_10b9c94f7b0a --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81
  style bed8b1a4_2e54_6e38_526f_10b9c94f7b0a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import { Slider as SliderPrimitive } from "radix-ui"

import { cn } from "@/lib/utils"

function Slider({
  className,
  defaultValue,
  value,
  min = 0,
  max = 100,
  ...props
}: React.ComponentProps<typeof SliderPrimitive.Root>) {
  const _values = React.useMemo(
    () =>
      Array.isArray(value)
        ? value
        : Array.isArray(defaultValue)
          ? defaultValue
          : [min, max],
    [value, defaultValue, min, max]
  )

  return (
    <SliderPrimitive.Root
      data-slot="slider"
      defaultValue={defaultValue}
      value={value}
      min={min}
      max={max}
      className={cn(
        "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
        className
      )}
      {...props}
    >
      <SliderPrimitive.Track
        data-slot="slider-track"
        className={cn(
          "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
        )}
      >
        <SliderPrimitive.Range
          data-slot="slider-range"
          className={cn(
            "bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
          )}
        />
      </SliderPrimitive.Track>
      {Array.from({ length: _values.length }, (_, index) => (
        <SliderPrimitive.Thumb
          data-slot="slider-thumb"
          key={index}
          className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
        />
      ))}
    </SliderPrimitive.Root>
  )
}

export { Slider }

Subdomains

Functions

Dependencies

  • radix-ui
  • react
  • utils

Frequently Asked Questions

What does slider.tsx do?
slider.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in slider.tsx?
slider.tsx defines 1 function(s): Slider.
What does slider.tsx depend on?
slider.tsx imports 3 module(s): radix-ui, react, utils.
Where is slider.tsx in the architecture?
slider.tsx is located at apps/v4/registry/new-york-v4/ui/slider.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: apps/v4/registry/new-york-v4/ui).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free