Skip to content

Reset

Because the styleguide is used side-by-side with existing component styles, a reset is applied at the root of each CDS component. This reset is necessary because the current website styles apply a lot of styles directly to HTML elements, which would otherwise leak into CDS components.

Wrap every CDS component with .tng-root:

<div class="tng-root">…</div>

The reset also lands on a handful of known application roots automatically — the AEM Headless root ([data-app-root]), Storybook’s #storybook-root, and the Astro page body — so inside those hosts you usually get it for free.

React portals break that assumption. createPortal renders its subtree into a container elsewhere in the document — typically appended to <body> — which sits outside the detected application root. The reset never reaches it, so the legacy page styles it was meant to neutralise leak straight back into whatever the portal renders: dropdowns, dialogs, tooltips.

Give the portalled element its own .tng-root when you create it:

import { createPortal } from 'react-dom';
function Popover({ children }) {
return createPortal(
<div className="tng-root tng-popover">{children}</div>,
document.body,
);
}

Any DOM rendered outside your app’s root — a portal, a manually appended overlay node — needs .tng-root for the same reason.

When a legacy component is placed inside a tng-root container, the CDS reset will strip its expected styles. To restore the legacy styles for that component, wrap its root element with the tng-legacy-apply class.

<div class="tng-root">
<!-- CDS components render normally -->
<div class="tng-legacy-apply">
<!-- Legacy component with legacy styles restored -->
</div>
</div>

This is useful when you need to embed an existing legacy component within a new CDS layout and want it to retain its original styling.

Components strip native element styling through opt-in .tng-reset-* classes. They work without a .tng-root, and each component that renders the element already applies its reset, so you only add one by hand to a raw element you style yourself.

Class Element Resets
.tng-reset-button <button> appearance, background, border, border-radius, color, font, margin, padding
.tng-reset-anchor <a> color, text-decoration
.tng-reset-input <input> appearance, background, border, border-radius, color, font, margin, padding
.tng-reset-list <ul>, <ol>, <dl> list-style, margin, padding
.tng-reset-summary <summary> the disclosure marker
.tng-reset-dialog <dialog> background, border, padding, inset and sizing
<button class="tng-reset-button" type="button">…</button>
<ul class="tng-reset-list" role="list">
…
</ul>

A reset list still needs role="list": Safari drops the list role from a list without markers.

The reset input keeps its outline, so pair it with a visible focus style.

Inside a root, the global reset still strips <dialog> and <ul role="list"> / <ol role="list"> without a class. A future major removes that, so add the class instead of relying on it.