🎨
Valence
🎨
Valence
  • Overview
    • 👋Welcome to Valence
    • 🏄‍♂️Getting started
  • Core Concepts
    • Responsiveness
    • Color
      • List of colors
      • Color types
    • Polymorphism
  • Valence Core
    • 🏃‍♂️Fundamentals
      • 🎬The ValenceProvider
      • ✍️Using custom fonts
    • 🧱Components
      • 🔘Buttons
        • Button with icon
        • Grid Button
        • Text button
        • Icon button
        • Multi-part button
        • Unstyled button
        • Primitive button
      • ⌨️Inputs
        • Color Picker
        • Text input
        • Text area
        • Number input
        • Select input
        • Switch
        • Slider
        • Range slider
        • Pill selector
        • Input container
        • Dropdown container
      • 🖥️Display
        • Accordion
        • Alert
        • Color Swatch
        • Icon
        • Image
        • Avatar
        • Avatar Group
        • Loader
        • Pill
        • Spoiler
        • Stepper
        • Text
        • Title
      • 🧩Layout
        • App Container
        • Card
        • Flex
          • Flex Center
          • Styled Flex
        • Floating Toolbar
        • Grid
        • Header
        • Overflow Container
        • Space
      • 🗺️Navigation
        • App Nav
      • 🔼Overlays
        • Modal
        • Tooltip
        • Modal background
        • 📰Sheets
          • Bottom Sheet
          • Dynamic Sheet
          • Side Sheet
    • 🪝Hooks
      • UseColorScheme
      • UseColors
      • UseControlledList
      • UseDetectKeyDown
      • UseDisclosure
      • UseFloating
      • UseTooltip
      • UseBreakpoint
      • UseResponsiveProps
    • 🤚Generics
      • Generic button props
      • Generic input props
      • Generic Sheet Props
  • Valence Plugins
    • 🎠Valence Carousel
      • Carousel Child Props
  • Valence Utils
    • ✋Generics
      • Clickable
      • Events
      • Global
      • Grid
      • Layout
      • Overlay
      • Polymorphic
    • 🧜‍♀️Polymorphism
      • Polymorphic Button
      • Polymorphic Layout
      • Polymorphic Text
  • Update Notes
    • 3.0.0
    • 2.7.0
    • 2.6.0
    • 2.5.0
    • 2.4.0
    • 2.3.0
    • 2.2.0
    • 2.1.0
    • 2.0.0
Powered by GitBook
On this page
  • Usage
  • Min, max & step
  • Hiding or modifying controls
  • Props

Was this helpful?

Edit on GitHub
  1. Valence Core
  2. Components
  3. Inputs

Number input

Last updated: 2.0.0 (18/01/2024)

Usage

import { NumberInput } from "@valence-ui/core";

function MyComponent() { 
    const [value, setValue] = React.useState(0);

    return ( 
        <NumberInput
            value={value}
            setValue={setValue}
        />
    )
}

Min, max & step

import { NumberInput } from "@valence-ui/core";

function MyComponent() { 
    const [value, setValue] = React.useState(4);

    return ( 
        <NumberInput
            value={value}
            setValue={setValue}
            
            min={0}
            max={10}
            step={2}
        />
    )
}

Hiding or modifying controls

The controls can be entirely hidden using the showControls prop:

import { NumberInput } from "@valence-ui/core";

function MyComponent() { 
    const [value, setValue] = React.useState(0);

    return ( 
        <NumberInput
            value={value}
            setValue={setValue}
            
            showControls={false}
        />
    )
}

Additionally, the icons used can be overridden by the controlIcons prop:

import { NumberInput } from "@valence-ui/core";
import { IconMinus, IconPlus } from "@tabler/icons-react";

function MyComponent() { 
    const [value, setValue] = React.useState(0);

    return ( 
        <NumberInput
            value={value}
            setValue={setValue}
            
            controlIcons={{
                up: <IconPlus />,
                down: <IconMinus />
            }}
        />
    )
}

Props

Property
Type
Description

icon

ReactNode

An icon to display at the left side of this input.

placeholder

string

Text that appears in this input when it has no value.

min

number

The minimum value of this input.

max

number

The maximum value of this input.

step

number

The step value of this input. Defaults to 1.

showControls

boolean

Whether the stepper controls are shown.

controlIcons

{ up?: ReactNode, down?: ReactNode }

Sets custom icons for the stepper control buttons.

grow

boolean

Shorthand for flex-grow = 1.

inputStyle

CSSProperties

Optional styles to apply to the input component.

PreviousText areaNextSelect input

Last updated 1 year ago

Was this helpful?

Extends and .

🧱
⌨️
GenericInputProps<number>
GenericTextInputEventProps