---
title: "IP Address Input"
description: "A field for an IPv4 address. It takes only digits and dots, adds a dot after 3 digits, and checks that each of the 4 parts is 0 to 255."
url: https://gelatinui.com/components/ip-address-input
markdown_url: https://gelatinui.com/components/ip-address-input.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/ip-address-input"
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# IP Address Input

> A field for an IPv4 address. It takes only digits and dots, adds a dot after 3 digits, and checks that each of the 4 parts is 0 to 255.

Page: https://gelatinui.com/components/ip-address-input

## When to use it

Best for: One IPv4 address in a settings or security form.

- Use it for one IPv4 address, such as a server, a router, or a subnet mask.
- Check it in a `Field` with `ipv4().valid` from `lib/masks`.

## When not to use it

- For an IPv6 address or a range with a slash, use a [Input](https://gelatinui.com/components/input.md).
- For another fixed format, use a [Masked Input](https://gelatinui.com/components/masked-input.md).

## Notes for agents

- It takes IPv4 only, with no range (`/24`). `valid` needs four parts of 0 to 255 with no leading zeros.
- The parts are `IpAddressInputIcon` and `IpAddressInputControl`. With no children it renders both.
- It is always left to right, also in a right-to-left page.

## Anatomy

```text
IpAddressInput
├─ IpAddressInputIcon (0..n)
└─ IpAddressInputControl (0..n)
```

## API reference

### IpAddressInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `rounded` | `"default" \| "full"` | "default" |  |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` | "default" |  |
| `variant` | `"dashed" \| "default"` |  |  |
| `disabled` | `boolean` | false | Turns the control off; the frame fades to 50% with it (the Base UI name). |
| `readOnly` | `boolean` | false | The address shows and can be copied, but not changed (the Base UI name). |
| `value` | `string` |  | The shown address (controlled). |
| `defaultValue` | `string` | "" | The first shown address (uncontrolled). |
| `onValueChange` | `function` |  | Runs on every change with the text and the checks (four parts, each 0–255). |

### IpAddressInputIcon

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### IpAddressInputControl

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `guide` | `boolean` |  | The ghost guide of the slots still to fill, while the input has focus. Default `true`. |
| `rawName` | `string` |  | Also submit the raw value under this name (a hidden input), next to the shown one. |
| `rejectFeedback` | `boolean` |  | Nudge the field 2px when the mask rejects a key. Default `true`. |
| `onReject` | `function` |  | Runs when the mask rejects a key (a letter in a number, a 13th month). |
| `ref` | `Ref<HTMLInputElement>` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` |  |  |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| IpAddressInput | `ip-address-input` |  |  |  |
| IpAddressInputIcon | `ip-address-input-icon` |  |  |  |
| IpAddressInputControl | `ip-address-input-control` |  |  |  |

## Usage

Put the icon and the control in the input, inside a Field with a label and a description.

The sample also uses `field`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui-pro/ip-address-input @gelatin-ui/field
```

```tsx title="allowed-ip.tsx"
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";
import {
  IpAddressInput,
  IpAddressInputControl,
  IpAddressInputIcon,
} from "@/components/ui/pro/ip-address-input";

export function AllowedIp() {
  return (
    <Field name="allowedIp">
      <FieldLabel>Allowed IP</FieldLabel>
      <IpAddressInput defaultValue="203.0.113.24">
        <IpAddressInputIcon />
        <IpAddressInputControl />
      </IpAddressInput>
      <FieldDescription>Requests from other addresses are blocked</FieldDescription>
    </Field>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/ip-address-input
```

It adds 27 registry items: 24 files, 5350 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@maskito/core`, `@maskito/kit`, `@maskito/react`, `@phosphor-icons/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Input Group](https://gelatinui.com/components/input-group.md)
- [Masked Input](https://gelatinui.com/components/masked-input.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Masked Input](https://gelatinui.com/components/masked-input.md)
- [Input Group](https://gelatinui.com/components/input-group.md)
- [Field](https://gelatinui.com/components/field.md)

## Accessibility

It is a native input with a decimal keypad, in a `Field` for the label and the error.

The network icon is decorative.

## Motion

| Part | Motion |
| --- | --- |
| Rejected key | indicator · the frame moves 2px to each side and back when the mask rejects a key |
