Spark Bars
React Native (Expo)
A tiny React Native bar chart for trends inside a card, whose bars grow up one after another and resize on change.
A tiny bar chart for showing a trend inside a card. The bars grow up from the baseline one after another, resize when the values change, and the active bar takes the accent colour. It reads out as an image with every value listed, since the bars carry no labels. Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add spark-barsManual
- Copy the code from the component tab.
- Create a file at
components/ui/spark-bars.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
values | number[] | - | One value per bar; the tallest sets the scale. |
height | number | 48 | Height of the tallest bar. |
gap | number | 4 | Space between bars. |
highlight | number | - | Index of the active bar; defaults to the last. |
label | string | "Chart" | Spoken name of the chart. |
colors | Partial<SparkBarsColors> | - | Overrides bar and active. |
style | StyleProp<ViewStyle> | - | Style for the row of bars. |
Comments