--- import DefaultLayout from '@shared/layouts/DefaultLayout.astro' import CaptureScript from '@shared/components/CaptureScript.astro' import Card from '@ui/Card.astro' import CardBody from '@ui/CardBody.astro' import CardHeader from '@ui/CardHeader.astro' import CardTitle from '@ui/CardTitle.astro' import CardSubtitle from '@ui/CardSubtitle.astro' import Legend from '@ui/Legend.astro' import LegendList from '@ui/LegendList.astro' import Subheader from '@ui/Subheader.astro' import DocsLink from '@ui/DocsLink.astro' import Chart from '@components/demo/Chart.astro' import site from '@data/site.json' import { ucFirst } from '@shared/lib/string-format' const colors = Object.keys(site.colors) const traffic = [ { name: 'Organic search', color: 'azure', value: '38%' }, { name: 'Direct', color: 'primary', value: '27%' }, { name: 'Social media', color: 'purple', value: '18%' }, { name: 'Referral', color: 'orange', value: '12%' }, { name: 'Email', color: 'green', value: '5%' }, ] const requests = [ { name: 'Allowed', color: 'blue', value: '339.0k' }, { name: 'Denied', color: 'red', value: '1.2k' }, { name: 'Challenged', color: 'orange', value: '815' }, { name: 'Logged', color: 'purple', value: '-' }, { name: 'Rate limited', color: 'teal', value: '-' }, ] const latency = [ { name: 'P99', color: 'primary', value: 124 }, { name: 'P95', color: 'azure', value: 76 }, { name: 'P75', color: 'green', value: 32 }, { name: 'P50', color: 'yellow', value: 10 }, ] const storage = [ { name: 'Documents', color: 'primary', value: '3.5 GB', width: 44 }, { name: 'Media', color: 'info', value: '1.5 GB', width: 19 }, { name: 'Shared', color: 'success', value: '0.7 GB', width: 9 }, ] ---
Basic A Legend is a marker and a label. Set the series color with color.
With values Add value to show a number next to the label. {requests.slice(0, 3).map((item) => )}
States Links and buttons get a tinted background on hover. Use active to keep it and off for a hidden series.
Colors Every palette color works with legend-{'{color}'}. {colors.map((color) => )}
Vertical Add vertical to the list to stack the items. {traffic.map((item) => )}
Marker only Use a bare legend-dot when the label lives elsewhere.
{colors.map((color) => )}
Large Set size="lg" to put a big value under the label. Add unit for the unit and divided on the list for the lines.
Under a stat A legend row explains the split behind a single number. Requests
341.0k
{requests.map((item) => )}
Above a chart Large items show the latest value of each series, so the chart needs no legend of its own. {latency.map((item) => )}
Large vertical Combine size="lg" with a vertical list for a side panel. {storage.map((item) => )}
Large links Large items work as links and buttons too. Mark the current one with active and a hidden series with off.
With units Add unit to a regular item to show the unit after the value. {latency.slice(0, 3).map((item) => )}
Without lines Leave out divided when the items sit in a tight space or wrap to more rows. {traffic.map((item) => )}
Loading Use placeholder blocks for the label and the value while the data loads.
Button items call toggleSeries() on the chart and toggle legend-off.
Next to a donut A vertical list beside a chart with its own legend hidden.
{traffic.map((item) => )}
With a progress bar Label the segments of a progress-separated bar.

Using 5.7 GB of 8 GB

{storage.map((item) =>
)}
{storage.map((item) => )}
Filter links Link items with href work as filters. Mark the current one with active.