Pallas UI
DocsComponents
Core Concepts
    • Introduction
    • Getting Started
    • Theming
    • Color Tokens
    • Spacing & Sizing
    • Layout Guide
    • AspectRatio
    • Box
    • Flex
    • Grid
    • Shapes
Previews
    • Accordion
    • Alert
    • Avatar
    • Badge
    • Breadcrumb
    • Button
    • Carousel
    • Checkbox
    • Combobox
    • Command
    • Date Picker
    • Form
    • Input
    • Input OTP
    • Label
    • MenuBar
    • Modal
    • Popover
    • Progress
    • Radio Group
    • Segmented
    • Select
    • Separator
    • Sheet
    • Sidebar
    • Skeleton
    • Slider
    • Spinner
    • Steps
    • Switch
    • Tabs
    • Textarea
    • Toast
    • Tooltip
    • Typography
  1. Components
  2. Slider

Slider

An input where the user selects a value from within a given range.

Installation

Install the following dependencies

npm install @radix-ui/react-slider

Copy and paste the following code into your project

'use client'
 
import * as SliderPrimitive from '@radix-ui/react-slider'
import { cx } from '@styled-system/css'
import { styled } from '@styled-system/jsx'
import { type SliderVariantProps, slider } from '@styled-system/recipes'
import * as React from 'react'
 
const BaseSlider = React.forwardRef<
  React.ComponentRef<typeof SliderPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> & SliderVariantProps
>(({ className, thumbSize, trackSize, ...props }, ref) => {
  const styles = slider({ thumbSize, trackSize })
 
  return (
    <SliderPrimitive.Root ref={ref} className={cx(styles.root, className)} {...props}>
      <SliderPrimitive.Track className={cx(styles.track, className)}>
        <SliderPrimitive.Range className={cx(styles.range, className)} />
      </SliderPrimitive.Track>
      <SliderPrimitive.Thumb className={cx(styles.thumb, className)} />
    </SliderPrimitive.Root>
  )
})
BaseSlider.displayName = SliderPrimitive.Root.displayName
 
export const Slider = styled(BaseSlider)

Update the import paths to match your project setup

Usage

import { Slider } from '@/components/ui/slider'
<Slider defaultValue={[33]} max={100} step={1} />

Examples

Default

With Custom width

With Custom Step

0%25%50%75%100%

Built with ❤️ by the carbonteq team. The source code is available on GitHub.

© 2025 Pallas UI. All rights reserved.