HueSlider
HueSlider
is a component used to allow the user to select a color hue.
<HueSlider.Root defaultValue={180} />
Usage
import { HueSlider } from "@yamada-ui/react"
import { HueSlider } from "@/components/ui"
import { HueSlider } from "@workspaces/ui"
<HueSlider.Root />
Change Size
<VStack>
<For each={["sm", "md", "lg"]}>
{(size, index) => (
<HueSlider.Root key={index} size={size} defaultValue={180} />
)}
</For>
</VStack>
Set Default Value
To set a default value, set a value to defaultValue
.
<HueSlider.Root defaultValue={270} />
Set Min and Max Values
To set minimum and maximum values, set numbers to min
or max
.
<HueSlider.Root defaultValue={300} min={270} max={360} />
Change Orientation
To change the orientation, set orientation
to "vertical"
or "horizontal"
. By default, "horizontal"
is set.
<HueSlider.Root defaultValue={180} orientation="vertical" h="xs" />
Change Shape
<VStack>
<For each={["circle", "rounded", "square"]}>
{(shape, index) => (
<HueSlider.Root key={index} defaultValue={180} shape={shape} />
)}
</For>
</VStack>
Set Step Value
To set a step value, set a value to step
.
<HueSlider.Root defaultValue={180} step={10} />
Disable
To disable, set disabled
to true
.
<HueSlider.Root defaultValue={180} disabled />
Read-Only
To make read-only, set readOnly
to true
.
<HueSlider.Root defaultValue={180} readOnly />
Display Tooltip
const [value, setValue] = useState(50)
return (
<HueSlider.Root value={value} onChange={setValue}>
<HueSlider.Track>
<Tooltip content={value}>
<HueSlider.Thumb />
</Tooltip>
<HueSlider.Overlay />
</HueSlider.Track>
</HueSlider.Root>
)
"use client"
to the top of the file.Handle Start and End Events
To handle start and end events, use onChangeStart
or onChangeEnd
.
Value: 180, Start Value: 180, End Value: 180
const [value, onChange] = useState(180)
const [startValue, onChangeStart] = useState(180)
const [endValue, onChangeEnd] = useState(180)
return (
<VStack>
<Text>
Value: {value}, Start Value: {startValue}, End Value: {endValue}
</Text>
<HueSlider.Root
value={value}
onChange={onChange}
onChangeStart={onChangeStart}
onChangeEnd={onChangeEnd}
/>
</VStack>
)
"use client"
to the top of the file.Control
const [value, setValue] = useState(180)
return <HueSlider.Root value={value} onChange={setValue} />
"use client"
to the top of the file.Props
Accessibility
Currently, this section is being updated due to the migration of v2.