SwipeUI

Download button

Caller-owned transfer progress that folds Get into a stop ring, then Success or Retry.

npx @swipeui/cli add download-button
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

  • Represent a download owned by an application service.
  • Expose a real stop action while progress is known.

When not to use it

  • Start network requests or manage downloaded files inside the component.
  • Infer transfer completion from a timer; status belongs to the caller.

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

Usage

app/actions.tsx
import { DownloadButton } from '@/components/swipeui/ui/download-button';

<DownloadButton
  status={download.status}
  progress={download.progress}
  onStart={download.start}
  onStop={download.stop}
  onOpen={openFile}
/>;

Examples

install, failure, sizes. The app and public preview use the same content and variant names. Demo settings sit outside the component and outcome feedback stays on the action.

Settings

SettingDefaultBehavior
labelsGet / Waiting / Stop download / Success / RetryIndependent words for every lifecycle.
foldtrueFold the label into a circular transfer control.
progressMotiontrueAnimate progress-ring changes on the number role.
statusundefinedCaller-owned download lifecycle.
defaultStatus'idle'Initial lifecycle when uncontrolled.
onStatusChangeundefinedReceives start/stop/retry intent; owner confirms its lifecycle.
progress0Normalized caller progress; nonfinite values become zero.
onStartundefinedStart the actual download outside the component.
onStopundefinedCancel caller work; component never performs network requests.
onOpenundefinedOpen the downloaded content.
onRetryonStartRetry caller work after failure.
disabledfalseBlock activation.
announceProgresstrueAnnounce progress only when crossing quarter milestones.
hapticstrueGlobal feedback or independent start/stop/done/error switches.
variant'solid'How much the button stands out: solid, tinted (a soft wash of the tone), outline, ghost (no fill until pressed) or plain (text only). The 1.x names default, secondary and destructive still work as solid primary, neutral and destructive.
tone'primary' for solid, tinted and plain; 'neutral' for outline and ghostThe colour family: primary, neutral, destructive or success.
size'md'The height: sm 36pt (with a 44pt touch target), md 44pt, lg 52pt.
shape'preset'preset follows your preset's control radius; pill is a capsule.
blockfalseStretches the button to the full width of its container.
leadingIconabsentContent before the label: a node, or a function that receives &#123; color, size &#125;.
trailingIconabsentContent after the label: a node, or a function that receives &#123; color, size &#125;.
trailingIconNudgefalseSlides the trailing icon a little forward while pressed, mirrored in right-to-left layouts.
loadingLabelabsentLabel shown while loading; defaults to the children.
labelMorph'fade'How a changed text label arrives: fade (the new label rises in as the old one fades), characters (only the changed letters roll in) or none. The width springs to fit either way.
highlighttrueA faint rim of light along the top edge of solid buttons.
glowfalseA soft shadow in the tone's colour under solid buttons.
pressEffect'both'Feedback while pressed: both scales and washes the surface, scale, wash or none. Text-only buttons dim their label instead of washing.
disabledStyle'muted'How a disabled button looks: muted mutes its fill and label; dim halves its opacity.
paletteBUTTON_PALETTEColours that belong to the button's material rather than the theme (the top highlight).
motionthe app's feel (smooth without a provider)The app's motion feel, or a local override for the press, label and width springs.
classNameabsentClasses merged over the style.
textClassNameabsentClasses for the label text.
styleabsentStyle escape hatch for the container.
accessibilityLabelcurrent labelOptional spoken-name override.
testIDundefinedRoot identifier; parts append suffixes.
haptics.starttrueImpact for start or retry intent.
haptics.stoptrueImpact for stop intent.
haptics.donetrueSuccess notification on completion.
haptics.errortrueError notification on failed status.

Composition and behavior

Feed status and progress from the transfer service. Handle onStart/onStop/onRetry/onOpen outside the item. defaultStatus supports uncontrolled fixture states, but this UI never creates a download or decides when one completes.

Get requests waiting; caller status drives waiting, downloading, done or failed. onStatusChange reports intent without overriding a controlled owner.

During downloading, fold optionally turns the control into a circular progress ring and stop square. Stop requests idle; done shows Success; an optional onOpen callback enables activation; failure invokes onRetry or onStart.

Progress is clamped to 0–1 and announced only when crossing quarter milestones; announceProgress and progressMotion are independent.

API reference

PropTypeDefaultDescription
layout?union—

Optional layout transition for composed controls; derive its values from useMotion.

motion?MotionOverridethe app's feel (`smooth` without a provider)

The app's press character, or a local override. The app's motion feel, or a local override for the press, label and width springs.

variant?ButtonVariant'solid'

How much the button stands out: solid, tinted (a soft wash of the tone), outline, ghost (no fill until pressed) or plain (text only). The 1.x names default, secondary and destructive still work as solid primary, neutral and destructive.

tone?ButtonTone'primary' for solid, tinted and plain; 'neutral' for outline and ghost

The colour family: primary, neutral, destructive or success.

size?ButtonSize'md'

The height: sm 36pt (with a 44pt touch target), md 44pt, lg 52pt.

shape?ButtonShape'preset'

preset follows your preset's control radius; pill is a capsule.

block?booleanfalse

Stretches the button to the full width of its container.

leadingIcon?ButtonIcon—

Content before the label: a node, or a function that receives { color, size }.

trailingIcon?ButtonIcon—

Content after the label: a node, or a function that receives { color, size }.

trailingIconNudge?booleanfalse

Slides the trailing icon a little forward while pressed, mirrored in right-to-left layouts.

loadingLabel?string—

Label shown while loading; defaults to the children.

loadingPlacement?ButtonLoadingPlacement'start'

Where the spinner goes: start replaces the leading icon; center hides the label and holds the width.

singleLine?booleanfalse

Keep string labels and loading words on one clipped line.

labelMorph?ButtonLabelMorph'fade'

How a changed text label arrives: fade (the new label rises in as the old one fades), characters (only the changed letters roll in) or none. The width springs to fit either way.

highlight?booleantrue

A faint rim of light along the top edge of solid buttons.

glow?booleanfalse

A soft shadow in the tone's colour under solid buttons.

pressEffect?ButtonPressEffect'both'

Feedback while pressed: both scales and washes the surface, scale, wash or none. Text-only buttons dim their label instead of washing.

disabledStyle?ButtonDisabledStyle'muted'

How a disabled button looks: muted mutes its fill and label; dim halves its opacity.

glassStatus?ThemeSurfaceTone—

Keeps a completed or failed action’s Glass status visible when the control is locked.

palette?Partial<ButtonPalette>BUTTON_PALETTE

Colours that belong to the button's material rather than the theme (the top highlight).

className?string—

Classes merged over the style.

textClassName?string—

Classes for the label text.

style?StyleProp<ViewStyle>—

Style escape hatch for the container.

status?DownloadStatusundefined

Caller-owned download lifecycle.

defaultStatus?DownloadStatus'idle'

Initial lifecycle when uncontrolled.

onStatusChange?((status: DownloadStatus) => void)undefined

Receives start/stop/retry intent; owner confirms its lifecycle.

progress?number0

Normalized caller progress; nonfinite values become zero.

onStart?(() => void)undefined

Start the actual download outside the component.

onStop?(() => void)undefined

Cancel caller work; component never performs network requests.

onOpen?(() => void)undefined

Open the downloaded content.

onRetry?(() => void)onStart

Retry caller work after failure.

announceProgress?booleantrue

Announce progress only when crossing quarter milestones.

haptics?uniontrue

Global feedback or independent start/stop/done/error switches.

labels?Partial<Record<union, string>>Get / Waiting / Stop download / Success / Retry

Independent words for every lifecycle.

fold?booleantrue

Fold the label into a circular transfer control.

progressMotion?booleantrue

Animate progress-ring changes on the number role.

Review gates

Founder app and existing pnpm-dev visual acceptance remains open. Native runtime, VoiceOver/TalkBack, haptics, motion, Dynamic Type, RTL and recordings remain pending founder-scheduled 7.9. Source, bundle and unit checks do not establish visual or native acceptance.

Completion defaults to a green tick and Success on a tinted surface. It stays settled until the external owner resets it; pass onOpen and an explicit labels.done only when completion should be an action. Failure cross and Retry use the same red token. Waiting stays on one line.

Behavior and gestures

  • Get requests waiting; caller status drives waiting, downloading, done or failed. onStatusChange reports intent without overriding a controlled owner.
  • During downloading, fold optionally turns the control into a circular progress ring and stop square. Stop requests idle; done shows tinted Success (onOpen is optional opt-in activation); failure invokes onRetry or onStart.
  • Progress is clamped to 0–1 and announced only when crossing quarter milestones; announceProgress and progressMotion are independent.

Accessibility

  • Named controls expose unavailable, busy and selected/progress state where applicable. Decorative layers are excluded from interaction.
  • Meaningful outcome/availability announcements are distinct from clocks and decorative effects. Native VoiceOver/TalkBack, Dynamic Type, RTL and touch evidence remain pending for 7.9.

Motion

  • Uses the press, morph, number and ambient motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • Every decorative duration/spring comes from the shared role helpers. Content clocks remain independent of motion feel.
  • Reduce Motion retains readable outcome/progress feedback. Native motion/performance review remains pending.

Performance

  • No new package, network service, telemetry or proprietary source.
  • Async results and content timers clean up or invalidate after unmount; UI animation values stay on the UI thread.

Notes for AI

  • Feed status and progress from the transfer service. Handle onStart/onStop/onRetry/onOpen outside the item. defaultStatus supports uncontrolled fixture states, but this UI never creates a download or decides when one completes.
  • Founder app/web acceptance and all native runtime, accessibility, haptics, motion and recordings remain pending for 7.9.

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