A singleton debug bar UI for Alpine.js applications, providing an interactive, tabbed panel to inspect reactive data or any arbitrary debug information live in the browser.
npm install @designbycode/alpine-debug
bash
npm install alpinejs
`
Add the debug bar plugin script to your project (assuming you saved it as alpine-debug.ts):
`js
import Alpine from 'alpinejs'
import AlpineDebug from './alpine-debug'
Alpine.plugin(AlpineDebug)
Alpine.start()
`
Usage
Use the x-debug directive on any element within an Alpine.js component.
$3
`html
`
This will create a debug tab showing the component’s reactive data.
---
$3
`html
`
* Without the .tab modifier, the x-debug expression is evaluated and displayed in the panel and used as the tab name.
* With .tab modifier, the expression is treated as the literal tab name, and the entire component data stack is displayed.
Features
* Singleton debug bar appended to the document body
* Toggle button to show/hide debug bar (bug icon / chevron)
* Tabs dynamically created for each debug block with selectable activation
* Reactive updates of debug content when Alpine data changes
* Safe JSON serialization with custom replacer to handle functions, undefined, symbols, and class instances
* Clean UI styled with scoped CSS for easy customization
* Automatically removes debug blocks when their DOM elements are removed
* Disabled in production unless URL contains ?debug=true
Example
`html
User component
``