Progress

Requires:
@ray-js/ray≥0.6.15

Description

Progress bar component for displaying the current progress of an operation or task.

Props

PropertyTypeRequiredDefaultDescription
percentnumberNo0Current progress, range 0-100
showInfobooleanNofalseWhether to show the percentage on the right of the progress bar
borderRadiusnumber | stringNo0Corner radius, default unit rpx
fontSizenumber | stringNo16Right-side percentage font size, default unit px
strokeWidthnumber | stringNo6Progress bar line width, default unit rpx
activeColorstringNo#007affColor of the completed portion
backgroundColorstringNorgba(0,0,0,0.04)Color of the unfinished portion
activebooleanNofalseWhether to enable left-to-right progress animation
activeMode"backwards" | "forwards"NobackwardsAnimation playback mode: backwards plays from the beginning; forwards continues from the last end point

Valid Values

activeMode
ValueDescriptionSince
backwardsPlay the progress animation from the beginning each time-
forwardsResume the progress animation from where it last ended-

Examples

Basic usage

import React from 'react';
import { View, Progress } from '@ray-js/ray';

export default function Demo() {
  return (
    <View style={{ padding: 20 }}>
      <Progress percent={50} strokeWidth={8} />
    </View>
  );
}

Display percentage

import React from 'react';
import { View, Progress } from '@ray-js/ray';

export default function Demo() {
  return (
    <View style={{ padding: 20 }}>
      <View style={{ marginBottom: 20 }}>
        <Progress percent={20} showInfo strokeWidth={8} />
      </View>
      <View style={{ marginBottom: 20 }}>
        <Progress percent={60} showInfo strokeWidth={8} />
      </View>
      <View>
        <Progress percent={100} showInfo strokeWidth={8} />
      </View>
    </View>
  );
}

Custom styles

import React from 'react';
import { View, Progress } from '@ray-js/ray';

export default function Demo() {
  return (
    <View style={{ padding: 20 }}>
      <View style={{ marginBottom: 20 }}>
        <Progress
          percent={70}
          showInfo
          strokeWidth={12}
          borderRadius={6}
          fontSize={14}
          activeColor="#52c41a"
          backgroundColor="#e8e8e8"
        />
      </View>
      <View>
        <Progress
          percent={40}
          showInfo
          strokeWidth={12}
          borderRadius={6}
          activeColor="#ff4d4f"
          backgroundColor="#fff1f0"
        />
      </View>
    </View>
  );
}

Progress animation

import React, { useState } from 'react';
import { View, Progress, Button } from '@ray-js/ray';

export default function Demo() {
  const [percent, setPercent] = useState(0);

  return (
    <View style={{ padding: 20 }}>
      <Progress
        percent={percent}
        showInfo
        strokeWidth={8}
        active
        activeMode="forwards"
      />
      <View style={{ marginTop: 20, display: 'flex', flexDirection: 'row', gap: '10px' }}>
        <Button size="mini" onClick={() => setPercent(Math.min(percent + 20, 100))}>
          Increase
        </Button>
        <Button size="mini" onClick={() => setPercent(0)}>
          Reset
        </Button>
      </View>
    </View>
  );
}