Skip to main content

gpui_core/
_accessibility.rs

1//! Accessibility guide.
2//!
3//! GPUI exposes accessibility through [AccessKit](https://accesskit.dev/).
4//! Elements opt into the accessibility tree by providing both a stable
5//! [`ElementId`](crate::ElementId) and an accessible role.
6//!
7//! The usual entry point for application code is the fluent API on
8//! [`StatefulInteractiveElement`](crate::StatefulInteractiveElement):
9//!
10//! ```ignore
11//! div()
12//!     .id("save-button")
13//!     .role(gpui::Role::Button)
14//!     .aria_label("Save")
15//!     .aria_description("Save the active document")
16//!     .aria_keyshortcuts("Ctrl+S")
17//!     .on_click(|_, window, _| {
18//!         window.refresh();
19//!     })
20//! ```
21//!
22//! `aria_keyshortcuts` only reports existing shortcut metadata to assistive
23//! technology; it does not register a GPUI key binding.
24//!
25//! For development diagnostics, [`Window::debug_a11y_tree_json`](crate::Window::debug_a11y_tree_json)
26//! returns the latest completed accessibility frame as JSON once accessibility
27//! is active for the window.
28//!
29//! This core crate builds the AccessKit tree, maps focused GPUI elements to
30//! AccessKit nodes, and dispatches accessibility actions back into GPUI.
31//! Platform-specific adapter wiring is provided separately by GPUI's internal
32//! platform window implementations.