Socket
Socket
Sign inDemoInstall

@anatoliygatt/numeric-stepper

Package Overview
Dependencies
76
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @anatoliygatt/numeric-stepper

A numeric stepper component for React.


Version published
Weekly downloads
3
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

1.0.9 (2023-03-10)

Bug Fixes

  • deps: bump minimist from 1.2.5 to 1.2.7 (337a648)

Readme

Source

numeric-stepper Demo

numeric-stepper

A numeric stepper component for React. Inspired by Ehsan Rahimi's Tally Counter Micro-Interaction Dribbble shot.


GitHub CI Workflow Status NPM Version License


📖 Table of Contents

🚀 Getting Started

🐇 Jump Start

npm install @anatoliygatt/numeric-stepper @emotion/react @emotion/styled framer-motion
import { useState } from 'react';
import { NumericStepper } from '@anatoliygatt/numeric-stepper';

function Example() {
  const INITIAL_VALUE = 20;
  const [value, setValue] = useState(INITIAL_VALUE);
  return (
    <NumericStepper
      minimumValue={10}
      maximumValue={100}
      stepValue={10}
      initialValue={INITIAL_VALUE}
      size="lg"
      inactiveTrackColor="#fed7aa"
      activeTrackColor="#fddec0"
      activeButtonColor="#ffedd5"
      inactiveIconColor="#fb923c"
      hoverIconColor="#ea580c"
      activeIconColor="#9a3412"
      disabledIconColor="#fdba74"
      thumbColor="#f97316"
      thumbShadowAnimationOnTrackHoverEnabled={false}
      focusRingColor="#fff7ed"
      onChange={(value) => {
        setValue(value);
      }}
    />
  );
}

💻 Live Demo

Open in CodeSandbox

⚙️ Configuration

NumericStepper supports the following props:

PropTypeDefault valueDescription
minimumValuenumber0The minimum value.
maximumValuenumberNumber.MAX_SAFE_INTEGERThe maximum value.
stepValuenumber1The step increment value.
initialValuenumberminimumValueThe initial value.
onChangeFunctionundefinedThe callback invoked when the value changes.
sizestringsmThe size of the numeric stepper. There are 3 available sizes:
  • sm — 185x74px
  • md — 277.5x111px
  • lg — 370x148px
inactiveTrackColorstring#2b2b2bThe color of the track while the thumb is not being horizontally dragged.
activeTrackColorstring#1f1f1fThe color of the track while the thumb is being horizontally dragged and is at the maximum trackable distance from the track's center.
hoverButtonColorstringtransparentThe color of the decrement/increment button in a hover state.
activeButtonColorstring#ecececThe color of the decrement/increment button in an active state.
inactiveIconColorstring#858585The color of the decrement/increment button icon in an inactive state.
hoverIconColorstring#ffffffThe color of the decrement/increment button icon in a hover state.
activeIconColorstring#000000The color of the decrement/increment button icon in an active state.
disabledIconColorstring#383838The color of the decrement/increment button icon in a disabled state.
thumbColorstring#444444The color of the thumb.
thumbLabelColorstring#ffffffThe color of the thumb's label.
thumbShadowAnimation
OnTrackHoverEnabled
booleantrueIf true, the thumb's shadow will animate when hovering over the track.
focusRingColorstring#ecececThe color of the focus ring of the interactive elements.

In order to customise the thumb's font settings, we can use CSS, like so:

[data-testid='numeric-stepper-thumb'] {
  font-family: 'Times New Roman', Times, serif;
  font-style: italic;
  font-weight: 800;
}

♿️ Accessibility

In order to comply with the web accessibility standards, we must make use of the decrementButtonAriaLabel and incrementButtonAriaLabel props, like so:

function AccessibleExample() {
  return (
    <NumericStepper
      decrementButtonAriaLabel="Decrement"
      incrementButtonAriaLabel="Increment"
    />
  );
}

Also, we can use a thumbAriaLabel prop to provide a description for the value rendered inside a thumb, like so:

function EnhancedThumbAccessibilityExample() {
  const [value, setValue] = useState(0);
  return (
    <NumericStepper
      thumbAriaLabel={`${value} items`}
      onChange={(value) => {
        setValue(value);
      }}
    />
  );
}

👨🏼‍⚖️ License

MIT

Keywords

FAQs

Last updated on 10 Mar 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc