Skip to content

Options

import { createPal } from 'pagepal';
const pal = createPal({ /* options */ });

All options are optional. Every watcher option also accepts false to turn it off, and true for its defaults.

OptionTypeDefault
character'blob' | 'cat' | 'ghost' | CharacterDefinition | { images }'blob'Characters
colorCSS color | 'auto'character’s colorBody color; see color
sizenumber72px
position'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'inline''bottom-right'
offsetnumber20px from the edges
zIndexnumber2147483000
containerHTMLElementdocument.bodyWhere to mount it; required in practice for 'inline'
OptionTypeDefault
interactivebooleantruePoke, drag and dismiss. false makes it click-through
keyboardbooleantrueDismiss button in the tab order
labels{ dismiss?: string }{ dismiss: 'Hide mascot' }Accessible labels
rememberbooleantrueRemember dismissal and position in localStorage
storageKeystring'pagepal'localStorage key
gazeboolean | { duration?: number }{ duration: 2500 }Look at the field with a validation error
OptionTypeDefault
watchselector | element | arraynoneForms to watch
requestsboolean | WatchRequestsOptionsfalsefetch and XHR
scrollboolean | { threshold?: number }{ threshold: 2 }px/ms averaged over 300 ms
networkbooleantrueOffline → sad
darkModeboolean | { detect?: () => boolean }trueDark mode → sleepy
idleboolean | { timeout?: number }{ timeout: 30000 }
passwordbooleantruePassword field → shy
frustrationboolean | { clicks?, within?, radius? }{ clicks: 4, within: 1000, radius: 30 }Rage clicks
deadClicksboolean | { timeout?, ignore? }{ timeout: 1000 }Dead clicks
avoidboolean | { selectors?, focus? }{ focus: true }Overlap avoidance
copybooleantrueCopy → wink
welcomeBackboolean | { after?: number }{ after: 30000 }Back after a while → cheer
errorsbooleanfalseUncaught errors → wince
OptionTypeDefault
plugins(PalPlugin | Watcher)[][]Plugins, watchers, analytics(), debugPanel()
durationsPartial<Record<TransientMood, number>>cheer 1800, wince 1200, dizzy 1200, wink 900, concerned 1800, confused 1600ms
prioritiesPartial<Record<Mood, number>>see moodsHigher wins

createPalCore() from pagepal/core accepts the appearance, interaction, storage and extending options above. It has no watcher options: add watchers through plugins. Its character accepts a definition or images, not a name. See smaller bundles.

interface WatchRequestsOptions {
delay?: number; // 150
filter?: (input: RequestInfo | URL, init?: RequestInit) => boolean;
isError?: (response: { status: number; ok: boolean; url: string }) => boolean; // status >= 500
progress?: number | false; // 100_000 bytes
}

Per form, as the second argument to pal.watch():

interface WatchFormOptions {
cheer?: boolean; // true
wince?: boolean; // true
progress?: boolean; // true
}

The pal in the corner is pagepal itself.