Form
A shared keyboard provider, focused-input scroll view and token-coloured keyboard toolbar.
npx @swipeui/cli add formWhen to use it
- Any screen with text fields, so the focused field always scrolls into view above the keyboard.
- Long sign-up or checkout forms where people move from field to field.
- Numeric keyboards that have no Return key and need Previous, Next and Done buttons above them.
- Setting up keyboard handling once for the whole app.
When not to use it
- Screens without text input.
- Chat composers pinned to the keyboard; use Keyboard Controller's sticky views directly.
- Single fields inside sheets where the sheet already handles the keyboard.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add form- Adds
components/swipeui/ui/form.tsxand 3 shared helpers. - Installs react-native-keyboard-controller, uniwind, react-native-reanimated, react-native-worklets, react-native-gesture-handler, react-native-safe-area-context. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { FormProvider, FormScrollView, FormToolbar } from '@/components/swipeui/ui/form';
<FormProvider>
<FormScrollView>
<TextField label="Name" />
</FormScrollView>
<FormToolbar />
</FormProvider>;Examples
Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.
API reference
FormProviderProps
| Prop | Type | Default | Description |
|---|---|---|---|
| No props of its own. | |||
FormScrollViewProps
| Prop | Type | Default | Description |
|---|---|---|---|
| No props of its own. | |||
FormToolbarProps
| Prop | Type | Default | Description |
|---|---|---|---|
portal? | | | Mount the toolbar in the app's overlay layer (OverlayProvider), so it sits at the bottom of the screen wherever it's declared: hidden below the screen while the keyboard is down, and riding on top of the keyboard while it's up. Turn it off when you already render the toolbar as a direct child of a full-screen view. Without an OverlayProvider it renders in place. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Form toolbar settings
| Prop | Does | Default |
|---|---|---|
| portal | Mount in the overlay layer so it rides the keyboard at the screen edge | true |
Composition and behavior
- FormProvider is the keyboard host near your app root.
- FormScrollView keeps the focused input visible and supports interactive dismissal.
- FormToolbar adds Previous, Next and Done with your theme colours.
- Built on React Native Keyboard Controller.
Behavior and gestures
- When a field is focused, the scroll view moves it just above the keyboard.
- Drag the content down to dismiss the keyboard interactively.
- The keyboard toolbar adds Previous, Next and Done buttons, so people can move between fields on any keyboard.
- Toolbar buttons are tinted with your theme's primary colour.
Accessibility
- Toolbar buttons are real buttons with labels you can translate.
- Fields are never hidden behind the keyboard, which helps people using large text.
- Disabled toolbar actions show your theme's disabled colour.
Motion
- Static on its own; any movement comes from the parent that animates it.
- Scrolling to the focused field follows the keyboard's own animation.
- No SwipeUI motion roles are used, so the system keyboard timing wins.
Performance
- Keyboard tracking runs natively through React Native Keyboard Controller.
- Eager keyboard preloading is off by default to save start-up time.
Notes for AI
- Put one FormProvider near the app root; skip it if you already use KeyboardProvider.
- Rebuild dev clients and bare apps after installing Keyboard Controller.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.