HextaUI

Slider: With icons

Place icons beside the slider in a flex row. The slider takes the remaining width.

import { IconVolume, IconVolume3 } from "@tabler/icons-react"

import { Slider } from "@/components/ui/slider"

export function SliderIcons() {
  return (
    <div className="flex w-full max-w-xs items-center gap-3 text-muted-foreground">
      <IconVolume3 className="size-4 shrink-0" aria-hidden />
      <Slider defaultValue={50} aria-label="Volume" />
      <IconVolume className="size-4 shrink-0" aria-hidden />
    </div>
  )
}

This adds the example as components/examples/slider/icons.tsx, together with the Slider component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/slider-icons.json

To add only the component, follow the Slider installation.

Props in this example

The Slider props this example sets, from the API reference.

PropTypeDefault
defaultValue
number | number[]–
aria-labelNames the thumbs.
string–

Every prop is in the Slider API reference.

See them all, with keyboard support and accessibility notes, on the Slider page.