Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chu121su12/unocss-preset-chroma

chroma-js gradient for UnoCSS
https://github.com/chu121su12/unocss-preset-chroma

Last synced: 3 months ago
JSON representation

chroma-js gradient for UnoCSS

Awesome Lists containing this project

README

        

# unocss-preset-chroma



npm version


node version

> chroma-js gradient for UnoCSS

## Installation

```sh
npm i unocss-preset-chroma unocss --save-dev # with npm
yarn add unocss-preset-chroma unocss -D # with yarn
pnpm add unocss-preset-chroma unocss -D # with pnpm
```

## Usage

```js
// unocss.config.js
import { presetUno, defineConfig } from 'unocss'
import { presetChroma } from 'unocss-preset-chroma'

export default defineConfig({
presets: [
presetUno(), // for color theme
presetChroma(),
],
})
```

## Utilities

- Shorthand gradient + stops:

`chroma-(linear|radial|conic)-(rgb|lab|hsl|lch)-`

Where `` is dash-separated hex color.

- Stops only:

`chroma-stops-(rgb|lab|hsl|lch)---`

- Shape:

`chroma-shape-[contour/size/potiion/direction/etc]`

- Base gradient function (`background-image`):

`chroma-(linear|radial|conic)`

### Type of `ChromaOptions`

```ts
export interface ChromaOptions {
/**
* Class prefix for matching gradient rules.
*
* @defaultValue `chroma-`
*/
prefix?: string
/**
* Number of gradient steps to generate.
*
* @defaultValue 7
*/
steps?: number
}
```

## Acknowledgement

- [Polychroma](https://polychroma.app/)
- [chroma.js](https://vis4.net/chromajs/)
- [Make Beautiful Gradients](https://www.joshwcomeau.com/css/make-beautiful-gradients/) by Josh Comeau

## License

MIT

## Demo

Clone the repo, run `pnpm dev`.