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LjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D&colorA=16161d&style=flat-square)

# Magma 2
---

## Install with an AI agent

This package ships an agent-readable install guide, versioned with the package. Point
your coding agent (Claude Code, etc.) at it and let it wire up styles, fonts, icons and
component registration, asking you only for what it cannot detect from your project:

> Read `node_modules/@maggioli-design-system/magma/AGENTS.md` and follow it to install
> Magma into this project.

The detailed steps live under `agents/` in this package.

#### Required versions

Use the versions of `@maggioli-design-system/design-tokens` and `@maggioli-design-system/styles` matching your magma major version:

| magma | design-tokens | styles |
| :--- | :--- | :--- |
| `1.x` (before Magma 2) | `13.x` (latest `13.7.2`) | `15.x` (latest `15.11.1`) |
| `2.0.0-alpha.0` to `2.0.0-beta.3` (prereleases) | `14.x` | `16.x` |
| `2.x` and later | `>= 15` | `>= 17` |

#### Tones name changes

Now tones have new names to make them more consistent with the rest of the system and to be more semantically correct.

| V1 | V2 | V1 compatibility |
|---------|---------|-------------|
| `strong`  | `strong`  | ✅ |
| `weak`    | `weak`    | ✅ |
| `ghost`   | `outline` | ⚠️ |
| `quiet`   | `text` or `weak` (see below) | ⚠️ |

`quiet → text` only applies to the components whose v2 tone set includes `text`: `mds-button`,
`mds-radial-menu` and `mds-radial-menu-item`. Every other component dropped `quiet` without
gaining `text` (e.g. `mds-banner`, `mds-label`), so there the closest replacement is `weak`.
The [migration codemod](../codemod/README.md) applies exactly this mapping.

#### Design tokens

- ⚠️ added `text-box` css module with vertically treats text nodes with a better optical alignment.
- ✅ Added additional box shadow tokens.
- ✅ CSS tokens are now dynamically calculated with `calc()` method instead of hardcoded values.

#### Styles changes

- ⚠️ Library is now using tailwind 4 instead of 3, this means the config is now CSS custom properties based instad of pure javascript configuration.
- ✅ Added `--magma-corner-shape` to style the corner shape of the components globally.

#### Component changes

| Change | Component | Description |
|---------|---------|-------------|
| ⚠️ | `mds-text`                 | added `text-box` css module with vertically treats text nodes with a better optical alignment.
| ⚠️ | `mds-banner`               | Removed old `quiet` tone which is NOT replaced with `text` tone. |
| ⚠️ | `mds-breadcrumb`           | Now item requires `label` attribute to be set. |
| ⚠️ | `mds-calendar`             | Boolean props inverted to the negative form, every default is now `false`: `rangePicker` → `singlePicker`, `showPreviousButton` → `hidePreviousButton`, `showNextButton` → `hideNextButton`, `showPreselection` → `hidePreselection`. The [migration codemod](../codemod/README.md) rewrites them. |
| ✅ | `mds-file`                  | Added download icon on hover to make component more explicit. |
| ✅ | `mds-table`                | Added batch actions to the table when rows are selectable. |
| ✅ | `mds-header-bar`           | The overlay blur effect is now applied progressively rather than sharply outlined. |
| ✅ | `mds-button`               | Added `label` attribute to the component. |
| ✅ | `mds-modal`                | Added a fixed position to `header` and `footer` slotted elements |
| ✅ | `mds-input-range`          | Changed appearance of the component to be more consistent with the rest of the system. |
| ✅ | `mds-accordion-item`       | Changed the toggle arrow icon to be more visually constent and semantically clear. |
| ✅ | `mds-accordion-timer-item` | Changed the toggle arrow icon to be more visually constent and semantically clear. |
| ✅ | `mds-details`              | Changed the toggle arrow icon to be more visually constent and semantically clear. |


### Breaking changes

---

## Maggioli Design System Web-Component

Questa libreria fornisce una lista di componenti basati sullo standard web-component agnostici rispetto ai framework Javascript

Fa uso della libreria [@maggioli-design-system/styles](https://www.npmjs.com/package/@maggioli-design-system/styles) per gli sitli dei componenti

## Architecture

One build makes the whole package: the slug dictionary, the guides for agents, the components
through the output targets of Stencil (which also write the sources of the React and Angular
wrappers), the docs of each component, the API snapshot, the lint and the MCP server, and the
images of the previews of the patterns, rendered on the components just built (#1243: the build
needs a browser, as `render_preview` does).

```mermaid
flowchart LR
  DT["design-tokens<br/>dist/dtcg, for the checks"]
  ST["styles<br/>the Tailwind theme"]
  SI["svg-icons<br/>dist/iconsauce.json"]
  AGD["docs/agents<br/>the guides, the patterns"]
  LINT["lint<br/>its sources"]
  MCP["mcp<br/>its sources"]
  ID["identity<br/>logo-magma.svg"]
  subgraph wc["stencil<br/>package @maggioli-design-system/magma"]
    BUILD["stencil build<br/>118 mds-* components, build.icons"]
    DOCS["agent docs, API snapshot<br/>sync-agent-docs, component-docs"]
    BL["scripts/build-lint.ts<br/>dist/lint, dist/mcp"]
    IMG["scripts/preview-images.ts<br/>the images of the previews"]
    BUILD --> DOCS --> IMG
  end
  DT & ST & SI --> BUILD
  AGD --> DOCS
  LINT & MCP & ID --> BL
  MCP -->|"renderPreviewImages"| IMG
  BUILD -->|"src/, one module per tag"| RE["stencil-react"]
  BUILD -->|"stencil-generated/"| AN["stencil-angular"]
  BUILD -.->|"./components, ./loader, ./hydrate, ./services"| APP(["consumer app"])
  BUILD -->|"dist/magma-components, loaded by its pages"| STU["studio"]
  DOCS -->|"documentation.json"| CM["codemod"]
  DOCS -->|"documentation.json"| STU
  DOCS -->|"magma.api.txt"| RISK["check.pr-risk"]
  DOCS -.->|"AGENTS.md, agents/"| AGENT(["the agent of a consumer project"])
  DOCS -.->|"documentation.json"| SITE(["docs site"])
  IMG -.->|"agents/patterns/previews/*.webp"| SITE
  BL -.->|"./eslint, ./stylelint, magma-mcp"| AGENT
  class AGD,MCP,DOCS,BL,IMG,AGENT ai
  class SI,ID assets
  class DT,ST,STU visual
  class BUILD,RE,AN components
  class LINT,CM,RISK tooling
  class APP,SITE outside
  class wc area
  classDef ai fill:#efe5ff,stroke:#8250df,color:#3e1f79
  classDef assets fill:#fff1d6,stroke:#bf8700,color:#5c3d00
  classDef visual fill:#dcf5ec,stroke:#1a7f64,color:#0b4a3a
  classDef components fill:#ddf0ff,stroke:#0969da,color:#0a3069
  classDef tooling fill:#eceff3,stroke:#57606a,color:#24292f
  classDef outside fill:#ffffff,stroke:#8c959f,color:#24292f
  classDef area fill:none,stroke:#8c959f
```

Rectangles: this repository; rounded boxes: outside it. Solid arrows: inside the repository;
dashed: where the package is installed. Labels: the file, export or command that crosses.
Colours: purple ai, amber assets, teal visual, blue components, grey tooling, white outside
([convention](../../docs/ARCHITECTURE.md#diagrams-of-the-projects)).

## Installation

```
npm i '@maggioli-design-system/magma'
```

## Define Components

The recommended entry point is `@maggioli-design-system/magma/components`: import only
the components you use and the bundler drops the rest.

```js
// insert in bootstrap file of client part of your application

import {
  defineCustomElementMdsButton,
  defineCustomElementMdsIcon,
} from '@maggioli-design-system/magma/components';

defineCustomElementMdsButton();
defineCustomElementMdsIcon();
```

Each `defineCustomElement*` registers the component's children recursively, so only the
tags you write yourself need to be listed. A per-component deep import is available too:

```js
import { defineCustomElement } from '@maggioli-design-system/magma/components/mds-button.js';
```

The lazy loader registers every `mds-*` tag in one call. It is simpler, but nothing can
be tree-shaken away - use it only when the app needs most of the library.

```js
import { defineCustomElements } from '@maggioli-design-system/magma/loader';

defineCustomElements();
```

Do not mix the two entry points in the same app: they are separate builds of the same
components.

Without a bundler, a plain HTML page can load the ES2017 build of the loader as a file: it
imports only relative paths, so it works from a CDN that serves npm packages or from your own
copy of the package folder. The URL is a file path, not a package specifier, so `exports` does
not apply.

```html
<html>
  <head>
    <script type="module">
      import { defineCustomElements } from 'https://cdn.jsdelivr.net/npm/@maggioli-design-system/magma@2/loader/index.es2017.js';
      defineCustomElements();
    </script>
  </head>
  <body>
    <mds-text>Hello world</mds-text>
  </body>
</html>
```

## Style
Import style used by components

```css
/* global.css */

// color
@import "@maggioli-design-system/styles/dist/css/colors-rgb.css";

// font
@import '@fontsource/karla/400.css';
@import '@fontsource/karla/700.css';
@import '@fontsource/merriweather/400.css';
@import '@fontsource/merriweather/700.css';
@import '@fontsource/roboto-mono/400.css';
@import '@fontsource/roboto/500.css';
@import '@fontsource/roboto/700.css';
@import '@fontsource/roboto/900.css';
```

For more details see the [library](https://www.npmjs.com/package/@maggioli-design-system/styles)


## Icon
Tell the `mds-icon` component where to load the SVG icons from. The recommended way is the shared `IconsSetService` singleton, imported from the package root (`@maggioli-design-system/magma/services` is the same module). It sets the path in memory (no `sessionStorage`), wins over the `sessionStorage` key below and makes every mounted icon (re)load - so it works even where storage is blocked (incognito, sandboxed iframes, storage partitioning).

```js
import { IconsSetService } from '@maggioli-design-system/magma';

IconsSetService.setSvgPath('/assets/img/svg/');
```

Pass an absolute path (starting with `/`, resolved against the origin) or a full URL. It can be called before or after the icons mount.

Alternatively, set the `mdsIconSvgPath` key in `sessionStorage` before any icon mounts. This is optional and **may be blocked** by some browsers/contexts - prefer `IconsSetService` above.

```js
window.sessionStorage.setItem('mdsIconSvgPath', '/assets/img/svg/');
```

On a server (no `window`) `setSvgPath()` stores nothing: with SSR, call it in code the browser runs (in React, inside `useEffect`).


For greater interoperability between components and frameworks, see the specific libraries for [Angular](https://www.npmjs.com/package/@maggioli-design-system/magma-angular) and [React](https://www.npmjs.com/package/@maggioli-design-system/magma-react)

