Trend Formatter
Visually communicates trends (positive, negative, or neutral) in numerical data within highlights and tables, enhancing data comprehension.
#Variants
The TrendFormatter
consists of an icon arrow colored red, green, or gray to indicate whether the change is negative, positive, or neutral, respectively. It's accompanied by a number next to the arrow that displays the specific value of the change (e.g., "+5%", "-3.2%").
<TrendFormatter value={42} referenceValue={41} variant="green-positive" />
<TrendFormatter value={41} referenceValue={42} variant="green-positive" />
<TrendFormatter value={42} referenceValue={42} variant="green-positive" />
<br />
<TrendFormatter value={42} referenceValue={41} variant="red-positive" />
<TrendFormatter value={42} referenceValue={43} variant="red-positive" />
<TrendFormatter value={42} referenceValue={42} variant="red-positive" />
<br />
<TrendFormatter value={42} referenceValue={41} variant="neutral" />
<TrendFormatter value={41} referenceValue={42} variant="neutral" />
<TrendFormatter value={42} referenceValue={42} variant="neutral" />
#Alignment
The TrendFormatter
offers flexible alignment options, allowing you to position the trend indicator to the left or right of the numerical value. Choose the alignment that best complements the surrounding content and layout.
<TrendFormatter value={42} referenceValue={41} alignment="left" />
<TrendFormatter value={42} referenceValue={41} alignment="right" />
#BaseTrendFormatter
The BaseTrendFormatter
is a fundamental building block for creating custom trend indicators. It provides a standardized structure and default styling that can be easily extended and customized to match your specific design requirements.
<BaseTrendFormatter value={42} direction="down" color="green" />
<BaseTrendFormatter value={42} direction="down" color="red" />
<BaseTrendFormatter value={42} direction="down" color="gray" />
<br />
<BaseTrendFormatter value={42} direction="up" color="green" />
<BaseTrendFormatter value={42} direction="up" color="red" />
<BaseTrendFormatter value={42} direction="up" color="gray" />
<br />
<BaseTrendFormatter value={42} direction="neutral" />
<br />
<BaseTrendFormatter value={42} direction="down" color="green" alignment="right" />
<BaseTrendFormatter value={42} direction="down" color="red" alignment="right" />
<BaseTrendFormatter value={42} direction="down" color="gray" alignment="right" />
<br />
<BaseTrendFormatter value={42} direction="up" color="green" alignment="right" />
<BaseTrendFormatter value={42} direction="up" color="red" alignment="right" />
<BaseTrendFormatter value={42} direction="up" color="gray" alignment="right" />
<br />
<BaseTrendFormatter value={42} direction="neutral" alignment="left" />
<BaseTrendFormatter value={42} direction="neutral" alignment="right" />
#Properties
#TrendFormatter
Property | Description | Defined | Value |
---|---|---|---|
valueRequired | number The trend value | ||
referenceValueRequired | number The reference value | ||
classNameOptional | string Custom className that's applied to the outermost element (only intended for special cases) | ||
onKeyDownOptional | function Callback for onKeyDown event | ||
onBlurOptional | function Callback for onBlur event | ||
onMouseDownOptional | function Callback for onMouseDown event | ||
aria-describedbyOptional | string ID of an an element that describes the trend content | ||
aria-labelOptional | string Label of the trend | ||
aria-labelledbyOptional | string ID of an an element that labels this trend | ||
data-observe-keyOptional | string Unique string, used by external script e.g. for event tracking | ||
styleOptional | object Style object to apply custom inline styles (only intended for special cases) | ||
colorOptional | string The arrow color | ||
alignmentOptional | "left" | "right" Whether the arrow comes before or after the number | ||
tabIndexOptional | number Tab index of the outermost HTML element of the component | ||
onMouseEnterOptional | function Callback for onMouseEnter event | ||
onMouseLeaveOptional | function Callback for onMouseLeave event | ||
onFocusOptional | function Callback for onFocus event | ||
variantOptional | "green-positive" | "neutral" | "red-positive" |
#BaseTrendFormatter
Property | Description | Defined | Value |
---|---|---|---|
valueRequired | | string | number The trend value | ||
directionRequired | "down" | "neutral" | "up" The arrow orientation | ||
colorOptional | string The arrow color | ||
alignmentOptional | "left" | "right" Whether the arrow comes before or after the number | ||
aria-labelOptional | string Label of the trend | ||
aria-labelledbyOptional | string ID of an an element that labels this trend | ||
aria-describedbyOptional | string ID of an an element that describes the trend content | ||
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) | ||
tabIndexOptional | number Tab index of the outermost HTML element of the component | ||
onKeyDownOptional | function Callback for onKeyDown event | ||
onMouseDownOptional | function Callback for onMouseDown event | ||
onMouseEnterOptional | function Callback for onMouseEnter event | ||
onMouseLeaveOptional | function Callback for onMouseLeave event | ||
onFocusOptional | function Callback for onFocus event | ||
onBlurOptional | function Callback for onBlur event |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications