Our new CDN server will be the preferred method of installation going forward. If you are a Red Hat associate
and have questions or comments about the CDN or installation process please connect with us on Slack.
## How to install
There are three ways you can install the Red Hat Design System's Web Components: Red Hat CDN, NPM,
or via a third party CDN like jsDelivr. Each element's "Code" page includes the same installation
information with code snippets that are specific to that element.
- [Red Hat CDN](#red-hat-cdn)
- [NPM](#npm)
- [jsDelivr CDN](#jsdelivr-cdn)
### Tokens CSS
In addition to loading JavaScript, RHDS strongly encourages loading our design [tokens](/tokens/)
via a `` tag in the `
`. Designers and developers use tokens instead of hard-coded values
to create flexible yet seamless user experiences across a variety of Red Hat platforms and
technologies. See our [Tokens Installation](/get-started/developers/tokens/) page for further details.
## Red Hat CDN
The recommended way to load the Red Hat Design System (RHDS) on Red Hat websites and applications is through the [Red Hat Digital Experience CDN](https://www.redhatstatic.com/dssf-001) using an [import map][importmap].
**Note:** Due to current information security standards regarding access to the CDN, the CDN only allows requests from `*.redhat.com` domains. This means for local development an `/etc/hosts` change to forward `localhost` to something like `dev.foo.redhat.com` and navigating to that instead of `localhost` is required. If you need help setting this up for your project please reach out on [Slack](/support/#contact-us).
### Using import maps
- If you have full control over the page you are using, add an import map to the
`` pointing to the CDN or update any existing import map.
- If you are not responsible for the page's ``, request that the page owner makes the
change on your behalf.
#### Base import map
Below is the base import map for using version {{ pkg.version }} RHDS components.
```html rhcodeblock
```
### Loading individual elements
Once the import map is established, you can load individual elements using a [bare module specifier][barespec].
For example, you can load `` using the following:
```html rhcodeblock
Primary
```
Note that modules may be placed in the ``. Since they are deferred by
default, they will not block rendering. Multiple import statements on the same page to the same
script in this manner are completely safe, and will be deduplicated, so the browser
won't make any additional calls as long as they use the same bare module specifier.
### Still need CDN v1 bundles?
If you'd like to continue to use the bundles available in v1 of our CDN, they are still available on our new server at the following URL:
```html rhcodeblock
https://www.redhatstatic.com/dssf-001/v1-alpha/
```
To migrate, change /dx/v1-alpha/ to /dssf-001/v1-alpha/ in your current URLs.
## NPM
Install RHDS using your team's preferred NPM package manager.
```sh rhcodeblock
npm install @rhds/elements
```
Once that's been accomplished, you will need to use a bundler to resolve the
bare module specifiers and optionally optimize the package for your site's
particular use case and needs. Comprehensive guides to bundling are beyond the
scope of this page; read more about bundlers on their websites:
- [Rollup][rollup]
- [esbuild][esbuild]
- [Parcel][parcel]
- [Webpack][webpack]
## jsDelivr CDN
Public CDNs
jsDelivr and other public CDNs should not be used on corporate domains. Use
them for development purposes only!
Add an [import map][importmap] to the ``, pointing to the jsDelivr CDN, or update
any existing import map. This provides the same functionality as the Red Hat CDN but uses
the publicly accessible jsDelivr CDN.
```html rhcodeblock
```
Once the import map is established, you can load individual elements using the same approach as with
the Red Hat CDN. For example, you can load `` using:
```html rhcodeblock
Primary
```
Note that modules may be placed in the ``. Since they are deferred by default, they will not
block rendering.
## Lightdom CSS
Some elements require you to load "Lightdom CSS" stylesheets, which are necessary
for styling deeply slotted child elements. In some cases, these may also help reduce
some [Cumulative Layout Shift (CLS)][cls] experience before the element has fully
initialized, but are not intended to be used without initializing the element or by
themselves to prevent CLS.
Red Hat CDN
```html rhcodeblock
```
Third party CDN
```html rhcodeblock
```
If you're looking for lightdom stylesheets on a third party CDN, the URL patterns follow a similar
convention.
Note: a future version of RHDS will remove the requirement to manually
load these stylesheets
## Lightdom undefined CSS
Some elements have provided an _optional_ `-lightdom-undefined.css` file to aid in limiting
[CLS][cls] as much as possible, by styling some parts of the element before it has fully
initialized (i.e., `:not(:defined)`). These stylesheets are inherently different than the
required "Lightdom CSS" mentioned above, and are only a temporary stop-gap until
[Delcarative Shadow DOM][dsd] is more widely available; at which point the undefined stylesheets will
no longer be needed and will become deprecated.
```html rhcodeblock
```
Designers
To get started using our design system as a designer, go to the Designers page.