# Number input (UI SDK): Invalid

> `invalid` marks the field and sets `aria-invalid` on the input, for checks of your own like stock.

Canonical: https://hextaui.com/docs/ui-sdk-number-input/examples/invalid

Component docs: https://hextaui.com/docs/ui-sdk-number-input

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/ui-sdk-number-input-invalid.json
```

This adds `components/examples/ui-sdk-number-input/invalid.tsx` with the Number input component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/ui-sdk-number-input/invalid.tsx"
"use client"

import * as React from "react"

import { Label } from "@/components/ui/label"
import {
  NumberInput,
  NumberInputControl,
  NumberInputDecrement,
  NumberInputGroup,
  NumberInputIncrement,
} from "@/components/ui/ui-sdk-number-input"

const stock = 12

function UiSdkNumberInputInvalid() {
  const [quantity, setQuantity] = React.useState<number | null>(14)
  const invalid = quantity !== null && quantity > stock

  return (
    <div className="flex w-full max-w-40 flex-col gap-2">
      <Label htmlFor="order-quantity">Quantity</Label>
      <NumberInput
        defaultValue={14}
        min={1}
        invalid={invalid}
        onValueChange={(value) => setQuantity(value)}
      >
        <NumberInputGroup>
          <NumberInputDecrement />
          <NumberInputControl
            id="order-quantity"
            aria-describedby="order-quantity-message"
          />
          <NumberInputIncrement />
        </NumberInputGroup>
      </NumberInput>
      <p
        id="order-quantity-message"
        className={
          invalid
            ? "m-0 text-xs text-destructive"
            : "m-0 text-xs text-muted-foreground"
        }
      >
        {invalid ? `Only ${stock} left in stock.` : `${stock} in stock.`}
      </p>
    </div>
  )
}

export { UiSdkNumberInputInvalid }
```

## Props in this example

### NumberInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `defaultValue` | `number \| null` | – |  |
| `onValueChange` | `(value: number \| null, details) => void` | – |  |
| `min` | `number` | – |  |
| `invalid` | `boolean` | `false` |  |

### NumberInputControl

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `id` | `string` | – |  |

## More Number input examples

- [Min and max](https://hextaui.com/docs/ui-sdk-number-input/examples/min-max)
- [Step](https://hextaui.com/docs/ui-sdk-number-input/examples/step)
- [Currency, percent and units](https://hextaui.com/docs/ui-sdk-number-input/examples/format)
- [Locale](https://hextaui.com/docs/ui-sdk-number-input/examples/locale)
- [Scrub](https://hextaui.com/docs/ui-sdk-number-input/examples/scrub)
- [Mouse wheel](https://hextaui.com/docs/ui-sdk-number-input/examples/wheel)
- [Controlled](https://hextaui.com/docs/ui-sdk-number-input/examples/controlled)
- [Form](https://hextaui.com/docs/ui-sdk-number-input/examples/form)
- [Disabled](https://hextaui.com/docs/ui-sdk-number-input/examples/disabled)
- [Read-only](https://hextaui.com/docs/ui-sdk-number-input/examples/read-only)
- [Right to left](https://hextaui.com/docs/ui-sdk-number-input/examples/rtl)
