Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chakra-ui/slider

Package Overview
Dependencies
Maintainers
2
Versions
511
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/slider

Accessible slider component for React that implements

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
495K
increased by3.68%
Maintainers
2
Weekly downloads
 
Created

What is @chakra-ui/slider?

@chakra-ui/slider is a component library for creating highly customizable and accessible sliders in React applications. It is part of the Chakra UI library, which provides a set of accessible, reusable, and composable React components.

What are @chakra-ui/slider's main functionalities?

Basic Slider

This code demonstrates a basic slider with a default value of 30, a minimum value of 0, a maximum value of 100, and a step value of 5.

```jsx
import { Slider, SliderTrack, SliderFilledTrack, SliderThumb } from '@chakra-ui/react';

function BasicSlider() {
  return (
    <Slider defaultValue={30} min={0} max={100} step={5}>
      <SliderTrack>
        <SliderFilledTrack />
      </SliderTrack>
      <SliderThumb />
    </Slider>
  );
}
```

Vertical Slider

This code demonstrates a vertical slider with a default value of 30, a minimum value of 0, a maximum value of 100, and a step value of 5. The height of the slider is set to 200px.

```jsx
import { Slider, SliderTrack, SliderFilledTrack, SliderThumb } from '@chakra-ui/react';

function VerticalSlider() {
  return (
    <Slider orientation='vertical' defaultValue={30} min={0} max={100} step={5} height='200px'>
      <SliderTrack>
        <SliderFilledTrack />
      </SliderTrack>
      <SliderThumb />
    </Slider>
  );
}
```

Slider with Tooltip

This code demonstrates a slider with a tooltip that shows the current value of the slider. The tooltip appears when the user hovers over the slider thumb.

```jsx
import { Slider, SliderTrack, SliderFilledTrack, SliderThumb, Tooltip } from '@chakra-ui/react';
import { useState } from 'react';

function SliderWithTooltip() {
  const [sliderValue, setSliderValue] = useState(30);
  const [showTooltip, setShowTooltip] = useState(false);

  return (
    <Slider
      id='slider'
      defaultValue={30}
      min={0}
      max={100}
      step={5}
      onChange={(v) => setSliderValue(v)}
      onMouseEnter={() => setShowTooltip(true)}
      onMouseLeave={() => setShowTooltip(false)}
    >
      <SliderTrack>
        <SliderFilledTrack />
      </SliderTrack>
      <Tooltip
        hasArrow
        bg='teal.500'
        color='white'
        placement='top'
        isOpen={showTooltip}
        label={`${sliderValue}%`}
      >
        <SliderThumb />
      </Tooltip>
    </Slider>
  );
}
```

Other packages similar to @chakra-ui/slider

Keywords

FAQs

Package last updated on 18 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc