Configuration

Cursor Types

cursors is the core configuration option in AnimeCursor. Each key represents a cursor type, corresponding to a CSS class
(cursor-${type}, automatically generated by AnimeCursor). You have complete freedom to name the cursor types; any valid JavaScript identifier will work without affecting the result.

cursors: {
    default: { ... },
    pointer: { ... },
    text: { ... },
    cursorForFun: { ... }
}

To make these cursors actually work, you also need to configure basic parameters for them, telling AnimeCursor how you want these cursors to be presented.

Parameter Options

All Cursor Parameters

The table below lists all parameter options reserved by AnimeCursor for cursors, which can be used for quick reference. For a more detailed introduction to each parameter, please see the sections below.

Option Type Required Description Behavior When Empty
size [number, number] Cursor dimensions [width, height] (pixels) Error
image string Path to cursor image Error
tags string[ ] Target HTML tags AnimeCursor will only switch to this cursor when hover an element that has data-cursor setted by user manually
default boolean ⚠️ Whether the cursor is the default cursor
⚠️ Only one default cursor can be set
Same as setting to false
frames number Number of frames for sprite sheet animation Cursor will not be animated as a sprite sheet
duration number Loop duration for sprite sheet animation (seconds) Cursor will not be animated as a sprite sheet
pingpong boolean Whether sprite sheet animation uses ping-pong loop Sprite sheet animation loops normally
offset [number, number] Cursor offset [right, down] (pixels) Cursor pointer position defaults to top-left corner
scale [number, number] Cursor scaling factor [horizontal, vertical] Cursor maintains size as set
pixel boolean Whether to enable pixelated rendering Original pixel art edges are smoothed
zindex number Set z-index specifically for this cursor (at <body> level) Defaults to maximum z-index minus 1

Parameter Details

Global Options

In addition to the cursors themselves, AnimeCursor provides a few global options at the same level as cursors:

What Are Global Options

OptionTypeDefaultDescription
debugbooleanfalseEnable debug overlay
displayOnLoadbooleanfalseSets whether the cursor should be displayed before mouse movement is detected
enableTouchbooleanfalseWhether to enable on touchscreen devices

Global Option Details

How to Set Global Options

Since global options are at the same level as cursor types, pay attention to the code format when setting global parameters:

✅ Correct Format:

new AnimeCursor({
    debug: true, // At the same level as cursors, correct format
    enableTouch: false, // At the same level as cursors, correct format
    cursors: {
        default: {
            size: [32,32],
            image: 'i/cursor/cursor_default.gif',
            pixel: true,
            default: true
        },
    }
});

An AnimeCursor initialization with global options set should look like the example above.

❌ Incorrect Format:

new AnimeCursor({
    cursors: {
        debug: true, // Wrapped inside cursors, incorrect location
        default: {
            size: [32,32],
            image: 'i/cursor/cursor_default.gif',
            pixel: true,
            default: true,
            enableTouch: false // Wrapped inside cursor settings, incorrect location
        },
    }
});

The example above is an incorrect demonstration. Note the location of debug and enableTouch in the code and the comment text.