SwipeUI

Screen core

The formatters, seeded mock helpers and artwork every SwipeUI kit shares.

Formatters, seeded mock helpers and original artwork shared by every SwipeUI kit.

Free (MIT)Version 1.0.0Released 24 Nov 2026iOS and Android

When to use it

  • Formatting counts, durations, relative times, money and percentages the way every SwipeUI kit does.
  • Writing a mock adapter that returns the same data on every run, with cancellable latency.
  • Covers, banners and placeholders when there's no photo, in the active preset's colours.

When not to use it

  • Date pickers and calendars. Use Date utils and the selection components.
  • Person avatars. Use Avatar, which draws initials.

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 screen-core
  • Adds components/swipeui/lib/screen-core.ts, components/swipeui/lib/screen-artwork.tsx and 1 shared helper.
  • Installs react-native-svg, uniwind, clsx, tailwind-merge. In Expo apps it uses npx expo install so versions match your SDK.

Every kit installs this library through its own core, so you rarely add it yourself.

Formatters

components/inbox-row.tsx
import {
  formatCompactNumber,
  formatRelativeTime,
} from '@/components/swipeui/lib/screen-core';

formatCompactNumber(12_345); // "12.3K"
formatRelativeTime(message.sentAt, { locale }); // "Now", "5m", "3h", "Yesterday", "4d", "2 Nov"
  • formatCompactNumber rounds down, so a count never reads higher than it is.
  • formatDuration gives 0:05, 3:05 or 1:02:03.
  • formatClockTime, formatCurrency and formatPercent (with signed for gains) use Intl and your locale.
  • Every built-in word comes from a messages object, so you can translate or lengthen it:
formatRelativeTime(date, { messages: { minutes: (n) => `${n} min ago` } });

Mock helpers

lib/mock-adapter.ts
import { createSeededRandom, wait } from '@/components/swipeui/lib/screen-core';

const random = createSeededRandom('inbox');

export async function loadConversations(signal?: AbortSignal) {
  await wait(300, signal); // rejects with an AbortError when the screen cancels
  return conversations.map((conversation) => ({ ...conversation, unread: random() > 0.6 }));
}
  • createSeededRandom(seed) repeats the same sequence for the same seed, so demos and tests stay stable.
  • wait(ms, signal) and isAbortError(error) make latency cancellable.
  • createIdFactory('msg') numbers the items a mock creates.

Artwork

import { ScreenArtwork } from '@/components/swipeui/lib/screen-artwork';

<ScreenArtwork seed={album.id} className="size-24 rounded-card" accessibilityLabel={album.title} />;

ScreenArtwork draws original abstract art from a seed in the active preset's chart colours, so it follows every theme. It is decorative unless you give it an accessibilityLabel. Kits never ship photos: pass your own images where you have them.

Behavior and gestures

  • None; the helpers are pure functions and the artwork is static.

Accessibility

  • Artwork is decorative and hidden unless you give it an accessibilityLabel, which makes it an image.
  • Formatters return plain text, so screen readers read the same words people see.

Motion

  • Static on its own; any movement comes from the parent that animates it.
  • No motion.

Performance

  • Artwork geometry is memoised per seed and pattern; it draws a few SVG shapes.

Notes for AI

  • Installed with every kit through its core; don't add it on its own unless you build a kit-style screen.
  • Pass the buyer's locale to every formatter, and replace the messages to translate.
  • Mock adapters should take an AbortSignal and use wait(ms, signal) for latency.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items

On this page