Components
Legend
A color-coded legend which goes well with data bar components.
Category 1
Category 2
Category 3
Import Legend
Tremor exports one component for Legend.
import { Legend } from "@tremor/react";
Usage example
The example below shows a KPI card in employing Legend
to display more
information about the data.
Total Users
10,483
6724
10345
0
10345
Active users
Inactive users
import { Card, Metric, Text, CategoryBar, Legend } from "@tremor/react"; export default () => ( <Card className="max-w-md mx-auto"> <Text>Total Users</Text> <Metric>10,483</Metric> <CategoryBar className="mt-4" categoryPercentageValues={ [6724, 3621] } colors={ ['emerald', 'red'] } /> <Legend className="mt-3" categories={ ['Active users', 'Inactive users'] } colors={ ['emerald', 'red'] } /> </Card> );
API Reference: Legend
- categories
- Description
- Define the categories in the legend.
- Type
- string[]
- Default
- Values
- E.g. ['Active users', 'Inactive users']
- colorsoptional
- Description
- Change the default colors. When using Typescript, import the Color type provided by tremor.
- Type
- Color[]
- Default
- Values
- E.g. ['blue', 'indigo'].