Enable
A11yCore.features.enable('highContrast');Activates a feature immediately.
Explore the public JavaScript API available in the browser.
Initialize A11yCore once the DOM is ready. The promise resolves totruewhen the widget is ready and all licensed modules are loaded.
// Initialize with options
await window.A11yCore.init({
licenseKey: 'your-license-key',
debug: false,
config: {
branding: {
name: 'A11yCore',
primaryColor: '#0066CC',
accentColor: '#FF6B35',
logo: ''
},
widget: {
position: 'bottom-right',
offset: { x: 20, y: 20 },
triggerKey: 'alt+a',
showBadge: true,
pulseOnFirstVisit: true
},
features: {
keyboardNav: true,
visualAdjustments: true,
contentAdjustments: true
},
defaults: {
language: 'en',
rememberSettings: true,
respectSystemPreferences: true
},
analytics: {
enabled: false,
endpoint: ''
}
}
});Feature methods returntruewhen the requested state change is applied.
A11yCore.features.enable('highContrast');Activates a feature immediately.
A11yCore.features.disable('highContrast');Turns off a feature and restores baseline DOM state.
A11yCore.features.toggle('darkMode');Switches between enabled and disabled states.
// Available feature names for enable/disable/toggle:
'highContrast' // High contrast mode
'keyboardNav' // Enhanced keyboard navigation
'highlightLinks' // Highlight all links
'readingGuide' // Reading guide line
'readingMask' // Focus mask overlay
'reduceMotion' // Reduce animations
'accessibleFont' // Accessible font family
'darkMode' // Dark mode
'largeCursor' // Large cursor
'highlightHeadings' // Highlight headings
'hitTargets' // Larger click targets
'landmarks' // Show landmarks/skip nav
'toc' // Table of contents overlay
'breadcrumbs' // Breadcrumb navigation
'altSuggest' // Alt text suggestions
'contrastAdjust' // Adjust contrast levels
'hoverDisable' // Disable hover effects
'captions' // Enable captions
'formAssist' // Form assistance
'simplifyText' // Simplify text
'focusAssist' // Focus assistance
'muteMedia' // Mute all media
// Special methods:
A11yCore.features.colorFilter('protanopia'); // 'none' | 'protanopia' | 'deuteranopia' | 'tritanopia' | 'monochrome'
A11yCore.features.spacing('comfortable'); // 'compact' | 'default' | 'comfortable' | 'spacious'
A11yCore.features.transcript(); // Show media transcriptLoad preset accessibility profiles or save/manage custom user profiles.
// Load a preset profile
A11yCore.profiles.load('low-vision'); // Enables high contrast, 150% text, monochrome
A11yCore.profiles.load('cognitive'); // Enables 120% text, reading guide, reduced motion
A11yCore.profiles.load('motor'); // Enables keyboard navigation
A11yCore.profiles.load('seizure-safe'); // Enables reduced motion, monochrome
// Save current settings as a custom profile
A11yCore.profiles.save('my-profile');
// List all saved custom profiles
const profiles = A11yCore.profiles.list(); // Returns: ['my-profile', ...]
// Delete a custom profile
A11yCore.profiles.delete('my-profile');Subscribe to widget events for analytics, custom UI, or logging. Events are emitted when features are enabled/disabled.
// Subscribe to feature events
const handler = (featureName: string) => {
console.info('[A11yCore] Feature changed:', featureName);
};
A11yCore.on('featureEnabled', handler);
A11yCore.on('featureDisabled', handler);
// Listen for state changes on window
window.addEventListener('a11ycore:statechange', (event) => {
const { key, value } = (event as CustomEvent<{ key: string; value: unknown }>).detail;
console.info('A11yCore state update:', key, value);
});
// Unsubscribe when cleaning up (SPA route changes)
A11yCore.off('featureEnabled', handler);
A11yCore.off('featureDisabled', handler);Access current widget state and get a simple compliance score based on detected accessibility issues.
// Get current state snapshot
const state = A11yCore.getSettings();
console.log(state.features); // { highContrast: true, ... }
console.log(state.settings); // { language: 'en', ... }
// Get compliance score (0-100)
const score = A11yCore.getComplianceScore();
console.log('Compliance score:', score); // e.g., 85Respect user privacy preferences by requesting consent before enabling analytics.
// Grant analytics consent
const success = A11yCore.analytics.consent(true);
// Revoke analytics consent
A11yCore.analytics.consent(false);
if (!success) {
console.warn('[A11yCore] Analytics consent failed to persist');
}Analytics is only sent if enabled in config and consent is granted. Revoking consent immediately stops telemetry collection.