Skip to main content

Progress & Spinner

Progress shows how far a task has got. Leave value out while the amount is unknown and a segment sweeps across instead (it holds still when the OS asks to reduce motion). Spinner is the platform's own activity indicator in a theme color.

import { Progress, Spinner } from 'patine-ui';
Loading…
<Card style={{ maxWidth: 380, width: '100%' }}>
  <CardContent style={{ paddingTop: 16, gap: 12 }}>
    <HStack gap="md" align="center">
      <Icon name="film" size={28} color="primary" />
      <VStack style={{ flex: 1 }}>
        <Text weight="medium">product-demo.mp4</Text>
        <Text size="sm" color="textSecondary">
          {done ? '48 MB · Uploaded' : `${Math.round((value / 100) * 48)} of 48 MB · ${running ? 'Uploading' : 'Paused'}`}
        </Text>
      </VStack>
      <Text weight="medium">{value}%</Text>
    </HStack>
    <Progress value={value} accessibilityLabel="Uploading product-demo.mp4" />
    <HStack gap="sm">
      {done ? (
        <Button size="sm" variant="outline" onPress={() => { setValue(0); setRunning(true); }}>Upload another</Button>
      ) : (
        <Button size="sm" variant="outline" onPress={() => setRunning((r) => !r)}>{running ? 'Pause' : 'Resume'}</Button>
      )}
    </HStack>
  </CardContent>
</Card>

Try the props​

Props
value
max
height
design
<Progress accessibilityLabel="Upload" value={60} />

Example: a storage meter​

indicatorStyle and height restyle the bar: here its color warns as the quota fills.

Loading…
<VStack gap="lg" style={{ maxWidth: 380, width: '100%' }}>
  {QUOTAS.map(({ label, used, total }) => (
    <VStack key={label} gap="xs">
      <HStack justify="space-between">
        <Text weight="medium">{label}</Text>
        <Text size="sm" color="textSecondary">{used} of {total} GB</Text>
      </HStack>
      <Progress value={used} max={total} height={10} indicatorStyle={{ backgroundColor: color(used / total) }} accessibilityLabel={`${label} storage`} />
    </VStack>
  ))}
</VStack>

Determinate and indeterminate​

Pass a value from 0 to max when you know how far along it is. Leave it out (or pass null) while you don't, such as while connecting, and a segment sweeps across.

Loading…
<VStack gap="md" style={{ maxWidth: 360, width: '100%' }}>
  <Text size="sm" color="textSecondary">Connecting to the server…</Text>
  <Progress accessibilityLabel="Connecting" />
  <Text size="sm" color="textSecondary">Step 3 of 5</Text>
  <Progress value={3} max={5} accessibilityLabel="Onboarding, step 3 of 5" />
</VStack>

Spinner​

Spinner is the platform's activity indicator. size is 'small', 'large' or a number, and color a theme color. Inside a button, use the button's own loading instead.

Loading…
<HStack gap="xl" align="center">
  <Spinner />
  <Spinner size="large" />
  <Spinner color="success" accessibilityLabel="Verifying" />
  <Spinner color="danger" />
  <HStack gap="sm" align="center">
    <Spinner color="textSecondary" accessibilityLabel="Loading messages" />
    <Text color="textSecondary">Loading messages…</Text>
  </HStack>
</HStack>

Designs​

iOS and Material draw a thin 4pt track, as their system progress views do; brand and web a rounder 8pt one.

Loading…
<VStack gap="sm" style={{ maxWidth: 360, width: '100%' }}>
  {Object.entries(DESIGNS).map(([design, label]) => (
    <VStack key={design} gap="xs">
      <Text size="xs" color="textSecondary">{label}</Text>
      <Progress design={design as keyof typeof DESIGNS} value={65} accessibilityLabel={label} />
    </VStack>
  ))}
</VStack>

Accessibility​

Both have the progressbar role. Progress reports its percentage (aria-valuenow) and is aria-busy while indeterminate; name it with accessibilityLabel. Spinner is named "Loading" unless you pass your own accessibilityLabel.

Props​

Progress​

Progress also takes View props.

PropTypeDefaultDescription
valuenumber | null—From 0 to max. Leave it out while unknown.
maxnumber100
heightnumber4 (iOS, Material), 8 (brand, web)The track's height.
indicatorStyleStyleProp<ViewStyle>—The filled part.
themeDeepPartial<Theme>—Theme override.
designDesignfrom PatineProviderThe look to follow.

Spinner​

Spinner also takes ActivityIndicator props.

PropTypeDefaultDescription
colorkeyof Theme['colors']'primary'A theme color.
size'small' | 'large' | number'small'
accessibilityLabelstring'Loading'