Fnon.js v2.0.4 Interactive Playground — all APIs, live sandbox, Init reference

Twelve feature sections. Each has code examples (try instantly), an Init() config reference table, an Async explanation, and a live sandbox form. Open browser console for lifecycle logs.

1. Hint Fnon.Hint.Theme(msg, titleOrOpts?)

Toast-style notifications. Auto-dismisses after 4 seconds. 7 themes, 9 positions, customizable width/font/progress bar.

String + title

Fnon.Hint.Theme(message, title). Auto-dismisses after 4s.

Fnon.Hint.Success('Message', 'Title') Fnon.Hint.Warning('Message', 'Title') Fnon.Hint.Danger('Message', 'Title')

Position options

Pass object as 2nd arg: { position: 'left-top' }. 9 positions available.

Fnon.Hint.Primary('msg', { position: 'left-top' })

closable + timeOut

Disable the X button or control auto-dismiss timeout.

Fnon.Hint.Primary('msg', { closable: false, timeOut: 3000 })

width + fontSize + spacing

Control hint dimensions and gap between stacked hints.

Fnon.Hint.Primary('msg', { width: '500px' })

Progress bar + Hint.Init

Progress bar shows remaining time. Use Init() to set global defaults.

Fnon.Hint.Init({ timeOut: 6000 })

HintOptions — Init() config reference

Option Default Type Description
type 'Primary' ThemeName Theme key (set automatically by shortcut)
title string | HTMLElement Dialog title
position 'right-top' string right-top, right-center, right-bottom, left-top, left-center, left-bottom, center-top, center-center, center-bottom
timeOut 4000 number (ms) Auto-dismiss after N ms (0 = no dismiss)
closable true boolean Show/hide the X button
width '360px' string Hint container max-width
fontSize '0.88rem' string Hint text size
fontFamily 'Quicksand', sans-serif string Font family
spacing '8px' string Gap between stacked hints
animation 'slide-left' string CSS animation class
animationDuration '0.3s' string Enter/exit transition duration
progressColor color Progress bar color (defaults to theme borderColor)
svg string Custom icon SVG HTML
svgSize {w:20,h:20} object Icon dimensions in px
appendTo body selector Mount container element
onClose () => void Called when hint is dismissed
onclosed () => void Called after hint is fully removed

Async: Fnon.Hint.Theme.Async(message, title?) returns a Promise<void> that resolves when the hint closes (auto or manual). Useful for sequencing notifications.

Sandbox — Hint

Fill in the fields and click Run to see the hint live.

2. Wait Fnon.Wait.Type(text?, opts?)

Full-page spinner overlay. 5 spinner types (Orbit, Spin / Infinity, Ripple, Typing). Supports clickToClose, text label, custom color, and Remove/Change controls.

CSS spinners — Orbit, Spin

Lightweight CSS-only spinners with clickToClose: true for dismiss.

Fnon.Wait.Orbit('Loading', { clickToClose: true })

SVG spanners (Infinity, Ripple, Typing)

Lightweight SVG spinners: Infinity, Ripple, Typing.

Fnon.Wait.Infinity('Loading', { clickToClose: true })

Custom color + containerSize

Override svgColor and containerSize to match your brand.

Fnon.Wait.Orbit('Loading', { svgColor: '#ff6b6b' })

Wait controls + Wait.Init

Remove(), Change(text), and Init() for global defaults.

Fnon.Wait.Pulse('Working')
Fnon.Wait.Change('New text')
Fnon.Wait.Remove()

Wait.Async

Returns a Promise that resolves when Remove() is called or the spinner is dismissed.

Fnon.Wait.Orbit.Async('Working')
  .then(() => Fnon.Hint.Success('Done!'))

SpinnerOptions — Wait

Option Default Type Description
text '' string Label text below the spinner
clickToClose false boolean Click the overlay to dismiss
svgColor '#029eff' color Spinner / accent color
fontFamily 'Quicksand', sans-serif string Font family for text
containerSize string Spinner box width (e.g. '400px')
appendTarget body selector Mount container
Spinner types: Orbit, Spin (CSS) • Infinity, Ripple, Typing (SVG)

Async: Fnon.Wait.Type.Async(text?, opts?) returns Promise<boolean> (resolves true when Remove() is called or the spinner is dismissed).

Sandbox — Wait

Select a spinner type, configure options, and launch.

3. Box Fnon.Box.Type(selector, text?, opts?)

Container-bound spinner overlay. Same 5 spinner types as Wait, but rendered inside a specific DOM element instead of full-screen.

Spinner in container

First arg is a CSS selector. Spinner appears inside that element.

Fnon.Box.Orbit('#box-target', 'Loading')

Custom color + svgSize

Override svgColor and svgSize for the box spinner.

Fnon.Box.Orbit('#box-target', 'Loading', { svgSize: { w: 80, h: 80 } })

Box.Init + Box.Async

Box.Init sets global defaults. Box.Async returns a Promise.

Fnon.Box.Init({ svgColor: '#39DA8A' })
#box-target — spinners appear here

BoxOptions — Box

Option Default Type Description
selector string CSS selector for the target element
text '' string Label below the spinner
svgColor '#029eff' color Spinner accent color
svgSize {w,h} Spinner SVG dimensions in px
fontFamily 'Quicksand', sans-serif string Font family for text
containerSize string Spinner box width
Same 5 spinner types as Wait: Orbit, Spin, Infinity, Ripple, Typing

Async: Fnon.Box.Type.Async(selector, text?, opts?) returns Promise<boolean> (resolves true when Box.Remove(selector) is called).

Sandbox — Box

Enter a CSS selector and configure the spinner.

4. Alert Fnon.Alert.Theme(msg, title?, btnOkText?, callback?)

A one-button modal for simple messages. Supports both positional args and a single options object.

String message

Three positional args: message, title, button text.

Fnon.Alert.Primary('Hello!', 'Title', 'OK')

Object args

Access every option by passing a single object.

Fnon.Alert.Primary({ message: 'Object mode!', width: 'sm' })

delButtons + autoFocus

delButtons: true removes footer. autoFocus: true highlights the button.

Fnon.Alert.Primary({ delButtons: true })

Button styling overrides

Custom colors, background, shadow, border for the OK button.

Fnon.Alert.Primary({ btnOkColor: '#fff', btnOkBackground: '#6c5ce7' })

.Async + .Init

.Async returns a Promise. .Init sets global defaults.

await Fnon.Alert.Primary.Async('msg', 'title')

Alert — common ModalOptions

Option Default Type Description
message string | HTMLElement | VNode Body content
title string Dialog title
btnOkText 'OK' string OK button label
width 'sm' | 'lg' | 'xl' | 'fl' Width mode (360/640/800/full px)
closeButton true boolean Show/hide X button
showClose boolean Alias for closeButton
delButtons false boolean Remove all footer buttons
autoFocus false boolean Auto-focus first matching element
autoFocusTag 'input:not([disabled])' selector Focus target selector
fontFamily 'Quicksand', sans-serif string CSS font-family
animation 'slide-top' string CSS animation class
color '#2b2b2b' color Body text color
background 'rgba(0,0,0,0.4)' color Overlay background
titleColor color Title text color
titleBackground color Title bar background
zIndex 4000 number Overlay z-index
showIcon false boolean Show an icon in the body
data object Shared mutable data for lifecycle callbacks
focusTrap true boolean Lock Tab focus inside the modal
isDark boolean | ()=>boolean Enable dark mode for body & footer
darkBgColor '#1a202c' color Dark mode background color
onOpen (el,data)=>void After modal opens
onClose (data)=>void When modal closes
onInit (el,data)=>void After element built, before DOM append
onClosed (data)=>void After modal fully removed

Async: Fnon.Alert.Theme.Async(message, title?, btnOkText?) returns Promise<void> that resolves when OK is clicked or the modal is closed.

Sandbox — Alert

Configure and launch an Alert modal.

5. Ask Fnon.Ask.Theme(msg, title?, okText?, cancelText?, callback?)

A two-button confirm modal (OK / Cancel). The callback receives true or false. Supports object args and async.

Positional args

message, title, OK text, Cancel text, callback(result).

Fnon.Ask.Primary('Proceed?', 'Confirm', 'Yes', 'No', r => {})

Object args

Pass a single options object for full control.

Fnon.Ask.Primary({ message: 'Object mode!', btnOkText: 'Sure' })

Button styling overrides

Custom colors for both OK and Cancel buttons.

Fnon.Ask.Primary({ btnOkColor: '#fff', btnOkBackground: '#6c5ce7' })

.Async + .Init

.Async resolves true or false. .Init sets global defaults.

let r = await Fnon.Ask.Primary.Async('Continue?')

Ask — common ModalOptions

Option Default Type Description
message string | HTMLElement | VNode Body content
title string Dialog title
btnOkText 'OK' string OK button label
btnCancelText 'Cancel' string Cancel button label
width 'sm' | 'lg' | 'xl' | 'fl' Width mode
closeButton true boolean Show/hide X button
showClose boolean Alias for closeButton
autoFocus false boolean Auto-focus first matching element
fontFamily 'Quicksand', sans-serif string CSS font-family
color '#2b2b2b' color Body text color
btnOkColor color OK button text color
btnOkBackground color OK button background
btnOkShadow string OK button box-shadow
btnCancelColor color Cancel button text color
btnCancelBackground color Cancel button background
focusTrap true boolean Lock Tab focus inside the modal
isDark boolean | ()=>boolean Enable dark mode for body & footer
darkBgColor '#1a202c' color Dark mode background color

Async: Fnon.Ask.Theme.Async(message, title?, okText?, cancelText?) returns Promise<boolean>true on OK, false on Cancel or close.

Sandbox — Ask

Configure and launch a confirmation modal.

6. Dialogue Fnon.Dialogue(opts) · Fnon.Dialogue.Theme(...)

The most flexible modal. Custom buttons, full lifecycle hooks, minimize/maximize, drag, and raw options control.

Custom buttons

Define buttons with text, style, and callback. Callback receives close().

Fnon.Dialogue({ buttons: [{ text: 'Save', callback: c => c() }] })

Themed shortcut + prevent close

Positional shortcut: msg, title, OK, Cancel, callback(close, html). Return false to stay open.

// Return false to prevent close
callback: (c, html) => { return false }

Minimize / Maximize

showMin and showMaxMin add window controls to the title bar. Minimized modals go to a task bar.

Fnon.Dialogue({ showMin: true, showMaxMin: true })

Lifecycle hooks + data

onInit → beforeShow → afterShow → onOpen → onClosing → onClose → onClosed. All receive (el, data).

Fnon.Dialogue({ onInit: (el, data) => {}, onOpen: (el, data) => {} })

Custom styling + drag

Override colors, font, width. All modals are draggable by the title bar.

Fnon.Dialogue({ titleColor: '#fff', width: 'sm' })

Dialogue — ModalOptions (full reference)

Option Default Type Description
message string | HTMLElement | VNode Body content
title string Dialog title
buttons ButtonDef[] Custom button definitions
width 'sm' | 'lg' | 'xl' | 'fl' Width mode
layout 'hbf' string Order of header/body/footer
closeButton true boolean Show/hide X button
showClose boolean Alias for closeButton
showMin false boolean Show minimize button
showMaxMin false boolean Show maximize button
delButtons false boolean Remove all footer buttons
autoFocus false boolean Auto-focus first input
fontFamily 'Quicksand', sans-serif string CSS font-family
animation 'slide-top' string CSS animation class
data object Shared mutable data for all lifecycle hooks
color '#2b2b2b' color Body text color
background 'rgba(0,0,0,0.4)' color Overlay background
titleColor color Title text color
titleBackground color Title bar background
zIndex 4000 number Overlay z-index
appendTarget 'body' string | HTMLElement Mount container
focusTrap true boolean Lock Tab focus inside the modal
isDark boolean | ()=>boolean Enable dark mode for body & footer
darkBgColor '#1a202c' color Dark mode background color
onInit (el,data)=>void After element built
beforeShow (el,data)=>void Before DOM append
afterShow (el,data)=>void After DOM append
onOpen (el,data)=>void After modal opens
onClosing (el,data)=>void When modal starts closing
onClose (data)=>void During close animation
onClosed (data)=>void After modal fully removed

Async: Fnon.Dialogue.Theme.Async(message, title?, okText?, cancelText?) returns Promise<boolean | null>true on OK, false on Cancel, null on close/X.

Sandbox — Dialogue

Configure a modal with the most common options.

7. Breaking Fnon.Breaking(opts) · Fnon.Breaking.Theme(headline?)

Full-width notification bar anchored to top or bottom. Auto-dismisses after 5 seconds. Supports custom buttons and headlines.

Themed shortcuts

One arg: Fnon.Breaking.Theme(headline). Auto-dismisses after 5s.

Fnon.Breaking.Danger('Breaking news')

Full options + bottom anchor

headline, message, theme, anchor, buttons, timeout, closable, onClose.

Fnon.Breaking({ headline: 'BOTTOM', anchor: 'bottom' })

.Async + .Init

.Async resolves when bar closes. .Init changes global defaults.

Fnon.Breaking.Init({ headline: 'ALERT' })

BreakingOptions

Option Default Type Description
headline 'BREAKING' string Bold label text
message string | HTMLElement Body content
theme 'Danger' ThemeName Color scheme
anchor 'top' 'top' | 'bottom' Where the bar attaches
timeout 5000 number (ms) Auto-dismiss after N ms
closable true boolean Show/hide the X button
buttons ButtonDef[] Action buttons in the bar
fontFamily 'Quicksand', sans-serif string Font family
appendTarget 'body' string | HTMLElement Mount container
onClose () => void Called when bar closes

Async: Fnon.Breaking.Theme.Async(message?, headline?) returns Promise<void> that resolves when the bar is closed (auto-dismiss or manual).

Sandbox — Breaking

Configure a breaking notification bar.

8. DatePicker Fnon.DatePicker(opts) · Fnon.DP(opts)

A modal date picker with month/year selector, range mode, optional time picker, and min/max constraints. Returns a Promise.

Single Date

Click a date → resolves immediately. Toggle dark mode first to test dark theme support.

Fnon.DatePicker({ title: 'Pick a date' }) .then(d => console.log(d)) .catch(() => console.log('cancelled'))

Date Range

Click start date, then end date. Promise resolves with { start, end }.

Fnon.DatePicker({ dateRange: true }) .then(r => console.log(r.start, r.end))

Constrained

Only dates within a range are selectable (minDate / maxDate).

Fnon.DatePicker({ minDate: new Date('2026-01-01'), maxDate: new Date('2026-12-31') })

DatePickerOptions

{
  initDate: Date          // Initial month to show (default: today)
  dateRange: boolean       // Enable range mode (default: false)
  withTime: boolean        // Show time picker after date selection (default: false)
  minDate: Date           // Earliest selectable date
  maxDate: Date           // Latest selectable date
  title: string           // Modal title
  isDark: boolean|()=>boolean  // Enable dark mode for this instance
}
      

Async: Always async — returns Promise<Date | { start: Date; end: Date }>. Rejects when the modal is closed without selecting. Also available as Fnon.DP(opts).

Sandbox — DatePicker

Configure and run a DatePicker instance.

9. ContextMenu Fnon.ContextMenu(event, items[], globalOnClick?)

Right-click or programmatic context menu with nested submenus, keyboard navigation, viewport-aware positioning, and dark mode support.

Right-click anywhere

Right-click (or Ctrl+click) on this card to open the context menu. Try submenus and keyboard navigation (Arrow keys, Enter, Escape).

Fnon.ContextMenu(event, [
  { text: 'Edit', onClick: () => {} },
  { text: 'Share',
    items: [
      { text: 'Twitter' },
      { text: 'Facebook' },
    ] },
  { text: 'Delete', disabled: true },
])

ContextMenuItem

Prop Type Default Description
label string Menu item text
onClick () => void Called when item is chosen. Ignored if items is set.
items ContextMenuItem[] Nested submenu (takes priority over onClick)
disabled boolean false Gray out and prevent interaction
divider boolean false Render as a visual separator
icon string Optional icon HTML (e.g. SVG) prepended to label

Keyboard: Arrow keys to navigate, Enter/Space to select, Escape to close, ArrowRight to open submenu, ArrowLeft to close submenu. Alias: Fnon.CM(event, items, globalOnClick?)

10. AddTheme Fnon.AddTheme(name, config)

Register a custom theme that applies to all modal types and hints.

Custom "Purple" theme

Registers a purple-themed palette.

Fnon.AddTheme("Purple", {
  titleBackground: "#7c3aed",
  titleColor: "#fff",
  btnOkBackground: "#7c3aed",
  btnOkColor: "#fff",
  btnOkBorderColor: "#7c3aed",
  backgroundColor: "#faf5ff",
});
Fnon.Ask.Purple("Question?");

# 12. No‑Backdrop Dialog overlay: false

Set overlay: false on a Dialogue to hide the dark backdrop and let users interact with the page behind the modal. Clicking the modal body brings it to the front.

Fnon.Dialogue({
  title: "Floating Dialog",
  message: "No backdrop.",
  overlay: false,
  showMaxMin: true
});