Key
Keys label the meaning of colors or values in a chart or data visualization, such as which color in a grouped meter represents which series.
Usage
forge-key lays out one or more forge-key-item entries, each pairing a colored icon with a label (and an optional value slot), to explain what a color or series means in a chart or visualization. It’s the standard companion to a grouped meter: label each meter in the group with a key item sharing its color, so the grouping is legible without relying on color alone.
Rules
Basic usage
Each forge-key-item pairs an icon color with a label describing what it represents.
A key labeling the parts of a grouped visualization.
<forge-key>
<forge-key-item style="--forge-key-item-icon-color: salmon;">
<span>
Black Guillemot
</span>
<span slot="value">
25%
</span>
</forge-key-item>
<forge-key-item style="--forge-key-item-icon-color: var(--forge-theme-success);">
<span>
Great Shearwater
</span>
<span slot="value">
50%
</span>
</forge-key-item>
<forge-key-item style="--forge-key-item-icon-color: #abcdef;">
<span>
Mealy Redpoll
</span>
<span slot="value">
75%
</span>
</forge-key-item>
</forge-key>Keys present key items to label a chart or data visualization.
import "@tylertech/forge/key";| Name | Description |
|---|---|
(default) | The default slot for key items. |
| Name | Description |
|---|---|
::part(root) | The root element. |
| Name | Description |
|---|---|
--forge-key-gap | The spacing between key items. |
--forge-key-direction | The direction that items are laid out in the key. |
Distinguishable colors
Make sure each key item’s icon color is easily distinguishable from the others, and matches the color used in the associated visualization — don’t rely on subtle shade differences alone.
Text alternative
Use the value slot to give assistive technology a text alternative for data the visualization otherwise only conveys visually.