SwipeUI

Usage meter

Allowance progress and written category contributions with explicit near/exceeded status.

npx @swipeui/cli add usage-meter
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Storage, data or credit allowances, such as 12 of 15 GB used.
  • Breakdowns by category, like photos, videos and documents.
  • Warning people before they hit a limit and stating clearly when they've gone over.

When not to use it

  • Simple progress. Use Progress.
  • A single number. Use Metric card.
  • Budgets with many categories; build a chart.

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 usage-meter
  • Adds components/swipeui/ui/usage-meter.tsx and 10 shared helpers.
  • Installs react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, class-variance-authority, expo-haptics. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/storage.tsx
import { UsageMeter } from '@/components/swipeui/ui/usage-meter';

<UsageMeter label="Storage" limit={10} unit="GB" segments={usage} />;

Examples

Storage shows an inspectable category breakdown. Credits shows a compact monthly balance. Each demo has an external control for exercising all three allowance states in the top-right tag.

API reference

UsageMeterProps

PropTypeDefaultDescription
animateValue?booleantrue

Animate changing values.

animateSegments?booleantrue

Animate segment proportions.

animateStatus?booleantrue

Crossfade the allowance tag when its state changes.

showLegend?booleantrue

Show the written category breakdown.

inspectBar?booleantrue

Allow direct bar inspection; the legend remains independent.

appearance?"elevated" | "transparent"'elevated'

Card or transparent surface.

interactive?booleantrue

Enable category inspection without modifying usage.

selectedSegment?string | nullundefined

Controlled inspected category; null shows the total.

defaultSelectedSegment?string | nullnull

Initial inspected category.

onSelectedSegmentChange?((id: string | null) => void)—

Category selection intent.

messages?object—

Translated allowance statuses.

labelstring—

Named allowance.

limitnumber—

Positive allowance.

segmentsreadonly UsageSegment[]—

Ordered contributions; labels carry meaning beyond colour.

unit?string''

Formatted unit suffix, such as 'GB'.

locale?string—

Locale for numeric labels.

warningAt?number0.9

Warning fraction.

motion?MotionOverride—

Shared number feel.

haptics?booleantrue

Action haptics.

className?string—

Root classes.

style?StyleProp<ViewStyle>—

Native layout escape hatch.

testID?string—

Root ID.

Native view/input props not listed here pass through where the exported TypeScript type allows them.

Composition and behavior

  • label and limit define the allowance; segments list categories with labels and values.
  • unit, locale and warningAt shape the text and warning.

Settings

PropDoes / default
idStable category identifier.
labelNamed allowance.
valueNon-negative usage in the same unit as limit.
appearanceCard or transparent surface. @default 'elevated'
showLegendShow category rows. Defaults to true.
animateStatusCrossfade the allowance tag when its state changes. Defaults to true and respects reduced motion.
interactiveEnable category inspection without modifying usage. @default true
selectedSegmentControlled inspected category; null shows the total. @default undefined
defaultSelectedSegmentInitial inspected category. @default null
onSelectedSegmentChangeCategory selection intent.
messagesTranslated allowance statuses.
limitPositive allowance.
segmentsOrdered contributions; labels carry meaning beyond colour.
unitFormatted unit suffix, such as 'GB'. @default ''
localeLocale for numeric labels.
warningAtWarning fraction. @default 0.9
motionShared number feel.
classNameRoot classes.
styleNative layout escape hatch.
testIDRoot ID.

Behaviour

Tap the bar or a legend row to inspect a category. selectedSegment/defaultSelectedSegment/onSelectedSegmentChange support controlled and uncontrolled inspection. The component never changes usage. It belongs to Lists and data display.

Action haptics can be disabled independently with haptics={false} (default true).

Behavior and gestures

  • The Storage board inspects category segments; Credits shows a compact monthly balance.
  • Near the limit (90% by default) and over it, the status text changes, not just the colour.

Accessibility

  • Announced as a progress bar with its label and status, such as "Storage: Near limit" or "Storage: Limit exceeded".
  • Each category is written out with its value, so colour isn't the only signal.
  • Over-limit allowances say so explicitly.

Motion

  • Uses the number and morph motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • The number and bar animate independently of the status tag. Reduce Motion shows status changes immediately.

Performance

  • A few views; numbers are formatted with your locale.

Notes for AI

  • Pass limit and segments with values in the same unit; set unit like "GB".

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