Getting Started with code | Tokens
If utilizing a framework-specific package, there's no need for a separate installation.
The tokens package is inherently bundled as a dependency within the framework-specific offering.
Tokens
The @dhl-official/tokens package is a framework agnostic package that can be used in any project.
It provides:
- The full set of CSS rules, including resets.
- The full set of CSS variables derived from the DHL User Interface Library design tokens.
- The font files.
Install
- npm
- Yarn
- pnpm
- Bun
npm install @dhl-official/tokens
yarn add @dhl-official/tokens
pnpm add @dhl-official/tokens
bun add @dhl-official/tokens
CSS
You can import all of the CSS generated rules by importing the index.css file.
import "@dhl-official/tokens/index.css";
By including this file, basename.css, animation.css and font-face.css are included into your application too.
Additionally, CSS box-sizing rule is set to border-box and the html and body tags get the CSS font-family rule set to the value of the css variable --duil310-dui-font-family
@import "base.css";
@import "animations.css";
@import "font-face.css";
*,
*::before,
*::after {
box-sizing: border-box;
}
html,
body {
font-family: var(--duil310-dui-font-family);
}
html[lang^="ar"],
html[lang^="ar"] body {
--duil310-dui-font-family: var(--duil310-dui-font-family-arabic);
font-family: var(--duil310-dui-font-family-arabic);
font-style: normal;
}
html[lang^="vi"],
html[lang^="vi"] body {
--duil310-dui-font-family: var(--duil310-dui-font-family-vietnamese);
font-family: var(--duil310-dui-font-family-vietnamese);
font-style: normal;
}
html[lang^="he"],
html[lang^="he"] body {
--duil310-dui-font-family: var(--duil310-dui-font-family-hebrew);
font-family: var(--duil310-dui-font-family-hebrew);
font-style: normal;
}
CSS Variables
If you only want to import the CSS variables, you can either import them all or import them individually.
// import ALL the CSS variables
import "@dhl-official/tokens/base.css";
animation
To find the CSS variables name and their values for the colors, please refer to the Foundation | Animation Duration section.
// import only the animations @keyframes definitions
import "@dhl-official/tokens/animations.css";
// import only the CSS variables for the animation-duration definitions
import "@dhl-official/tokens/duration.css"
typography
To find the CSS variables name and their values for the colors, please refer to the Foundation | Typography section
// import only the @font-face rules
import "@dhl-official/tokens/font-face.css";
// import only the CSS variables for the typography definitions
import "@dhl-official/tokens/typography.css"
// import only the CSS variables for the font-family definitions
import "@dhl-official/tokens/font-family.css"
// import only the CSS variables for the font-family-arabic definitions
import "@dhl-official/tokens/font-family-arabic.css"
// import only the CSS variables for the font-family-vietnamese definitions
import "@dhl-official/tokens/font-family-vietnamese.css"
// import only the CSS variables for the font-family-hebrew definitions
import "@dhl-official/tokens/font-family-hebrew.css"
// import only the CSS variables for the font-size definitions
import "@dhl-official/tokens/font-size.css"
// import only the CSS variables for the font-weight definitions
import "@dhl-official/tokens/font-weight.css"
// import only the CSS variables for the letter-spacing definitions
import "@dhl-official/tokens/letter-spacing.css"
// import only the CSS variables for the letter-height definitions
import "@dhl-official/tokens/line-height.css"
gradients
To find the CSS variables name and their values for the colors, please refer to the Foundation | Gradient section.
// import only the CSS variables for the gradient definitions
import "@dhl-official/tokens/gradient.css"
radius
To find the CSS variables name and their values for the colors, please refer to the Foundation | Radius section.
// import only the CSS variables for the radius definitions
import "@dhl-official/tokens/radius.css"
border-width
To find the CSS variables name and their values for the colors, please refer to the Foundation | border-width section.
// import only the CSS variables for the border-width definitions
import "@dhl-official/tokens/border-width.css"
shadow
To find the CSS variables name and their values for the colors, please refer to the Foundation | Shadow section.
// import only the CSS variables for the shadow definitions
import "@dhl-official/tokens/shadow.css"
metric system
To find the CSS variables name and their values for the colors, please refer to the Foundation | Metric System section.
// import only the CSS variables for the space definitions
import "@dhl-official/tokens/space.css"
Fonts
import "@dhl-official/tokens/fonts/Delivery/Delivery_W_Bd.woff2"
import "@dhl-official/tokens/fonts/Delivery/Delivery_W_BdIt.woff2"
import "@dhl-official/tokens/fonts/Delivery/Delivery_W_CdBlk.woff2"
import "@dhl-official/tokens/fonts/Delivery/Delivery_W_CdLt.woff2"
import "@dhl-official/tokens/fonts/Delivery/Delivery_W_It.woff2"
import "@dhl-official/tokens/fonts/Delivery/Delivery_W_Lt.woff2"
import "@dhl-official/tokens/fonts/Delivery/Delivery_W_LtIt.woff2"
import "@dhl-official/tokens/fonts/Delivery/Delivery_W_Rg.woff2"
import "@dhl-official/tokens/fonts/DeliveryArabic/Delivery_Arabic.woff2"
import "@dhl-official/tokens/fonts/DeliveryVietnamese/Delivery_Viet.woff2"
import "@dhl-official/tokens/fonts/Assistant/Assistant_Light.woff2"
import "@dhl-official/tokens/fonts/Assistant/Assistant_Regular.woff2"
import "@dhl-official/tokens/fonts/Assistant/Assistant_Medium.woff2"
import "@dhl-official/tokens/fonts/Assistant/Assistant_Bold.woff2"
import "@dhl-official/tokens/fonts/Assistant/Assistant_ExtraBold.woff2"