<Center w={300} h={100}><SliderdefaultValue={30}size="md"orientation="horizontal"isDisabled={false}isReversed={false}><SliderTrack><SliderFilledTrack /></SliderTrack><SliderThumb /></Slider></Center>
import { Slider } from '@gluestack-ui/themed';
export default () => (<Slider><SliderTrack><SliderFilledTrack /></SliderTrack><SliderThumb /></Slider>)
Prop | Type | Default | Description |
---|---|---|---|
onChange | (value: number) => void | - | Function called when the state of the Slider changes. |
isDisabled | bool | false | When true, this will disable Slider |
isReadOnly | boolean | false | To manually set read-only to the checkbox. |
sliderTrackHeight | number | 8 | To change the slider track height . |
defaultValue | number | - | To change the slider value . |
minValue | number | - | The slider's minimum value |
maxValue | number | - | The slider's maximum value. |
value | number | - | The slider's current value. |
step | number | - | The slider's step value. |
Sx Prop | Description |
---|---|
_thumb | Prop to style SliderThumb Component |
_track | Prop to style SliderTrack Component |
_filledTrack | Prop to style SliderFilledTrack Component |
Name | Value | Default |
---|---|---|
orientation | horizontal | vertical | horizontal |
isReversed | true | false | false |
size | sm | md | lg | md |
function App() {const [sliderValue, setSliderValue] = React.useState(45)const handleChange = (value) => {setSliderValue(value)}return (<Center w="$80"><SlidersliderTrackHeight={4}value={sliderValue}orientation="vertical"h={120}onChange={(value) => {handleChange(value)}}><SliderTrack><SliderFilledTrack /></SliderTrack><SliderThumb /></Slider></Center>)}
function App() {return (<VStack space="4xl"><Center w="$80"><Slider defaultValue={45} sliderTrackHeight={4}><SliderTrack><SliderFilledTrack bg="$emerald600" /></SliderTrack><SliderThumb bg="$emerald600" $active-outlineColor="$emerald500" /></Slider></Center><Center w="$80"><Slider defaultValue={45} sliderTrackHeight={4}><SliderTrack><SliderFilledTrack bg="$amber600" /></SliderTrack><SliderThumb bg="$amber600" $active-outlineColor="$amber500" /></Slider></Center><Center w="$80"><Slider defaultValue={45} sliderTrackHeight={4}><SliderTrack><SliderFilledTrack bg="$fuchsia600" /></SliderTrack><SliderThumb bg="$fuchsia600" $active-outlineColor="$fuchsia500" /></Slider></Center><Center w="$80"><Slider defaultValue={45} sliderTrackHeight={4}><SliderTrack><SliderFilledTrack bg="$cyan600" /></SliderTrack><SliderThumb bg="$cyan600" $active-outlineColor="$cyan500" /></Slider></Center></VStack>)}
function App() {const [sliderValue, setSliderValue] = React.useState(40)const handleChange = (value) => {setSliderValue(value)}return (<HStack space="lg"><Text size="md">$0</Text><Tooltipplacement={"top"}trigger={(triggerProps) => {return (<Center w="$80"><Sliderstep={5}sliderTrackHeight={4}value={sliderValue}maxValue={60}minValue={0}onChange={(v) => {handleChange(Math.floor(v))}}><SliderTrack><SliderFilledTrack /></SliderTrack><SliderThumb {...triggerProps} /></Slider></Center>)}}><TooltipContent><Text color="white">{"$" + sliderValue}</Text></TooltipContent></Tooltip><Text size="md">$60</Text></HStack>)}
function App() {const [sliderValue, setSliderValue] = React.useState(50)const handleChange = (value) => {setSliderValue(value)}return (<VStack space="lg"><Heading size="sm">Select the quantity</Heading><Center w="$72"><SlidersliderTrackHeight={5}size="md"value={sliderValue}onChange={(value) => {handleChange(value)}}><SliderTrack><SliderFilledTrack /></SliderTrack><SliderThumb /></Slider></Center><Text size="sm">Slide the knob to select the number of products</Text></VStack>)}
function App() {const [sliderValue, setSliderValue] = React.useState(55)const handleChange = (value) => {setSliderValue(value)}return (<VStack space="lg"><Text size="lg">Brightness</Text><Center w="$72"><SlidersliderTrackHeight={6}size="lg"value={sliderValue}onChange={(value) => {handleChange(value)}}><SliderTrack><SliderFilledTrack bg="$amber600" /></SliderTrack><SliderThumb bg="$amber600" p="$1" $active-outlineColor="$amber500"><Icon as={LightbulbIcon} color="white" size="sm" /></SliderThumb></Slider></Center></VStack>)}
function App() {const [sliderValue, setSliderValue] = React.useState(40)const [onChangeEndValue, setOnChangeEndValue] = React.useState(40)const handleChange = (value) => {setSliderValue(value)}return (<VStack space="2xl"><Box><Text textAlign="center">current sliderValue - {sliderValue}</Text><Text textAlign="center">onChangeEndValue - {onChangeEndValue}</Text></Box><HStack space="lg"><Volume /><Center w="$80"><SlidersliderTrackHeight={4}value={sliderValue}onChange={(v) => {handleChange(Math.floor(v))}}onChangeEnd={(v) => {v && setOnChangeEndValue(Math.floor(v))}}><SliderTrack><SliderFilledTrack /></SliderTrack><SliderThumb /></Slider></Center><Volume2Icon /></HStack></VStack>)}