Socket
Socket
Sign inDemoInstall

@chakra-ui/number-input

Package Overview
Dependencies
8
Maintainers
3
Versions
486
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/number-input

An accessible numeric input alternative to


Version published
Weekly downloads
534K
increased by8.97%
Maintainers
3
Install size
1.80 MB
Created
Weekly downloads
 

Package description

What is @chakra-ui/number-input?

@chakra-ui/number-input is a component from the Chakra UI library that provides a customizable and accessible number input field. It allows users to input numerical values with ease and provides features such as increment and decrement buttons, value formatting, and validation.

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

Basic Number Input

This code demonstrates a basic number input with increment and decrement buttons. The input is restricted to values between 10 and 20, with a default value of 15.

import { NumberInput, NumberInputField, NumberInputStepper, NumberIncrementStepper, NumberDecrementStepper } from '@chakra-ui/react';

function BasicNumberInput() {
  return (
    <NumberInput defaultValue={15} min={10} max={20}>
      <NumberInputField />
      <NumberInputStepper>
        <NumberIncrementStepper />
        <NumberDecrementStepper />
      </NumberInputStepper>
    </NumberInput>
  );
}

Formatted Number Input

This code shows a number input with formatted values. The input allows for two decimal places and increments/decrements by 0.2.

import { NumberInput, NumberInputField } from '@chakra-ui/react';

function FormattedNumberInput() {
  return (
    <NumberInput defaultValue={15} precision={2} step={0.2}>
      <NumberInputField />
    </NumberInput>
  );
}

Controlled Number Input

This code demonstrates a controlled number input where the value is managed by React state. The input value is updated based on user interaction.

import { useState } from 'react';
import { NumberInput, NumberInputField, NumberInputStepper, NumberIncrementStepper, NumberDecrementStepper } from '@chakra-ui/react';

function ControlledNumberInput() {
  const [value, setValue] = useState(10);

  return (
    <NumberInput value={value} onChange={(valueString) => setValue(parseInt(valueString))}>
      <NumberInputField />
      <NumberInputStepper>
        <NumberIncrementStepper />
        <NumberDecrementStepper />
      </NumberInputStepper>
    </NumberInput>
  );
}

Other packages similar to @chakra-ui/number-input

Readme

Source

@chakra-ui/number-input

The NumberInput component is similar to the Input, but it has controls for incrementing or decrementing numeric values.

It follows the WAI-ARIA authoring practices for the Spinbutton widget.

Installation

yarn add @chakra-ui/number-input

# or

npm i @chakra-ui/number-input

Import components

import {
  NumberInput,
  NumberInputField,
  NumberInputStepper,
  NumberIncrementStepper,
  NumberDecrementStepper,
} from "@chakra-ui/react"

Usage

// TO DO

Keywords

FAQs

Last updated on 07 Apr 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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc