Guides
Scoping
Keep the cursor to one section, or a set of pages, with a CSS selector.
By default a cursor covers the whole window (html). A scope limits it to elements matching a CSS selector, and everything outside keeps the native cursor.
Why scope
Custom cursors suit portfolios, hero sections and marketing pages. They don’t suit checkout, forms, dashboards or admin tools (see where not to use). If one site has both, scope the cursor to the marketing parts.
How
| Where | Option |
|---|---|
| Gallery | the Scope field on a cursor’s page |
| Static CLI | npx cursor-static bold-arrow --scope "#hero" --out public/cursors |
| Static API | generateStatic({ family: 'bold-arrow', scope: '#hero' }) |
| Animated script tag | data-scope="#hero" |
| Animated API | loadCursor({ family: 'morph', scope: '#hero' }) (a selector or an element) |
Examples of selector lists include #hero, .case-study, main > .intro and [data-theme="brand"]. Static generation rejects the universal selector *, {, }, ;, <, @, backslashes, CSS comments and !important. The Animated API instead passes a string directly to document.querySelector.
Static vs Animated
- Static scopes are baked into the generated CSS. The selector can match many elements, and elements added later are covered automatically. Hover rules target descendants, not the scope element itself. To change the scope, regenerate.
- Animated scopes are resolved once when the cursor starts, to the first matching element. Use one wrapper element (or pass an element), and recreate the cursor if that wrapper is replaced. A selector that matches nothing prevents the cursor from starting.
Spotlight
The spotlight family is meant for a single section and defaults to #hero in the gallery and in agent prompts.
Excluding a region inside a scope
Use data-cursor="native" on the region instead of a complicated selector.