Socket
Book a DemoInstallSign in
Socket

@iradics/react-sliderx

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iradics/react-sliderx

Easily customizable Slider component for React including a highly customizable selector functionality

1.0.7
latest
Source
npmnpm
Version published
Weekly downloads
217
11.86%
Maintainers
1
Weekly downloads
 
Created
Source

For full documentation, compatibility and examples visit sliderx.iradics.net

Getting started

Add SliderX your project:

npm install @iradics/react-sliderx
npm yarn add @iradics/react-sliderx

Import SliderX component(s) into your project:

import { SliderXClassic, SliderXSelector } from "@iradics/react-sliderx";

SliderXSelector

A slider component with predefined positions to select from multiple options

<SliderXSelector
  optionCount={5}
  colors={["#3cc9a3", "#2f8eb8", "#6617a3", "#dea002", "#e00000"]}
  className={"sliderXSelectorExample"}
  labels={["option 1", "option 2", "option 3", "option 4", "option 5"]}
  animationTime={100}
  defaultOptionIndex={2}
></SliderXSelector>

Props

NameTypeOptionalDefaultDescription
classNamestringtrueAdditional classname to add to the component
onChangefunctiontrueReturns the index of the selected option
colorsarraytrueArray of RGB,RGBA or HEX colors
optionCountnumberfalseNumber of options
defaultOptionIndexnumbertrue0Initially selected option. Invalid index is defaulted to the min or max index
labelsarraytrueArray of strings for labels. Pass "" for empty label. \n works for linebreaks
idstringtrueCustom ID for the direct slider (<input>) element which overwrites the default generated random ID
optionsEnumSliderXOptionstrueSlider behavior options. Use EnumSliderXOptions
indexnumbertrueAllows to externally control the selection. Invalid indexes are defaulted to min or max index.
animationTimenumbertrue0Time of full animation for selection change in microseconds. Use 0 for instant change.

SliderXClassic

Classic slider component with full range, implementing all the available easy styling possibilities.

export const SliderXClassicExample = () => {
  const [color, setcolor] = useState("rgba(102,23,163,1)");
  return (
    <div style={{ width: "75%", margin: "auto" }}>
      <SliderXClassic
        defaultValue={100}
        min={0}
        max={100}
        colors={[color]}
        className={"sliderXClassicExample"}
        onChange={(e) => {
          setcolor(`rgba(102,23,163,${e.target.value / 100})`);
        }}
      ></SliderXClassic>
    </div>
  );
};
.sliderXClassicExample {
  --sliderX-thumb-width: 1.5em;
  --sliderX-thumb-height: 3em;
  --sliderX-track-height: 2em;
  --sliderX-track-border-radius: 0.3em;
  --sliderX-thumb-border: 5px outset var(--sliderX-var-dynamic-color);
  --sliderX-thumb-color: white;
  --sliderX-thumb-color: white;
  --sliderX-track-box-shadow: 0px 0px 30px var(--sliderX-var-dynamic-color);
  --sliderX-thumb-box-shadow: 0px 0px 30px var(--sliderX-var-dynamic-color);
}

Props

NameTypeOptionalDefaultDescription
minnumbertrue0Minimum value
maxnumbertrue100Maximum value
stepnumbertrue1Specifies the number intervals
classNamestringtrueAdditional classname to add to the component
onChangefunctiontrueReturns the HTMLinput change event
colorsarraytrueArray of RGB,RGBA or HEX colors
defaultValuenumbertrueminSets the initial value of the slider
idstringtrueCustom ID for the direct slider (<input>) element which overwrites the default generated random ID
optionsEnumSliderXOptionstrueSlider behavior options. Use EnumSliderXOptions
valuenumbertrueControls the value of the slider externally.

SliderX Options

You can pass additional options which change the behaviour of the SliderX component.

Use EnumSliderXOptions to access these options.

<SliderXSelector
  ...
  options={EnumSliderXOptions.DynamicColorSampleRight | EnumSliderXOptions.ClickableLabels}
  ...
></SliderXSelector>
EnumSliderXOptions.SelectorClassicDescription
DynamicColorSampleRightxxIn case of the thumb being exactly between two colors, sample the right side color of the thumb instead of the left side
DisableCenteredOptionsxDisable the default centering of the options in SliderXSelector. This way the selectable options span from the very beginning of the slider to the very end
ClickableLabelsxMakes click on the labels change the slider position

Keywords

slider

FAQs

Package last updated on 07 Oct 2022

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.