# Floating Input — React Native component for Expo

> A text field whose label glides onto the border as an accent halo blooms.

The label starts as the placeholder and glides onto the border when you focus — a soft accent halo blooms around the field, errors shake in with an icon, valid values pop a spring check. Prefix/suffix, clear button, counter and three variants whose indicator grows from the centre.

- Docs: https://expokit.in/docs/components/floating-input
- Tier: Free
- Also called: floating label input, material text field, animated text input
- Category: Inputs
- Platforms: iOS, Android, web
- Expo Go: yes, no development build needed
- npm dependencies: react-native-svg
- Uses ExpoKit items: kit
- Variants: Sign Up, Payment, Variants, States, Website, Sizes, Label Above, Custom Styles

## Installation

Run once per project: `npx @expokit/cli@latest init` (shared theme + KitProvider). Then:

```bash
npx @expokit/cli@latest add floating-input
```

The CLI copies the source into your project (you own the code) and installs react-native-svg.

Import: `import { FloatingInput } from "@/components/ui/floating-input";`

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | — | Placeholder that floats onto the border. |
| `floatingLabel` | `boolean` | `true` | Set to false to put the label above the field as static text (no notch) and show placeholder inside; filled and underline work too. |
| `variant` | `"outlined" \| "filled" \| "underline"` | `"outlined"` | Notched outline, rounded filled, or bare underline (filled/underline bars grow from the centre on focus). |
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | 44 / 54 / 64pt — font, padding, radius and icons scale too. |
| `error` | `string` | — | Red state, icon + message that slides in, one shake. |
| `success` | `boolean \| string` | — | Green border + animated check; a string is shown as the message. |
| `helper` | `string` | — | Hint under the field. |
| `prefix / suffix` | `string` | — | Inline text like "₹", "+91", "INR" — fades in when the label floats. |
| `counter` | `boolean` | `false` | Shows length/maxLength under the field (needs maxLength). |
| `left / right` | `ReactNode` | — | Icons or adornments inside the field. |
| `clearable` | `boolean` | `false` | Animated SVG clear button while there's text. |
| `accent` | `string` | `theme accent` | Focus border, halo and label colour. |
| `surface` | `string` | `theme background` | Colour behind the field (paints the notch). |
| `style` | `StyleProp<ViewStyle>` | — | Style for the outer wrapper around the field and message line (the one that shakes). |
| `className` | `string` | — | Tailwind classes on the root when using NativeWind or Uniwind. Prefer style for StyleSheet overrides. |
| `fieldStyle` | `StyleProp<ViewStyle>` | — | The bordered box: background, border width / colour, radius, height, padding. Wins over the computed style; a borderColor replaces the resting border only (focus, error and success colours still show). A numeric height / borderRadius re-centres the label and resizes the halo. |
| `inputStyle` | `StyleProp<TextStyle>` | — | The typed text — fontSize, fontWeight, color, letterSpacing, fontFamily. |
| `labelStyle` | `StyleProp<TextStyle>` | — | Label in both modes (floating and above). color is the resting colour — focus (accent), error and success still take over; fontSize sets the resting size, it floats at the same ratio and the notch follows its width. |
| `messageStyle` | `StyleProp<TextStyle>` | — | Helper / error / success text. color applies to the helper; error and success keep their tone colour. |
| `prefixStyle / suffixStyle` | `StyleProp<TextStyle>` | — | Prefix / suffix text (still fades in with the label). |
| `counterStyle` | `StyleProp<TextStyle>` | — | The length/maxLength counter; turns danger at the limit regardless. |
| `placeholderTextColor` | `string` | `theme mutedForeground` | Placeholder colour (floatingLabel={false}). |
| `iconColor` | `string` | `theme mutedForeground` | Clear button colour at rest. |
| `…TextInputProps` | `` | — | Everything TextInput accepts. |

## Behaviour & accessibility

- **Touch**: Tapping anywhere on the field focuses the input. With clearable, a × springs in once there is text and empties the field.
- **Motion**: The label springs onto the border on focus or when filled, and a soft halo blooms around the field. An error shakes it once; a success check springs in.
- **Screen readers**: The input is labelled with your label and the clear button reads "Clear" plus the label. Helper, error and success messages are polite live regions.
- **Web**: Browser autofill floats the label too, and the field keeps its own background instead of the autofill blue.

## FAQ

### How do I make a floating label input in React Native?

Use ExpoKit's Floating Input: run npx @expokit/cli@latest add floating-input in your Expo or React Native project and it copies a ready-made floating label input into your app as plain TypeScript you can edit. It works on iOS, Android and web, and in Expo Go.

### Does Floating Input work in Expo Go?

Yes. Floating Input runs in Expo Go on iOS and Android with no development build — its packages (react-native-svg) are all included in Expo Go.

### How do I add Floating Input to my Expo app?

Run npx @expokit/cli@latest add floating-input in your project. The CLI copies the component's source into your app and installs react-native-svg, so the code is yours to change.

### Is Floating Input free?

Yes. Floating Input is free: its full source is on this page and the CLI installs it without an account.

### Can I change how Floating Input looks?

Yes. It takes its colours, radius and light / dark mode from useKit(), so wrapping your app in <KitProvider accent radius> re-skins it with every other ExpoKit component. The code lives in your project, so you can also edit anything directly.

## More

- Live preview, variants and code: https://expokit.in/docs/components/floating-input
- Every ExpoKit component, screen, template and chart: https://expokit.in/llms.txt
- Install commands and props for every free component: https://expokit.in/llms-full.txt
- Pricing: https://expokit.in/pricing
