|
| 1 | +import { Notification } from 'grommet'; |
| 2 | +import { BestPracticeGroup, Example } from '../../layouts'; |
| 3 | +import { ElementToken } from '../../examples'; |
| 4 | + |
| 5 | +In the HPE Design System, an "element" refers to a core UI building block. |
| 6 | + |
| 7 | +Elements can contain foundational items like text or icons, but "can't be broken down without ceasing to be functional." (source: [Atomic Design](https://atomicdesign.bradfrost.com/chapter-2/)) |
| 8 | + |
| 9 | +To understand what element tokens apply to, consider various UI components as levels from most fundamental to most composed: |
| 10 | + |
| 11 | +| Level | Example components | |
| 12 | +| --------------------------- | --------------------------------------------------- | |
| 13 | +| **1. Typography, controls** | text, anchor, checkbox, radio button, toggle switch | |
| 14 | +| **2. Elements** | button, input, select, menu, table cells | |
| 15 | +| **3. Layout/compositional** | card, modal, toolbars | |
| 16 | + |
| 17 | +Many common "elements" (corresponding directly to native HTML tags or roles like button, input, select, etc.) have [component-specific design tokens](/design-tokens/how-to-read-design-tokens#component) published. These design tokens reference element tokens. |
| 18 | + |
| 19 | +## When to use |
| 20 | + |
| 21 | +Use element tokens when there is not a component-specific token available for an element. For example, a team may be designing a new component that is not offered by the design system. They can use element tokens to ensure that the new component aligns and adapts with the rest of the sizing system. |
| 22 | + |
| 23 | +Do not use element tokens for compositional components like cards, lists, or toolbars. Instead, use [semantic tokens](/design-tokens/overview#semantic-tokens). |
| 24 | + |
| 25 | +## Element sizes |
| 26 | + |
| 27 | +Element sizes are used to ensure consistent sizing and alignment across layouts. Sizes "xsmall"-"xlarge" are available. |
| 28 | + |
| 29 | +## Supported design tokens |
| 30 | + |
| 31 | +The following design tokens exist for each element size. Replace `[size]` with the desired size (e.g., `xsmall`, `small`, `medium`, `large`, `xlarge`). |
| 32 | + |
| 33 | +| Property | Notes | Example | |
| 34 | +| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------- | |
| 35 | +| **element.[size].minHeight** | Ensures elements achieve the desired minimum height even if internal content varies. | <ElementToken token="ElementToken" /> | |
| 36 | +| **element.[size].width** | Use for fixed size components like avatar, spinner, etc. | <ElementToken token="width" /> | |
| 37 | +| **element.[size].height** | Use for fixed size components like avatar, spinner, etc. | <ElementToken token="height" /> | |
| 38 | +| **element.[size].paddingX.narrow** | Use for components that should have equal horizontal and vertical padding. Often this applies to square components like icon-only buttons. | <ElementToken token="paddingX.narrow" /> | |
| 39 | +| **element.[size].paddingX.default** | Use for standard horizontal padding. | <ElementToken token="paddingX.default" /> | |
| 40 | +| **element.[size].paddingX.wide** | Use for components that are fully rounded or need more horizontal affordance. | <ElementToken token="paddingX.wide" /> | |
| 41 | +| **element.[size].paddingY** | -- | <ElementToken token="paddingY" /> | |
| 42 | +| **element.[size].textToIconX** | Use for spacing between text and icon. | <ElementToken token="textToIconX" /> | |
| 43 | +| **element.[size].textToElementX** | Use for spacing between text and an internal control like a checkbox. | <ElementToken token="textToElementX" /> | |
| 44 | +| **element.[size].borderWidth** | -- | <ElementToken token="borderWidth" /> | |
| 45 | +| **element.[size].lineHeight** | -- | <ElementToken token="lineHeight" /> | |
| 46 | +| **element.[size].fontSize** | -- | <ElementToken token="fontSize" /> | |
| 47 | +| **element.[size].fontWeight** | -- | <ElementToken token="fontWeight" /> | |
| 48 | +| **element.[size].icon.size** | Applies to width and height of icon. | <ElementToken token="icon.size" /> | |
0 commit comments