The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(ui): update Slider component (#41183)
Francesco Sansalvadore20df38856ecd
diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsxindex 94efd8a5bfd..d5b4bf103ba 100644--- a/apps/design-system/__registry__/index.tsx+++ b/apps/design-system/__registry__/index.tsx@@ -1303,6 +1303,17 @@ export const Index: Record<string, any> = {subcategory: "undefined",chunks: []},+ "slider-minMax-range": {+ name: "slider-minMax-range",+ type: "components:example",+ registryDependencies: ["slider"],+ component: React.lazy(() => import("@/registry/default/example/slider-minMax-range")),+ source: "",+ files: ["registry/default/example/slider-minMax-range.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },"sonner-demo": {name: "sonner-demo",type: "components:example",diff --git a/apps/design-system/content/docs/components/slider.mdx b/apps/design-system/content/docs/components/slider.mdxindex e2f1120559c..6f22de237df 100644--- a/apps/design-system/content/docs/components/slider.mdx+++ b/apps/design-system/content/docs/components/slider.mdx@@ -59,3 +59,9 @@ import { Slider } from '@/components/ui/slider'```tsx<Slider defaultValue={[33]} max={100} step={1} />```++## Examples++### Min and Max Range++<ComponentPreview name="slider-minMax-range" peekCode wide />diff --git a/apps/design-system/registry/default/example/slider-minMax-range.tsx b/apps/design-system/registry/default/example/slider-minMax-range.tsxnew file mode 100644index 00000000000..01f280013b0--- /dev/null+++ b/apps/design-system/registry/default/example/slider-minMax-range.tsx@@ -0,0 +1,17 @@+import { cn } from '@/lib/utils'+import { Slider } from 'ui'++type SliderProps = React.ComponentProps<typeof Slider>++export default function SliderDemo({ className, ...props }: SliderProps) {+ return (+ <Slider+ defaultValue={[20, 80]}+ min={0}+ max={100}+ step={1}+ className={cn('w-[60%]', className)}+ {...props}+ />+ )+}diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.tsindex bc1ee485cb5..b36700bca15 100644--- a/apps/design-system/registry/examples.ts+++ b/apps/design-system/registry/examples.ts@@ -761,6 +761,12 @@ export const examples: Registry = [registryDependencies: ['slider'],files: ['example/slider-demo.tsx'],},+ {+ name: 'slider-minMax-range',+ type: 'components:example',+ registryDependencies: ['slider'],+ files: ['example/slider-minMax-range.tsx'],+ },{name: 'sonner-demo',type: 'components:example',diff --git a/packages/ui/src/components/shadcn/ui/slider.tsx b/packages/ui/src/components/shadcn/ui/slider.tsxindex ea9ac682742..1beace690ad 100644--- a/packages/ui/src/components/shadcn/ui/slider.tsx+++ b/packages/ui/src/components/shadcn/ui/slider.tsx@@ -5,21 +5,47 @@ import * as React from 'react'import { cn } from '../../../lib/utils/cn'-const Slider = React.forwardRef<- React.ElementRef<typeof SliderPrimitive.Root>,- React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>->(({ className, ...props }, ref) => (- <SliderPrimitive.Root- ref={ref}- className={cn('relative flex w-full touch-none select-none items-center', className)}- {...props}- >- <SliderPrimitive.Track className="relative h-1 w-full grow overflow-hidden rounded-full bg-surface-300">- <SliderPrimitive.Range className="absolute h-full bg-foreground-muted" />- </SliderPrimitive.Track>- <SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-background-surface-100 bg-foreground ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />- </SliderPrimitive.Root>-))-Slider.displayName = SliderPrimitive.Root.displayName+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 select-none items-center', className)}+ {...props}+ >+ <SliderPrimitive.Track+ data-slot="slider-track"+ className="relative h-1 w-full grow overflow-hidden rounded-full bg-surface-300"+ >+ <SliderPrimitive.Range+ data-slot="slider-range"+ className="absolute h-full bg-foreground-muted"+ />+ </SliderPrimitive.Track>+ {Array.from({ length: _values.length }, (_, index) => (+ <SliderPrimitive.Thumb+ data-slot="slider-thumb"+ key={index}+ className="block h-5 w-5 rounded-full border-2 border-background-surface-100 bg-foreground ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"+ />+ ))}+ </SliderPrimitive.Root>+ )+}export { Slider }