Code Monkey home page Code Monkey logo

undraw-js's Introduction

Welcome to this library

Undraw-js is a library allow you to add undraw.co illustration to web page with a specifique color

How to use it ?

  • Installation

    <script src="https://unpkg.com/[email protected]/index.min.js"></script>

    or use yarn or npm

    $ yarn add undraw-js
    $ npm i undraw-js
  • Add some attribute to your img element

    <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

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

    or

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

More customisation

You can provide options to Undraw object

    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 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

undraw-js's People

Contributors

bocovo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

undraw-js's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.