# Education Design System

![Test CI](https://github.com/chanzuckerberg/edu-design-system/actions/workflows/test.yml/badge.svg) [![Release](https://github.com/chanzuckerberg/edu-design-system/actions/workflows/release.yml/badge.svg)](https://github.com/chanzuckerberg/edu-design-system/actions/workflows/release.yml) [![codecov](https://codecov.io/gh/chanzuckerberg/edu-design-system/branch/main/graph/badge.svg)](https://codecov.io/gh/chanzuckerberg/edu-design-system) ![Release](https://img.shields.io/github/v/release/chanzuckerberg/edu-design-system) ![GitHub commits since latest release (branch)](https://img.shields.io/github/commits-since/chanzuckerberg/edu-design-system/latest/next)



The Education Design System (EDS) is a repository of building blocks, implementing the [Chan Zuckerberg Initiative Education](https://chanzuckerberg.com/education/) Design System. It contains:
- Design Tokens defining the color, sizes, and other details used in the system
- Tooling/Configuration for using and updating the tokens in a consuming application
- [Presentational](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0) components implementing the common controls provided by the EDS toolkit
- Guidelines for creating recipes using EDS, composing the above components

## Prerequisites

Currently, EDS supports the following:

* React 19 or above (tested with React 19.x)
* Tailwind 3.x

### Browser support

EDS supports the following browsers, on desktop and mobile. The same list is declared as `browserslist` in `package.json`.

| Browser          | Minimum version |
| ---------------- | --------------- |
| Chrome           | 123             |
| Edge             | 123             |
| Firefox          | 128             |
| Safari           | 17.5            |
| Safari (iOS)     | 17.5            |

These features set the floor:

| Feature | Used by | Chrome / Edge | Firefox | Safari |
| ------- | ------- | ------------- | ------- | ------ |
| CSS [`light-dark()`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark) | Theming (`body.css`, component styles) | 123 | 120 | 17.5 |
| [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) | `Avatar` | 87 | 125 | 14.1 |
| CSS [relative colors](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_colors/Relative_colors) (`rgb(from …)`) | `Avatar`, `Modal`, `ScrollWrapper` | 119 | 128 | 16.4 |

#### Vite 8 and Lightning CSS

Vite 8 minifies CSS with Lightning CSS, which lowers syntax to `build.cssTarget`. The default target sits below `light-dark()` support, so Vite rewrites EDS's `light-dark()` into `--lightningcss-light` / `--lightningcss-dark` variable fallbacks. Set `build.cssTarget` to the EDS floor to keep it native:

```ts
// vite.config.ts
export default defineConfig({
  build: {
    cssTarget: ['chrome123', 'edge123', 'firefox128', 'safari17.5', 'ios17.5'],
  },
});
```

`css.lightningcss.targets` doesn't help here: Vite's minifier overrides it with `build.cssTarget`.

## Installation

First, install the package.

```bash
# using npm
npm install --save @chanzuckerberg/eds

# or using Yarn
yarn add @chanzuckerberg/eds
```

## Setting up EDS in your project

Import the EDS stylesheets somewhere in your app root, e.g. an `init.ts` or `app.ts` file:

```js
import '@chanzuckerberg/eds/index.css'; // Includes relevant styles and tokens for EDS
```

Also, include this in your base / reset styles to allow configuation of the pixel-to-rem ratio:

```css
html {
  font-size: calc(var(--eds-typography-base-size) * 1px); /* Sets the default pixel-to-rem ratio */
  /* also set a default html/body font family, if desired by using --eds-typography-font-family-1, etc. */
}
```

Lastly, add `<link>` or other files to load fonts into your project. EDS provides fallbacks for the three font families, and can support fonts from [Adobe][adobe-fonts], [Google][google-fonts], or other hosting / local sources:

```html
<!-- Handling for font-family-1 : local file --> 
<link rel="stylesheet" href="https://local-domain.org/fonts.css">

<!-- Handling for font-family-2 : adobe font -->
<link rel="stylesheet" href="https://use.typekit.net/<example>.css">

<!-- Handling for font-family-3 : google font-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=<test-font-family...>" rel="stylesheet">

```

[adobe-fonts]: https://helpx.adobe.com/fonts/using/add-fonts-website.html
[google-fonts]: https://fonts.google.com/knowledge/using_type/using_web_fonts

### Theming Setup

For more information and configuration options, read the [Theming Overview][theming-docs].

### Semantic Icon Setup

A few icons are EDS's own rather than yours to pass in: the close button on a `Modal`, the chevron marking a `Menu.Button` as expandable, the icon carrying a notification's status. Each marks one role, and a role only reads as itself if it looks the same everywhere it appears, so they come from `IconProvider` instead of from props on each component.

Every role ships with a default, so skip this if those suit you. To change one, wrap your app once and name only the roles you want to differ:

```jsx
import { IconProvider } from '@chanzuckerberg/eds';

// Defined outside render: a new object on every render re-renders everything below it.
const icons = { back: 'arrow-left', expand: 'unfold-more' };

<IconProvider icons={icons}>
  <App />
</IconProvider>;
```

Each role takes an EDS icon name or a node, and anything left out keeps the icon it had. For the full list of roles and their defaults, read the [IconProvider docs][icon-provider-docs].

[icon-provider-docs]: https://chanzuckerberg.github.io/edu-design-system/?path=/docs/components-iconprovider--summary-docs

## EDS Component Usage

Import any of the components from the top-level package:

```jsx
// Import components by name at the top of your file
import { Heading } from '@chanzuckerberg/eds';

// ...and then use them in your React components:

<Heading preset="headline-lg">
  Coffee!
</Heading>
```

EDS provides a [suite](https://chanzuckerberg.github.io/edu-design-system/) of components for use, and documentation for available props and overrides.

## Development

This project is under **active development**. See [CONTRIBUTING.md][contributing] for more information on how to contribute to the Design System and IDE (VSCode) setup. Also, read our [guidelines][guidelines] for additional information on how we build EDS components.

Instead, if you want to report an issue, you can [open an issue][gh-issue].

This project is governed under the [Contributor Covenant][contribution-covenant] code of conduct.

[contributing]: ./docs/CONTRIBUTING.md
[guidelines]: https://chanzuckerberg.github.io/edu-design-system/?path=/docs/documentation-contributor-guidelines-code-guidelines--summary-docs
[gh-issue]: https://github.com/chanzuckerberg/edu-design-system/issues
[contribution-covenant]: https://www.contributor-covenant.org/
[theming-docs]: https://chanzuckerberg.github.io/edu-design-system/?path=/docs/documentation-theming-using-eds-theming--summary-docs

## Reporting Security Issues

See our [Security Readme](https://github.com/chanzuckerberg/edu-design-system/blob/main/SECURITY.md).

## Code of Conduct

This project adheres to the Contributor Covenant [code of conduct](https://github.com/chanzuckerberg/.github/blob/master/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. 
Please report unacceptable behavior to [opensource@chanzuckerberg.com](mailto:opensource@chanzuckerberg.com).
