Metric
A metric component is a button that visually represents a specific metric or measurement. It provides a concise and interactive way for users to access important information or track key performance indicators.
Version 0.4.2
Installation
To install @igloo-ui/metric
in your project, you will need to run the following command using npm:
npm install @igloo-ui/metric
If you prefer Yarn, use the following command instead:
yarn add @igloo-ui/metric
Usage
Then to use the component in your code just import it!
import Metric from '@igloo-ui/metric';
import Wellness from '@igloo-ui/icons/dist/Wellness';
const [selected, setSelected] = React.useState(false);
const handleOnPress = () => {
setSelected(!selected);
};
<Metric
value={20}
variation={3}
label="Metric Name"
icon={<Wellness size="medium" />}
onPress={handleOnPress}
appearance={selected ? 'selected' : 'positive'}
/>;
API
Metric
Prop | Type | Default | Description |
---|---|---|---|
appearance | Appearance | - | The appearance of the metric |
className | string | - | Add a specific class to the metric |
dataTest | string | - | Add a data-test tag for automated tests |
icon | ReactElement<any, string | JSXElementConstructor<any>> | - | The icon to display |
label | string | - | The label or metric name to display |
tooltip | string | - | The tooltip to display |
type | MetricType | The type of metric | |
value | number | - | The value of the metric (Only variation is used for type fluctuate) |
variation | number | - | The variation of the metric |
Score
Prop | Type | Default | Description |
---|---|---|---|
arrowSize | "small" | "medium" | "large" | The size of the arrow | |
className | string | - | Add a specific class to the metric |
forceDecimal | boolean | Force the score to have a decimal | |
hideIfZero | boolean | Whether or not the score should be hidden if it is zero | |
isSelected | boolean | Whether or not the score should have a selected style | |
isVariation | boolean | Whether or not the score is a variation | |
value | number | - | The value of the score |