AlphaSlider
AlphaSlider
is a component used to allow the user to select color transparency.
<AlphaSlider.Root color="#775999" defaultValue={0.5} />
Usage
import { AlphaSlider } from "@yamada-ui/react"
import { AlphaSlider } from "@/components/ui"
import { AlphaSlider } from "@workspaces/ui"
<AlphaSlider.Root />
Change Size
<VStack>
<For each={["sm", "md", "lg"]}>
{(size, index) => (
<AlphaSlider.Root
key={index}
size={size}
color="#775999"
defaultValue={0.5}
/>
)}
</For>
</VStack>
Set Default Value
To set a default value, set a value to defaultValue
.
<AlphaSlider.Root color="#775999" defaultValue={0.7} />
Set Minimum and Maximum Values
To set minimum and maximum values, set numbers to min
or max
.
<AlphaSlider.Root color="#775999" defaultValue={0.5} min={0.25} max={0.75} />
Change Orientation
To change the orientation, set orientation
to "vertical"
or "horizontal"
. The default is "vertical"
.
<AlphaSlider.Root
color="#775999"
defaultValue={0.5}
orientation="vertical"
h="xs"
/>
Change Shape
<VStack>
<For each={["circle", "rounded", "square"]}>
{(shape, index) => (
<AlphaSlider.Root
key={index}
color="#775999"
defaultValue={0.5}
shape={shape}
/>
)}
</For>
</VStack>
Set Step Value
To set the step value, set a value to step
.
<AlphaSlider.Root color="#775999" defaultValue={0.5} step={0.1} />
Disable
To disable, set disabled
to true
.
<AlphaSlider.Root color="#775999" defaultValue={0.5} disabled />
Read-Only
To make read-only, set readOnly
to true
.
<AlphaSlider.Root color="#775999" defaultValue={0.5} readOnly />
Display Tooltip
const [value, setValue] = useState(0.5)
return (
<AlphaSlider.Root color="#775999" value={value} onChange={setValue}>
<AlphaSlider.Track>
<Tooltip content={value}>
<AlphaSlider.Thumb />
</Tooltip>
<AlphaSlider.Overlay />
</AlphaSlider.Track>
</AlphaSlider.Root>
)
"use client"
to the top of the file.Handle Start and End Change Events
To handle start and end change events, use onChangeStart
and onChangeEnd
.
Value: 0.5, Start Value: 0.5, End Value: 0.5
const [value, onChange] = useState(0.5)
const [startValue, onChangeStart] = useState(0.5)
const [endValue, onChangeEnd] = useState(0.5)
return (
<VStack>
<Text>
Value: {value}, Start Value: {startValue}, End Value: {endValue}
</Text>
<AlphaSlider.Root
color="#775999"
value={value}
onChange={onChange}
onChangeStart={onChangeStart}
onChangeEnd={onChangeEnd}
/>
</VStack>
)
"use client"
to the top of the file.Control
const [value, setValue] = useState(0.5)
return <AlphaSlider.Root color="#775999" 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.