# Foundations

> The design tokens every Eunomia component and theme is built from: colors, spacing, radius, shadows, heights and typography, as CSS custom properties.

Source: https://eunomia-ds.com/foundations/

The design tokens every component and theme is built from. Every token follows one of two naming conventions:

```css
--eun-[content]-[variant]      /* e.g. --eun-space-m, --eun-font-size-s */
--eun-color-[group]-[shade]    /* e.g. --eun-color-primary-500 */
```

Nothing here is a fixed value baked into a component: every size, color, radius, and shadow is a CSS custom property, switchable at runtime (see [Theming](https://eunomia-ds.com/theming/)).

Every size token above (space, radius, border width, height, font size, ...) is expressed in `rem`, which is always relative to the `font-size` set on `<html>` rather than any nearby parent. Every measurement given in this documentation assumes the browser default: `1rem = 16px`. An app that sets its own `font-size` on `<html>` (directly, or through a CSS reset using `%`) makes every Eunomia component inherit that scale instead: components render uniformly smaller or larger than what's documented here, not broken, just scaled.

## Import

These tokens only exist once a theme stylesheet is loaded; without one, components fall back to the same default values documented here. Include one of the 7 prebuilt palettes and add its class to your app root:

```html
<body class="eunomia-theme eunomia-violet-theme">
  <app-root></app-root>
</body>
```

How you get that stylesheet loaded depends on how your build handles CSS/Sass imports:

**HTML / any framework:**

```html
<link
  rel="stylesheet"
  href="node_modules/@eunomia/elements/styles/themes/prebuilt-themes/violet/eunomia-violet.theme.css"
/>
```

Works anywhere a plain `<link>` tag does: every theme ships compiled to `.css` next to its `.scss`, so no Sass step is needed.

**JavaScript:**

```js
import "@eunomia/core/styles/themes/prebuilt-themes/violet/eunomia-violet.theme.scss";
```

Needs a bundler that already handles CSS/Sass imports (Vite, webpack with `sass-loader`, etc.). The import itself has no exports, it's only there for the side effect of injecting the stylesheet.

**React:**

```js
// index.js / main.jsx, once, before rendering
import "@eunomia/core/styles/themes/prebuilt-themes/violet/eunomia-violet.theme.scss";
```

Same side-effect import, done once at the entry point (Create React App, Vite, or any webpack-based setup already resolve `.scss` imports).

**Next.js:**

```js
// app/layout.tsx (App Router) or pages/_app.tsx (Pages Router)
import "@eunomia/core/styles/themes/prebuilt-themes/violet/eunomia-violet.theme.scss";
```

Next.js only allows *global* CSS/Sass imports in these two files (root layout or `_app`), not inside a regular component. Server or client component doesn't matter here since it's a plain stylesheet import.

**Vue:**

```js
// main.js, once, before mounting the app
import "@eunomia/core/styles/themes/prebuilt-themes/violet/eunomia-violet.theme.scss";
```

Vue CLI and Vite both resolve `.scss` imports out of the box (Vite needs the `sass` package installed as a dev dependency).

**Angular:**

```json
{
  "styles": [
    "node_modules/@eunomia/core/styles/themes/prebuilt-themes/violet/eunomia-violet.theme.scss",
    "src/styles.scss"
  ]
}
```

Angular CLI compiles Sass by default, so add the theme file to the `styles` array in `angular.json`'s relevant build target instead of importing it from TypeScript.

For dark mode, use the `eunomia-violet-theme--dark` class instead (same import, just the class that follows it). Full detail (the 8 palettes, and generating a theme from your own two brand colors) is in [Get started](https://eunomia-ds.com/get-started/#4-theme-it) and [Prebuilt themes](https://eunomia-ds.com/theming/prebuilt-themes/).

- [Tokens](https://eunomia-ds.com/foundations/tokens/): Space, radius, border, height, shadow, grid utilities

- [Typography](https://eunomia-ds.com/foundations/typography/): Font family, sizes, weights

- [Color](https://eunomia-ds.com/foundations/color/): Grey scale, decorative, semantic states, neutral tokens

## Tokens

Spacing, radius, border width, height, shadow, and grid layout utilities, identical across every brand and mode.

- [Space](https://eunomia-ds.com/foundations/tokens/space/)

- [Radius](https://eunomia-ds.com/foundations/tokens/radius/)

- [Border width](https://eunomia-ds.com/foundations/tokens/border/)

- [Height](https://eunomia-ds.com/foundations/tokens/height/)

- [Shadow](https://eunomia-ds.com/foundations/tokens/shadow/)

- [Motion](https://eunomia-ds.com/foundations/tokens/motion/)

- [Grid utilities](https://eunomia-ds.com/foundations/tokens/utilities/)

See [Tokens overview](https://eunomia-ds.com/foundations/tokens/) for the full detail on every value.

## Typography

- [Font family](https://eunomia-ds.com/foundations/typography/font-family/)

- [Sizes](https://eunomia-ds.com/foundations/typography/sizes/)

- [Weights](https://eunomia-ds.com/foundations/typography/weights/)

See [Typography overview](https://eunomia-ds.com/foundations/typography/) for live specimens of every step.

## Color

- [Grey scale](https://eunomia-ds.com/foundations/color/grey-scale/)

- [Decorative](https://eunomia-ds.com/foundations/color/decorative/)

- [Semantic states](https://eunomia-ds.com/foundations/color/semantic-states/)

- [Neutral tokens](https://eunomia-ds.com/foundations/color/neutral-tokens/)

See [Color overview](https://eunomia-ds.com/foundations/color/) for every swatch on one page, or [Theming: Prebuilt themes](https://eunomia-ds.com/theming/prebuilt-themes/) for the brand-specific primary/secondary palettes.

## JavaScript helpers

Next to the tokens, a few helpers register no component, so they run anywhere, a server included. Import them from `@eunomia/elements`, which installs `@eunomia/core` for you:

| Module | Exports | See |
| --- | --- | --- |
| `@eunomia/elements/theme.js` | `initializeTheme`, `buildPalette`, `buildTints`, `buildThemeCss` | [Custom theme](https://eunomia-ds.com/theming/custom-theme/) |
| `@eunomia/elements/breakpoints.js` | `EUNOMIA_BREAKPOINTS`, `mediaBelow`, `mediaFrom` | [Breakpoints](https://eunomia-ds.com/foundations/breakpoints/) |
| `@eunomia/elements/time.js` | `debounce`, `throttle` | [Rate limiting](https://eunomia-ds.com/utilities/rate-limiting/) |
| `@eunomia/elements/locale.js` | `setDefaultLocale`, `getDefaultLocale` | below |

`setDefaultLocale(locale)` sets the locale every component uses unless it has its own `locale` attribute, and `getDefaultLocale()` returns it (`"en"` until it's set). An unknown locale shows English strings, never an error.

`@eunomia/core` also exports date, time zone and motion functions, `resolveLocale`/`resolveDictionary` in `locale.js`, and `parseBreakpointOrWidth`, `breakpointOrWidthConverter` and `breakpointWidth` in `breakpoints.js`. They're shared between the Eunomia packages, not a public API: they can change in any version.

## See also

- [Icons](https://eunomia-ds.com/icons/): the full `eun-icon` set, 1473 icons × 4 shapes, searchable and click-to-copy (its own page, not a foundation)
