npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-counters

v1.3.1

Published

React native Minus(-) (Number) Plus(+) Component

Readme


What is it?

react-native-counters is a component that allows you to quickly implement counter operations in your React Native applications. It can be easily used in scenarios such as product quantity selection in e-commerce apps, number of guests in reservation systems, and more.

Features

  • Simple and fast integration
  • Fully customizable appearance
  • Min/Max value boundaries
  • Custom icon support (with react-native-vector-icons)
  • Configurable increment step size
  • onChangeBefore support for async operations
  • TypeScript support

Installation

npm

npm install react-native-counters --save

yarn

yarn add react-native-counters

Quick Start

Basic Usage

import Counter from "react-native-counters";

function App() {
  const handleChange = (number, type) => {
    // number: current count value
    // type: '+' or '-' (which button was pressed)
    console.log(`New value: ${number}, Action: ${type}`);
  };

  return (
    <Counter
      start={1}
      onChange={handleChange}
    />
  );
}

Usage with Class Components

import Counter from "react-native-counters";

class ShoppingCart extends React.Component {
  handleChange(number, type) {
    console.log(number, type); // 1, '+' or '-'
  }

  render() {
    return (
      <Counter
        start={1}
        onChange={this.handleChange.bind(this)}
      />
    );
  }
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | start | number | 0 | Initial count value | | min | number | 0 | Minimum selectable value | | max | number | 10 | Maximum selectable value | | increment | number | 1 | Increment/decrement amount per click | | minus | string | '-' | Minus button text (when icon is not used) | | plus | string | '+' | Plus button text (when icon is not used) | | minusIcon | function | null | Custom minus button icon | | plusIcon | function | null | Custom plus button icon | | buttonStyle | object | {} | Style object for buttons | | buttonTextStyle | object | {} | Style object for button text | | countTextStyle | object | {} | Style object for counter text | | formatFn | function | (count) => \${count}`| Function to format the displayed count | |onChange|function| - | Callback function called when value changes | |onChangeBefore|function|null` | Async function called before value changes |


Examples

1. Custom Styling

<Counter
  start={1}
  min={0}
  max={100}
  buttonStyle={{
    borderColor: '#3498db',
    borderWidth: 2,
    borderRadius: 25,
    width: 50,
    height: 50,
  }}
  buttonTextStyle={{
    color: '#3498db',
    fontSize: 20,
    fontWeight: 'bold',
  }}
  countTextStyle={{
    color: '#2c3e50',
    fontSize: 24,
    fontWeight: 'bold',
  }}
  onChange={(number, type) => console.log(number, type)}
/>

2. Text Buttons

<Counter
  start={1}
  plus="Add"
  minus="Remove"
  buttonStyle={{
    width: 80,
    backgroundColor: '#27ae60',
  }}
  buttonTextStyle={{
    color: '#fff',
  }}
/>

3. Custom Icons (react-native-vector-icons)

import Counter from "react-native-counters";
import Icon from 'react-native-vector-icons/MaterialIcons';

const MinusIcon = (isDisabled) => (
  <Icon
    name="remove-circle-outline"
    size={24}
    color={isDisabled ? '#ccc' : '#e74c3c'}
  />
);

const PlusIcon = (isDisabled) => (
  <Icon
    name="add-circle-outline"
    size={24}
    color={isDisabled ? '#ccc' : '#27ae60'}
  />
);

function ProductCounter() {
  return (
    <Counter
      start={1}
      min={1}
      max={99}
      minusIcon={MinusIcon}
      plusIcon={PlusIcon}
      onChange={(num) => console.log('Selected quantity:', num)}
    />
  );
}

4. Async Operations (onChangeBefore)

Use onChangeBefore for API calls, validation, or other async operations:

function AsyncCounter() {
  const handleBeforeChange = (next) => {
    // API call, validation, etc.
    fetch('/api/check-stock')
      .then(() => next()) // Apply change if successful
      .catch(() => alert('Insufficient stock!'));
  };

  return (
    <Counter
      start={1}
      onChangeBefore={handleBeforeChange}
      onChange={(num) => console.log('Updated:', num)}
    />
  );
}

5. Custom Increment Step

// Increment/decrement by 5 on each click
<Counter
  start={0}
  min={0}
  max={100}
  increment={5}
  onChange={(num) => console.log(num)}
/>

6. Formatted Count Display

Use formatFn to customize how the count is displayed:

// Display as percentage
<Counter
  start={0}
  max={100}
  formatFn={(count) => `${count}%`}
/>

// Display with currency
<Counter
  start={1}
  min={1}
  formatFn={(count) => `$${count}`}
/>

// Display with units
<Counter
  start={0}
  max={1000}
  formatFn={(count) => `${count} kg`}
/>

Documentation


Contributing

Contributions are welcome! To contribute:

  1. Fork this repository
  2. Create a new branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -am 'Added new feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Open a Pull Request

License

MIT License - see LICENSE file for details.


Author

Yasar ICLI


Support

If you find a bug or have suggestions, please report them on the Issues page.