# undraw-js

> Js library for Undraw illustration

Latest version **1.0.6** (published 2024-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install undraw-js
pnpm add undraw-js
yarn add undraw-js
bun add undraw-js
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2024-01-20 |
| First published | 2022-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 19 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Juste Bocovo |
| Maintainers | bocovo |
| Keywords | undraw, ullistration, js, svg, image |

## Links

- npm: https://www.npmjs.com/package/undraw-js
- Repository: https://github.com/BOCOVO/undraw-js
- Homepage: https://github.com/BOCOVO/undraw-js#readme
- Issues: https://github.com/BOCOVO/undraw-js/issues
- npm.io page: https://npm.io/package/undraw-js

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.6 (latest) — 2024-01-20
- 1.0.5 — 2023-12-30
- 1.0.5-alpha-02 — 2023-12-30
- 1.0.5-alpha-01 — 2023-12-28
- 1.0.4 — 2022-07-04
- 1.0.3 — 2022-07-04
- 1.0.1 — 2022-07-04
- 1.0.0 — 2022-03-11
- 0.0.2 — 2022-03-11
- 0.0.1 — 2022-03-09

## README

# Welcome to this library

Undraw-js is a library allow you to add [undraw.co](https://undraw.co/illustrations) illustration to web page with a specifique color

## How to use it ?

- Installation

    ```html
    <script src="https://unpkg.com/undraw-js@1.0/index.min.js"></script>
    ```

    or use yarn or npm

    ```bash
    $ yarn add undraw-js
    ```

    ```bash
    $ npm i undraw-js
    ```

- Add some attribute to your `img` element

    ```html
    <img data-ujs-name="Ukraine" data-ujs-color="#f00" />
    ```

    About attributes

    |Options | Description | Required|
    |--------|-------------|---------|
    |`data-ujs-name`| Input here the name of the illustration| `yes` |
    |`data-ujs-color`| Input here the main color code you want| `no` |
    |`data-ujs-fall-img`|The image link to set as the source of the `img` element if the illustration failed to load.| `no` |

- Add this script to the page

    ```html
    <script>
        UndrawJS.init()
    </script>
    ```

    or

    ```js
      import UndrawJs from 'undraw-js'
      (new UndrawJs()).init()
    ```

## More customisation

You can provide options to Undraw object

```js
    const options = {
        nameAttr: "data-ujs-name", // Custom attribute of nodes that specifies the name of the illustration
        colorAttr: "data-ujs-color", // Custom attribute of nodes that specifies the main color
        doneAttr: "data-ujs-done", // Custom attribute of nodes that specifies if the illustration is addded to the node
        fallbackAttr: "data-ujs-fall-img", // Custom attribute of nodes that specifies the fall image
        defaultColor: "#f00" // To specify a default color
    };

    UndrawJS.init(options); // or (new UndrawJs()).init(options) for module user
```

## How to find illustration name ?

Go to [undraw.co](https://undraw.co/illustrations) find illustration you need and copy its name

## Notes

> Only the illustrations you add to your page are loaded.

> Illustration not loaded ? Undraw is constantly evolving. If the illustration does not load, perhaps the version of undraw-js you are using is deployed before the creation of this illustration. To fix this, see if there is a version of undraw-js higher than the version you are using, if it is the last version you are using then wait for a new update.
> There are over 1300 illustrations that you can use

---
_Source: https://npm.io/package/undraw-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
