Files
ionic-framework/core/src/foundations
Bernardo Cardoso f9a936b875 fix(tokens): remove style dictionary scripts and reuse os tokens logic (#30786)
Issue number: internal

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

This pull request updates the design token build system and its
dependencies, simplifying the process and removing custom scripts in
favor of using the latest features of the `outsystems-design-tokens`
package. The changes modernize how design tokens are generated and
maintained, reducing custom code and leveraging upstream improvements.

Key changes include:

**Build Process Simplification:**
- The custom design token generation scripts
(`core/scripts/tokens/index.mjs` and `core/scripts/tokens/utils.mjs`)
have been removed. Token generation is now handled directly via the
`outsystems-design-tokens` package using an `npx` command in the
`build.tokens` script. This reduces maintenance overhead and keeps the
build process aligned with upstream best practices.
[[1]](diffhunk://#diff-0b9870c62ff80af860467e2541bba0b9ba5e7280b12bea6eeb124b1d174efbcfL1-L188)
[[2]](diffhunk://#diff-8b5c339d9dd13300954577213f84a443321a0d6477acd7553787fbcc00ce8cabL1-L320)
[[3]](diffhunk://#diff-7f67769260741e2563407af949f7e54fbf0431d1c607933f6e8a8094e3219e26L83-R82)

**Dependency Updates:**
- Updated `outsystems-design-tokens` to version `1.3.3` and
`style-dictionary` to version `5.1.1` in both `package.json` and
`package-lock.json`. This ensures compatibility with the latest features
and bug fixes and removes the need to specify `style-dictionary`
directly as a dependency.
[[1]](diffhunk://#diff-4ff996db8bece1eded512c3b97a6bde33622f94bb387634ef32496d832d57744L47-L52)
[[2]](diffhunk://#diff-4ff996db8bece1eded512c3b97a6bde33622f94bb387634ef32496d832d57744L9592-R9598)
[[3]](diffhunk://#diff-4ff996db8bece1eded512c3b97a6bde33622f94bb387634ef32496d832d57744L11137-R11138)
[[4]](diffhunk://#diff-7f67769260741e2563407af949f7e54fbf0431d1c607933f6e8a8094e3219e26L69-L74)

**SCSS Utility Import:**
- The `@forward "../../foundations/ionic.utility";` statement was
removed from `core/src/css/ionic/utils.bundle.ionic.scss`, likely
because the utility SCSS is now generated and managed by the new token
build process.

Removed CSS tests for Ionic theme, as they relied heavily on testing the
effect of the utility-classes, that are no longer created on the ionic
scope.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->

---------

Co-authored-by: ionitron <hi@ionicframework.com>
2025-11-20 13:02:37 -05:00
..

Ionic Design Tokens

What are Design Tokens?

Design Tokens are an abstract and universal language to store Design System values, creating a single source of truth that is tech-agnostic and easily scalable and extendable for various outputs such as CSS, SCSS, iOS, Android, JSON, and more. Typically stored in JSON format, they facilitate seamless scalability for integration with any language or Design Tool like Figma or Sketch.

Design tokens represent small, repeated design decisions that make up a design system's visual style. Tokens replace static values, like hex codes representing colors, with descriptive and intuitive names.

Design Tokens Architecture

The Ionic Design Tokens come from the outsystems-design-tokens repo.

Using the outsystems-design-tokens package, we use its npx run build.tokens to pass our configuration file, that will generate one file inside core/src/foundations:

  • ionic.vars.scss - SCSS variables, based on the native ones, that are used internally on all CSS/SCSS code.

This refers, more or less, to what's known as System Tokens, which are decisions that systematize the design language for a specific theme or context.

Currently, Reference Tokens and Component Tokens are not used. Instead we are defining a base architecture for system tokens, that will inform the :root and global SCSS variables, and then we let the SCSS architecture propagate that to the Components.

Format

The latest W3C Design Tokens Format was adhered to, this is a recent effort to normalize the nomenclature of Design Tokens.

The nomenclature has the following structure: type - type variation - modifier name - $value

Example:

{
  "color": {
    "$type": "color",
    "primary": {
      "10": {
        "$value": "#f7faff"
      }
    }
  }
}

The index.js script, on the scripts/tokens folder, is responsible for generating SCSS variables and utility classes, will follow the same nomenclature: prefix - CSS property name - type variation - modifier name.

Examples:

SCSS Variable:

$ion-semantics-primary-300

Managing the Design Tokens

It's not expected that the tokens need to be changed frequently. This represents the base of all the Ionic Design System and any change to them should be taken carefully, synced with the UX/UI Team and reviewed by other devs.

With the current architecture, this management is done on the outsystems-design-tokens repo, and its dependency is updated here as needed.

How to use

It's very important to highlight that only the Ionic Theme supports these tokens and they should not be used for md/ios themes.

Within the component scope, variables from these global tokens should always be used. There should be no hardcoded values on component scope that relate to any of the existing tokens.

To prevent differences between components implementation, a global partial was created - ionic.globals.scss - that forwards all the necessary foundations, functions and mixins, relevant to the Ionic Theme.

Usage example (Chip Component):

@use '../../themes/ionic/ionic.globals.scss' as globals;

:host {
  --background: #{globals.$ion-primitives-neutral-100};
  color: globals.$ion-primitives-neutral-900;
  @include globals.font-smoothing;
}