New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-proportion-slider

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-proportion-slider

> **Note:** This package is currently in beta.

latest
npmnpm
Version
0.9.5
Version published
Weekly downloads
1
Maintainers
0
Weekly downloads
 
Created
Source

React Proportion Slider

Note: This package is currently in beta.

A React component that allows users to adjust the proportion of two elements using a slider.

Installation

npm install react-proportion-slider
yarn add react-proportion-slider

Usage

function App() {
  const [proportions, setProportions] = React.useState<[number, number]>([
    50, 50,
  ]);
  return (
    <div>
      <ProportionSlider
        value={proportions}
        width={500}
        proportions={[
          {
            label: "Skill",
            backgroundColor: "#31332E",
          },
          {
            label: "3.7 Sonnet",
            backgroundColor: "#5f625C",
          },
        ]}
        onChange={(change) => {
          setProportions(change);
        }}
        knobOptions={{
          width: 5,
          gap: 5,
          backgroundColor: "#EC1308",
        }}
        height={50}
      />
    </div>
  );
}

Props

Prop NameTypeRequiredDescription
value[number, number]YesCurrent values of the two proportions [left, right]
proportions[ProportionDetail, ProportionDetail]YesDetails for the two proportions [left, right]
onChange(values: [number, number]) => voidNoCallback when values change
knobOptionsSliderKnobOptionsNoAppearance of the slider knob
heightnumberNoHeight of the slider in pixels
widthnumberNoWidth of the slider in pixels
disabledbooleanNoWhether the slider is disabled
classNamestringNoCustom class name for the slider container
styleReact.CSSPropertiesNoCustom styles for the slider container
ariaLabelstringNoAccessibility label for the slider

ProportionDetail

PropertyTypeRequiredDescription
labelstringYesCustom label to display
backgroundColorstringNoColor of the proportion segment
dataanyNoOptional data to associate with this proportion
ariaLabelstringNoAccessibility label for this proportion

SliderKnobOptions

PropertyTypeRequiredDescription
widthnumberNoWidth of the slider knob in pixels
gapnumberNoGap around the slider knob in pixels
backgroundColorstringNoColor of the slider knob
classNamestringNoCustom class name for the knob
styleReact.CSSPropertiesNoCustom styles for the knob

Future Features

  • Make it possible to adjust the proportion of more than two elements
  • Add more customization options

React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

  • @vitejs/plugin-react uses Babel for Fast Refresh
  • @vitejs/plugin-react-swc uses SWC for Fast Refresh

Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

export default tseslint.config({
  extends: [
    // Remove ...tseslint.configs.recommended and replace with this
    ...tseslint.configs.recommendedTypeChecked,
    // Alternatively, use this for stricter rules
    ...tseslint.configs.strictTypeChecked,
    // Optionally, add this for stylistic rules
    ...tseslint.configs.stylisticTypeChecked,
  ],
  languageOptions: {
    // other options...
    parserOptions: {
      project: ["./tsconfig.node.json", "./tsconfig.app.json"],
      tsconfigRootDir: import.meta.dirname,
    },
  },
});

You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:

// eslint.config.js
import reactX from "eslint-plugin-react-x";
import reactDom from "eslint-plugin-react-dom";

export default tseslint.config({
  plugins: {
    // Add the react-x and react-dom plugins
    "react-x": reactX,
    "react-dom": reactDom,
  },
  rules: {
    // other rules...
    // Enable its recommended typescript rules
    ...reactX.configs["recommended-typescript"].rules,
    ...reactDom.configs.recommended.rules,
  },
});

FAQs

Package last updated on 18 Mar 2025

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