Guides

"Use default cursor" toggle

Let visitors turn the custom cursor off, and remember their choice.

Offer visitors a way back to their own cursor. Both sets switch off when <html> has data-cursor="native".

With the package

<label><input type="checkbox" id="use-default-cursor"> Use default cursor</label>
import { applyNativePreference, getNativePreference, setNativePreference } from 'glint-cursors/preference';

applyNativePreference(); // as early as possible on load
// Run the following after the checkbox exists in the DOM.
const toggle = document.querySelector('#use-default-cursor');
toggle.checked = getNativePreference();
toggle.addEventListener('change', () => setNativePreference(toggle.checked));

The choice is stored in localStorage (key cursor-library:native). If storage is blocked, it still applies for the current page view.

Without a bundler

<script>
  const KEY = 'cursor-library:native';
  try { if (localStorage.getItem(KEY) === '1') document.documentElement.dataset.cursor = 'native'; } catch {}
</script>

Put that in the <head> to apply the saved choice early. This snippet restores a saved choice; it does not create a toggle or save changes. The Animated script-tag entry (auto.js) also reads the key when it starts. Every Animated zip’s example.html includes a working toggle.

Where to put it

Somewhere predictable: the footer, a settings menu, or an accessibility panel. Label it plainly: “Use default cursor”.