third party plugins

Tailwind CSS Rating

The Ratings Component visually represents user evaluations, typically using stars or similar symbols, providing a quick and intuitive way to display feedback or quality assessments.

Below are the comprehensively outlined steps you can follow to seamlessly integrate Raty JS with FlyonUI.

  • 1
    Installation

    Install raty-js using npm:

    npm install raty-js

  • 2
    Include Raty JavaScript and CSS

    Include the following CSS and JS files in your page:

    <head>
      <link rel="stylesheet" href="../path/to/raty-js/src/raty.css" />
    </head>
    <body>
      <script src="../path/to/raty-js/build/raty.js"></script>
    </body>

    Note: A CDN link will not work here as customization of the default Vendor CSS is required to align with FlyonUI's design.


  • 3
    Update Tailwind Configuration

    Add the path to the Raty JavaScript files in the content section of your Tailwind configuration file. Additionally, set vendors: true in the FlyonUI config to enable vendor-specific CSS generation:

    module.exports = {
      content: [
        '../path/to/raty-js/**/*.js',  
      ],
      flyonui: {
        vendors: true // Enable vendor-specific CSS generation
      }
    }

  • 4
    Initialize Raty

    Add the Raty initialization JavaScript code below the Raty JS library inclusion. Set up the Raty instance to target elements using its id or data-raty attribute. Ensure this Raty JS file is in a location where TailwindCSS can monitor it, as specified in step 3.

    For more options and detailed configurations, refer to the Raty JS documentation .

    const target = new Raty(document.querySelector('[data-raty]'), // or #Id
      {
        path: 'path/to/star-images/',
      });
    target.init();
Class Name
Type
Description
raty-jumpModifierApplies a jump animation to the clicked star.

The following example demonstrates the usage of a star-based rating system with the raty-js library using images, initialized with the below provided JavaScript code. Set the path to the location where the images are stored in your project, or to the node modules if they are stored there.

The following example demonstrates the usage of a star-based rating system with the raty-js library using fonts, initialized with the below provided JavaScript code. Set the path to the location where the fonts are stored in your project, or to the node modules if they are stored there.

The following example demonstrates the usage of a star-based read only (static) rating system, initialized with the below provided JavaScript code.

The following example demonstrates the usage of a rating with the custom heart icons, initialized with the below provided JavaScript code.

The following example demonstrates the usage of a rating with half stars, initialized with the below provided JavaScript code.

Utilize size-{number} with starOff & starOn options for rating with custom sizes.

Utilize text-{color} with starOff & starOn options for rating with custom colors.

The following example demonstrates the usage of a rating with hints, initialized with the below provided JavaScript code.

The following example demonstrates the usage of a rating with custom number of stars , initialized with the below provided JavaScript code.

The following example demonstrates the usage of a rating with score(value) , initialized with the below provided JavaScript code.

The following example demonstrates the usage of a rating with reset option, initialized with the below provided JavaScript code.

The following example demonstrates the usage of a rating with animation, initialized with the below provided JavaScript code.