@@ -81,44 +81,42 @@ This makes it easy to locate and inspect issues directly on the page.
8181
8282## Panel Configuration
8383
84- The ` A11yDevtoolsPanel ` component accepts the following props:
84+ ` A11yDevtoolsPanel ` is React-first and takes an ` options ` prop that matches ` A11yPluginOptions ` .
8585
8686``` tsx
87+ import type { A11yPluginOptions } from ' @tanstack/devtools-a11y'
88+
8789interface A11yDevtoolsPanelProps {
88- /** Default WCAG standard to use */
89- defaultStandard? : ' wcag2a' | ' wcag2aa' | ' wcag2aaa' | ' wcag21a' | ' wcag21aa' | ' wcag21aaa' | ' wcag22aa' | ' section508' | ' best-practice'
90-
91- /** Enable live monitoring by default */
92- defaultLiveMonitoring? : boolean
93-
94- /** Show overlays by default */
95- defaultShowOverlays? : boolean
96-
97- /** Enable scoped scanning by default */
98- defaultScopedMode? : boolean
99-
100- /** Auto-scan on panel mount */
101- autoScan? : boolean
102-
103- /** Custom axe-core rules to include */
104- includeRules? : string []
105-
106- /** Custom axe-core rules to exclude */
107- excludeRules? : string []
108-
109- /** CSS selectors to exclude from scanning */
110- excludeSelectors? : string []
90+ options? : A11yPluginOptions
91+ theme? : ' light' | ' dark'
11192}
11293```
11394
95+ Common ` options ` fields:
96+
97+ - ` threshold ` : minimum impact level to show
98+ - ` ruleSet ` : rule preset (` 'wcag2a' | 'wcag2aa' | 'wcag21aa' | 'wcag22aa' | 'section508' | 'best-practice' | 'all' ` )
99+ - ` disabledRules ` : rule IDs to ignore
100+ - ` showOverlays ` : highlight issues in the page
101+ - ` runOnMount ` : auto-scan when panel mounts
102+ - ` persistSettings ` : store config in localStorage
103+ - ` liveMonitoring ` : watch DOM mutations and re-scan automatically
104+ - ` liveMonitoringDelay ` : debounce delay (ms)
105+
114106### Example with Configuration
115107
116108``` tsx
117109<A11yDevtoolsPanel
118- defaultStandard = " wcag21aa"
119- defaultLiveMonitoring = { true }
120- autoScan = { true }
121- excludeSelectors = { [' .third-party-widget' , ' [data-testid="skip-a11y"]' ]}
110+ theme = { theme }
111+ options = { {
112+ ruleSet: ' wcag21aa' ,
113+ threshold: ' moderate' ,
114+ runOnMount: true ,
115+ showOverlays: true ,
116+ liveMonitoring: true ,
117+ liveMonitoringDelay: 1000 ,
118+ disabledRules: [' color-contrast' ],
119+ }}
122120/>
123121```
124122
@@ -201,33 +199,32 @@ function MyComponent() {
201199
202200## Vanilla JavaScript API
203201
204- For non-React applications, use the vanilla JavaScript plugin :
202+ For non-React applications, ` createA11yPlugin() ` exposes a small programmatic API in addition to the TanStack Devtools ` render() ` integration :
205203
206204``` ts
207205import { createA11yPlugin } from ' @tanstack/devtools-a11y'
208206
209207const plugin = createA11yPlugin ({
210- standard : ' wcag21aa' ,
208+ ruleSet : ' wcag21aa' ,
211209 liveMonitoring: true ,
212210 showOverlays: true ,
213211})
214212
215213// Run a scan
216- const result = await plugin .scan ()
214+ const result = await plugin .scan ?. ()
217215
218- // Start live monitoring
219- plugin .startLiveMonitoring ()
220-
221- // Stop live monitoring
222- plugin .stopLiveMonitoring ()
223-
224- // Subscribe to scan results
225- plugin .onScan ((result ) => {
226- console .log (' Issues found:' , result .issues .length )
216+ // Subscribe to scan results (manual or live)
217+ const unsubscribe = plugin .onScan ?.((next ) => {
218+ console .log (' Issues found:' , next .issues .length )
227219})
228220
221+ // Control live monitoring
222+ plugin .startLiveMonitoring ?.()
223+ plugin .stopLiveMonitoring ?.()
224+
229225// Clean up
230- plugin .destroy ()
226+ unsubscribe ?.()
227+ plugin .destroy ?.()
231228```
232229
233230## Export Formats
0 commit comments