Progress
Use the Progress component to show the status of ongoing processes.
Props
value
Use this to change the Progress value.
Type | Default | Description |
---|---|---|
| 0 | Represents the percentage of the progress. |
Example
size
Use this to change the Progress size.
Type | Default | Description |
---|---|---|
| 'md' | It applies mapped value to height property. |
Example
rounded
Use this to change the Progress radius value.
Type | Default | Description |
---|---|---|
| 'full' | It applies mapped value to borderRadius property. |
Example
trackBg
Use this to change the Progress track background color.
Type | Default | Description |
---|---|---|
| #169f94 | Background color of the Progress track. |
Example
bg
Use this to change the Progress background color.
Type | Default | Description |
---|---|---|
| #edf4f8 | Background color of the Progress. |
Example
Static
border
Use this to change the Progress border width.
borderColor
Use this to change the Progress border color.
Tips
Consider removing the minWidth property
The minWidth: 80
property within the progress: {...}
styles ensures the visibility of the Progress component, regardless of the layout it's placed in. Because some layouts can affect its size, potentially setting it to 0, you typically don't need to remove it unless you specifically intend to set a smaller size for the Progress element than the current minWidth value.
Editor
import React from 'react';
import {View} from 'react-native';
const UIProgress = ({
value = 0,
size = 'md',
rounded = 'full',
trackBg = '#169f94',
bg = '#edf4f8',
style
}) => {
const sizeMappedValue = {
'xs': 4,
'sm': 8,
'md': 14,
'lg': 20,
'xl': 26,
'2xl': 32,
}[size];
const fullRadius = sizeMappedValue / 2;
const roundedMappedValues = {
'none': 0,
'xs': 2,
'sm': 4,
'md': 6,
'lg': 8,
'xl': 12,
'2xl': 16,
'_2xl': 16,
'full': fullRadius,
}[rounded];
const styles = {
progress: {
flexDirection: 'row',
minWidth: 80,
height: sizeMappedValue,
minHeight: sizeMappedValue,
flexShrink: 0,
flexBasis: 0,
borderRadius: roundedMappedValues,
backgroundColor: bg,
overflow: 'hidden',
},
progressTrack: {
width: `${value}%`,
borderRadius: roundedMappedValues,
backgroundColor: trackBg,
},
};
return (
<View style={[styles.progress, style]}>
<View style={styles.progressTrack} />
</View>
);
};
export default UIProgress;
<UIProgress
value={40}
/>