# @sinoui/material-color-utilities

> Algorithms and utilities that power the Material Design 3 (M3) color system, including choosing theme colors from images and creating tones of colors; all in a new color space.

Latest version **0.2.5** (published 2023-02-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @sinoui/material-color-utilities
pnpm add @sinoui/material-color-utilities
yarn add @sinoui/material-color-utilities
bun add @sinoui/material-color-utilities
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2023-02-07 |
| First published | 2022-12-11 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 608.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2304 |
| Author | Material Eng |
| Maintainers | jackingliu, longniansheng, tianyanqiu, chenaihua, maitian0222 |
| Keywords | material, material design, material3, material you, color extraction, theming |

## Links

- npm: https://www.npmjs.com/package/@sinoui/material-color-utilities
- Repository: https://github.com/material-foundation/material-color-utilities
- Homepage: https://github.com/material-foundation/material-color-utilities/tree/main/typescript
- Issues: https://github.com/material-foundation/material-color-utilities/issues
- npm.io page: https://npm.io/package/@sinoui/material-color-utilities

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.4.0

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 0.2.5 (latest) — 2023-02-07
- 0.2.4 — 2023-01-17
- 0.2.3 — 2022-12-11
- 0.2.2 — 2022-12-11
- 0.2.1 — 2022-12-11

## README

# material-color-utilities

> 拷贝自 https://github.com/material-foundation/material-color-utilities 。主要用来解决无法在非 esm 环境中直接使用 @material/material-color-utilities 的问题。以后 @material/material-color-utilities 解决了 cjs 中直接使用的问题，再切换回来。

[![npm package](https://badgen.net/npm/v/@material/material-color-utilities)](https://npmjs.com/package/@material/material-color-utilities)

Algorithms and utilities that power the Material Design 3 (M3) color system,
including choosing theme colors from images and creating tones of colors; all in
a new color space.

See the main
[README](https://github.com/material-foundation/material-color-utilities#readme)
for more information.

## Getting started

`npm i @material/material-color-utilities` or `yarn add @material/material-color-utilities`

```typescript
import { HCT } from "@material/material-color-utilities";

// Simple demonstration of HCT.
const color = HCT.fromInt(0xff4285f4);
console.log(`Hue: ${color.hue}`);
console.log(`Chrome: ${color.chroma}`);
console.log(`Tone: ${color.tone}`);

```

### Theming

```typescript
import { argbFromHex, themeFromSourceColor, applyTheme } from "@material/material-color-utilities";

// Get the theme from a hex color
const theme = themeFromSourceColor(argbFromHex('#f82506'), [
  {
    name: "custom-1",
    value: argbFromHex("#ff0000"),
    blend: true,
  },
]);

// Print out the theme as JSON
console.log(JSON.stringify(theme, null, 2));

// Check if the user has dark mode turned on
const systemDark = window.matchMedia("(prefers-color-scheme: dark)").matches;

// Apply the theme to the body by updating custom properties for material tokens
applyTheme(theme, {target: document.body, dark: systemDark});

```

## Troubleshooting

If using node make sure to use the following flag:

```
node --experimental-specifier-resolution=node
```


## Contributing

This repo is not accepting external contributions, but feature requests and bug
reports are welcome on
[GitHub](https://github.com/material-foundation/material-color-utilities/issues).

---
_Source: https://npm.io/package/@sinoui/material-color-utilities · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
