Events and integration
-axxy- decouples keyboard navigation, focus management, and ARIA state updates from your application logic. Rather than requiring framework props or configuration callbacks, components dispatch standard DOM events and bubbling CustomEvents.
Every custom event bubbles (bubbles: true), so you can listen directly on the widget, delegate to the <axxy-scope> wrapper, or listen globally on document.
Custom events reference
| Component | Event | Target | event.detail |
Cancelable | Description |
|---|---|---|---|---|---|
| Accordion | axxy-accordion-change |
Header <button> |
{ expanded: boolean, trigger: HTMLElement, panel: HTMLElement } |
No | Dispatched when an accordion section expands or collapses. |
| Button / Toggle | axxy-toggle-change |
Toggle <button> / [aria-pressed] |
{ pressed: boolean } |
No | Dispatched when a toggle button changes its pressed state. |
| Button / Toggle | click |
<button> / [role="button"] |
Native MouseEvent |
Yes | Standard activation event. |
| Carousel | axxy-carousel-change |
Carousel container |
{ index: number, slide: HTMLElement, running: boolean } |
No | Dispatched when the active slide changes or automatic rotation starts/stops. |
| Checkbox | input / change |
<input type="checkbox"> / [role="checkbox"] |
Native Event |
No | Dispatched when the checked or mixed state changes. |
| Combobox | axxy-combobox-change |
[role="combobox"] |
{ value: string, option: HTMLElement|null } |
No | Dispatched when a combobox value or option is committed. |
| Combobox | change |
[role="combobox"] |
Native Event |
No | Standard change event dispatched on commit. |
| Datepicker | axxy-datepicker-change |
<input> |
{ value: string, date: Date } |
No | Dispatched when a date is chosen from the calendar. |
| Datepicker | input / change |
<input> |
Native Event |
No | Standard input and change events dispatched when the date updates. |
| Dialog / Alert Dialog | axxy-dialog-open |
<dialog> |
{ dialog: HTMLDialogElement, invoker: HTMLElement|null } |
No | Bubbling event dispatched when a modal dialog opens. |
| Dialog / Alert Dialog | axxy-dialog-close |
<dialog> |
{ dialog: HTMLDialogElement, invoker: HTMLElement|null } |
No | Bubbling event dispatched when a modal dialog closes. |
| Dialog / Alert Dialog | close |
<dialog> |
Native Event |
No | Standard non-bubbling dialog close event. |
| Disclosure | axxy-disclosure-change |
Trigger <button> |
{ expanded: boolean, panel: HTMLElement } |
No | Dispatched when a disclosure panel expands or collapses. |
| Feed | axxy-feed-load |
[role="feed"] |
None |
No | Dispatched when scrolling or focus nears the end of the feed to request more articles. |
| Grid | axxy-grid-edit |
Cell (td / [role="gridcell"]) |
{ cell: HTMLElement, editing: boolean } |
No | Dispatched when entering or exiting interactive cell edit mode. |
| Link | click |
<a href> / [role="link"] |
Native MouseEvent |
Yes | Standard link activation event (including Enter key on custom links). |
| Listbox | axxy-listbox-change |
[role="listbox"] |
{ selected: HTMLElement[] } |
No | Dispatched when the selected option(s) change. |
| Listbox | axxy-listbox-reorder |
[role="listbox"] |
{ message: string } |
No | Dispatched when items are moved or reordered. |
| Menu / Menubar | axxy-menu-select |
[role="menuitem"] |
{ item: HTMLElement, value: string, checked: string|null } |
Yes | Dispatched when a menu item is activated. Calling preventDefault() suppresses default navigation. |
| Radio Group | axxy-radio-change |
Checked [role="radio"] |
{ item: HTMLElement, value: string } |
No | Dispatched when the selected radio option changes. |
| Slider | axxy-slider-change |
<input type="range"> |
{ value: number } |
No | Dispatched when the slider value changes. |
| Slider | input / change |
<input type="range"> |
Native Event |
No | Standard range input and change events. |
| Spinbutton | axxy-spinbutton-change |
<input type="number"> / [role="spinbutton"] |
{ value: number } |
No | Dispatched when the spinbutton value changes. |
| Spinbutton | input / change |
<input type="number"> / [role="spinbutton"] |
Native Event |
No | Standard numeric input and change events. |
| Switch | axxy-switch-change |
[role="switch"] |
{ checked: boolean } |
No | Dispatched when the switch toggles on or off. |
| Switch | input / change |
[role="switch"] |
Native Event |
No | Standard input and change events. |
| Table (Sortable) | axxy-sort |
<table> |
{ column: number, ascending: boolean } |
No | Dispatched on sortable tables when a column header is activated. |
| Tabs | axxy-tab-change |
Selected [role="tab"] |
{ tab: HTMLElement, panel: HTMLElement } |
No | Dispatched when the active tab changes. |
| Toolbar | axxy-toolbar-change |
Active control |
{ item: HTMLElement } |
No | Dispatched when a toolbar control is activated or toggled. |
| Tooltip | axxy-tooltip-show |
Trigger element |
{ trigger: HTMLElement, tooltip: HTMLElement } |
No | Dispatched when the tooltip becomes visible. |
| Tooltip | axxy-tooltip-hide |
Trigger element |
{ trigger: HTMLElement, tooltip: HTMLElement } |
No | Dispatched when the tooltip is hidden or dismissed. |
| Treegrid | axxy-treegrid-toggle |
Row (<tr> / [role="row"]) |
{ row: HTMLElement, expanded: boolean } |
No | Dispatched when a treegrid row expands or collapses. |
| Treeview | axxy-tree-select |
[role="tree"] |
{ item: HTMLElement, label: string } |
No | Dispatched when a tree item is activated. |
| Treeview | axxy-tree-toggle |
Tree item |
{ item: HTMLElement, expanded: boolean } |
No | Dispatched when a tree branch expands or collapses. |
Listening to events
Attach standard addEventListener handlers to react to state changes, load dynamic data, or cancel default navigation:
// Listen for tab changes
document.addEventListener('axxy-tab-change', (event) => {
const { tab, panel } = event.detail;
console.log('Selected tab:', tab.textContent.trim(), 'Panel:', panel.id);
});
// Listen for accordion expand/collapse
document.addEventListener('axxy-accordion-change', (event) => {
const { expanded, trigger, panel } = event.detail;
console.log(trigger.textContent.trim(), expanded ? 'expanded' : 'collapsed');
});
// Listen for modal dialog open/close
document.addEventListener('axxy-dialog-open', (event) => {
console.log('Dialog opened:', event.detail.dialog.id);
});
// Listen for carousel slide changes
document.addEventListener('axxy-carousel-change', (event) => {
const { index, slide, running } = event.detail;
console.log('Slide index:', index, 'Auto-rotating:', running);
});
// Cancel menu navigation when needed
document.addEventListener('axxy-menu-select', (event) => {
if (event.detail.value === 'delete' && !confirm('Delete item?')) {
event.preventDefault();
}
});