Empty state
Intrinsic illustration, message and next-action layout.
npx @swipeui/cli add empty-stateWhen to use it
- Empty lists, such as no messages yet or no saved items, with a way forward.
- Search with no results and a suggestion to change filters.
- First-run screens before people create anything.
- Error-free blank states that need a friendly illustration.
When not to use it
- Loading. Use Skeleton or Spinner.
- Errors with retry. Use Alert.
- Onboarding with several steps. Use Onboarding checklist.
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 empty-state- Adds
components/swipeui/ui/empty-state.tsxand 11 shared helpers. - Installs react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority, react-native-svg. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { EmptyState } from '@/components/swipeui/ui/empty-state';
<EmptyState title="No saved places" description="Save a place to find it here." />;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
EmptyStateProps
| Prop | Type | Default | Description |
|---|---|---|---|
preset? | | — | |
title? | | — | |
appearance? | | | Card or transparent composition. |
person? | | | Person used by the offline preset; the caller owns the image. |
description? | | — | Helpful next-step instructions. |
illustration? | | — | Decorative illustration; keep important meaning in the text. |
action? | | — | Primary next step. |
secondaryAction? | | — | Optional secondary route. |
motion? | | — | Shared fade/press feel. |
haptics? | | | Action haptics. |
className? | | — | Root classes. |
style? | | — | Native layout escape hatch. |
testID? | | — | Root ID. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Composition and behavior
- illustration, title and description stacked in the centre.
- action and secondaryAction add a main and a ghost button.
Feedback lineup settings
| Prop | Does / default |
|---|---|
appearance | Card or transparent composition. @default 'elevated' |
person | Person used by the offline preset; the caller owns the image. @default undefined |
description | Helpful next-step instructions. |
illustration | Decorative illustration; keep important meaning in the text. |
action | Primary next step. |
secondaryAction | Optional secondary route. |
motion | Shared fade/press feel. |
className | Root classes. |
style | Native layout escape hatch. |
testID | Root ID. |
Ready-made states
Choose preset="offline-user", no-teammates, no-matches, empty-inbox, no-files or load-failed. Override title/description/art/actions, use appearance="transparent" to omit the card, or pass person={{ name, source }} for the offline avatar. Images belong to the host app.
Action haptics can be disabled independently with haptics={false} (default true).
Behavior and gestures
- Shows a message with up to two buttons, such as Create your first note and Browse templates.
- Buttons run their own actions; the illustration doesn't respond to touch.
- It fades in gently with the layout role.
Accessibility
- The illustration is decorative; put meaning in the title and description.
- Action buttons are separate, named focus stops.
- Text wraps fully at large sizes.
Motion
- Uses the
layoutandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Fades in with the layout role; Reduce Motion shows it immediately.
Performance
- Mount it only when the list is really empty, not while loading.
Notes for AI
- Write a title that says what's empty and a description with the next step.
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.