Highlight
Draw the attention of users to important data and metrics.
#Examples
The Highlight
component consists of four namespaced components:
Highlight.Layout
takes care of sizing, spacing, and responsive behavior.Highlight.Item
contains the data that needs to be highlighted.Highlight.Title
serves as the subtle heading of a highlight item.Highlight.Value
presents a string or number in a visually salient manner.
#Default
This is the default implementation of the Highlight
component. Things to take note of:
- The component can be used inside any container, but is mainly intended for use inside of a Card.
- An
aria-label
is required. It should describe what the collection of highlight items concerns. - Although not required, you'll usually want to wrap a number in a FormattedNumber component.
Number
Percentage
Currency
Empty
<Card>
<Highlight.Layout aria-label="Highlights">
<Highlight.Item>
<Highlight.Title>Number</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={20492} format="number" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>Percentage</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={0.5484} format="percent" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>Currency</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={1234567} format="currency" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>Empty</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={null} />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>
<Tooltip variant={{ type: "text" }} content="This title has a tooltip.">
Tooltip
</Tooltip>
</Highlight.Title>
<Highlight.Value>Yes</Highlight.Value>
</Highlight.Item>
</Highlight.Layout>
</Card>
#Heading level
By default, the Highlight.Title
component outputs an h3
level heading. That's because the component will often be nested inside of a Card with an h2
level heading. When this is not the case, the headingLevel
property can be used to output a different heading level.
Number
Percentage
Currency
Empty
<Card>
<Highlight.Layout aria-label="Highlights">
<Highlight.Item>
<Highlight.Title headingLevel="h5">Number</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={20492} format="number" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title headingLevel="h5">Percentage</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={0.5484} format="percent" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title headingLevel="h5">Currency</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={1234567} format="currency" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title headingLevel="h5">Empty</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={null} />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title headingLevel="h5">
<Tooltip variant={{ type: "text" }} content="This title has a tooltip.">
Tooltip
</Tooltip>
</Highlight.Title>
<Highlight.Value>Yes</Highlight.Value>
</Highlight.Item>
</Highlight.Layout>
</Card>
#Extra content
A Highlight.Item
component can contain more than a Highlight.Title
and Highlight.Value
. Simply add the extra content as another child. Correct spacing will automatically be applied.
Number
The answer to life, the universe, and everything.
Progress
<Card>
<Highlight.Layout aria-label="Highlights">
<Highlight.Item>
<Highlight.Title>Number</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={42} format="number" />
</Highlight.Value>
<Paragraph tone="subtle">The answer to life, the universe, and everything.</Paragraph>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>Progress</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={0.5484} format="percent" />
</Highlight.Value>
<ProgressBar value={54.84} total={100} />
</Highlight.Item>
</Highlight.Layout>
</Card>
#No padding
Use the noPadding
property to remove a Highlight.Item
component's padding.
Padding
Padding
<Card>
<Highlight.Layout aria-label="Highlights">
<Highlight.Item>
<Highlight.Title>Padding</Highlight.Title>
<Highlight.Value>Yes</Highlight.Value>
</Highlight.Item>
<Highlight.Item noPadding>
<Highlight.Title>Padding</Highlight.Title>
<Highlight.Value>No</Highlight.Value>
</Highlight.Item>
</Highlight.Layout>
</Card>
#No gap
Use the noGap
property to remove the space between the title, value, and other children elements nested inside a Highlight.Item
component.
Gap
Gap
<Card>
<Highlight.Layout aria-label="Highlights">
<Highlight.Item>
<Highlight.Title>Gap</Highlight.Title>
<Highlight.Value>Yes</Highlight.Value>
</Highlight.Item>
<Highlight.Item noGap>
<Highlight.Title>Gap</Highlight.Title>
<Highlight.Value>No</Highlight.Value>
</Highlight.Item>
</Highlight.Layout>
</Card>
#Compact
Use the compact
property of the Highlight.Layout
compontent to render a smaller, bordered Highlight component. This version is intended for use inside containers other than a Card, such as a Side Panel or Modal.
Number
Percentage
Currency
Empty
<Highlight.Layout aria-label="Highlights" compact>
<Highlight.Item>
<Highlight.Title headingLevel="h5">Number</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={20492} format="number" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>Percentage</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={0.5484} format="percent" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>Currency</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={1234567} format="currency" />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>Empty</Highlight.Title>
<Highlight.Value>
<FormattedNumber number={null} />
</Highlight.Value>
</Highlight.Item>
<Highlight.Item>
<Highlight.Title>
<Tooltip variant={{ type: "text" }} content="This title has a tooltip.">
Tooltip
</Tooltip>
</Highlight.Title>
<Highlight.Value>Yes</Highlight.Value>
</Highlight.Item>
</Highlight.Layout>
#Properties
#Highlight.Layout
Number
Percentage
Currency
Empty
Property | Description | Defined | Value |
---|---|---|---|
aria-labelRequired | string Labels the group of highlights. | ||
childrenOptional | element The content (highlight items) of the highlight section | ||
compactOptional | boolean Adds rounded border and reduces padding, spacing, and font-size | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) |
#Highlight.Item
Number
Property | Description | Defined | Value |
---|---|---|---|
childrenOptional | element The content of the highlight | ||
noPaddingOptional | boolean Removes the highlight's padding | ||
noGapOptional | boolean Removes the highlight's gap | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) |
#Highlight.Title
Number
Property | Description | Defined | Value |
---|---|---|---|
childrenOptional | element The content (label) of the title | ||
headingLevelOptional | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" The heading level of the title (defaults to h3) | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) |
#Highlight.Value
Property | Description | Defined | Value |
---|---|---|---|
childrenOptional | element The content (label) of the value | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications