Accessibility
An accessible interface lets people read, navigate, enter information, and recover from errors using their preferred input and assistive technology. This chapter covers Pax's current support, practical testing, and web reader content. For control properties and form recipes, see User Interface Controls.
Focus and keyboard interaction
Native text fields own editing, selection, and keyboard input while focused.
To request focus when a Textbox appears, set focus_on_mount=true. This can
be useful for a deliberate editing action; avoid taking focus automatically
from someone already navigating the page. On a mobile device, focusing a
field can also bring up the software keyboard.
On web, declare controls in the order someone uses them. Tab navigation follows the DOM structure, independently of paint depth. Moving a control between containers can affect its focus and position in that order. Pax has no public cross-container tab-order setting. Check both Tab and Shift-Tab, including neighboring host-page controls when embedding a Pax app.
Tab visits interactive controls; screen-reader navigation also reaches instructions, labels, and other static text. Test both paths through the interface.
On web and the alpha Windows/Linux hosts, a focused native control keeps
its keyboard input instead of also dispatching canvas shortcuts. A component's
@key_down is not a text-entry hook
or a way to make a drawn widget focusable. See
Keyboard events for the app-level
event boundary.
Covering a control can block pointer activation without removing keyboard focus. An Overlay supplies presentation and placement; it does not establish modal focus behavior. See Scroller islands and modal underlays for how overlays affect input.
Test a task from start to finish
Choose a real task, such as editing and saving a profile. The accessibility form provides a small example with a name field, checkbox, and Save button.
- Keyboard. Look for visible focus at each stop. Enter a name, toggle the checkbox with Space, and activate Save. Verify one save and read the result. Walk backward with Shift-Tab and check that you can leave the form.
- Screen reader. Listen for instructions, control purpose, role, state, and result. Try saving an empty name and finding the error. A visible validation message does not automatically become an announcement. On touch devices, also explore by touch, swipe between items, and activate controls using the screen reader's gestures.
- Overlays and scrolling. For a modal dialog, check where keyboard and accessibility focus land, whether either can reach the background, and where they return after dismissal. Check that offscreen controls in scrollers remain reachable.
- Text and visual preferences. Try larger text, browser zoom, and a narrow viewport. Fixed font sizes do not follow iPadOS Dynamic Type. Check focus, contrast, and selected states with Increase Contrast, Reduce Transparency, or forced colors. The web Checkbox's white checkmark can disappear in a light forced-colors palette. Provide a way to pause moving content; see motion choices.
- Other input. With a composing keyboard, select a candidate and check that Return confirms it before a later Return submits the field. Scroll while editing and check the candidate position and selection. Try touch and Switch Control on a device, including an alternative to any drag.
Record the target, OS, browser or native host, assistive technology, and task outcome. Inspecting an accessibility tree can help explain a skipped control; also listen to announcements and complete the action.
Target considerations
Test each target with its intended screen reader and input methods. Android, Windows, and Linux support is alpha. Android supports TalkBack navigation and activation of native controls, but reading order, custom-control semantics, and overlay focus containment and return remain incomplete. See control support by target for the available controls and platform differences.
Reading static web content
A web build extracts an HTML article from your templates for crawlers, assistive technology, and browser reading modes. Use reader directives to add headings or omit content that only makes sense in the live interface:
///@reader.h1
<Text>A place for your ideas</Text>
<Text>Capture a thought and follow where it leads.</Text>
<Link url="/about"><Text>About this project</Text></Link>
///@reader.ignore
<Group>
<Text>Drag the sample card to rotate it.</Text>
</Group>
The article contains a level-one heading, a paragraph and an About link. The live interface still displays the drag instruction. Reader directives describe initial HTML. A live control's accessible name, actions, state and focus come from its runtime representation.
Place each directive on its own line before the next node in the same scope.
///@reader.h1 through ///@reader.h6 require a text component.
///@reader.ignore omits the following node and its descendants. Directives
cannot cross a closing tag or an @settings boundary. Invalid or unattached
directives are compile errors.
Older ///#ignore and ///#h1 through ///#h6 directives still work. Upgrade
the web build toolchain before switching to ///@reader.; older compilers
read the namespaced form as an ordinary comment.
The browser can read the article before Pax starts. It is visually clipped during ordinary use, revealed when one of its links receives focus, and shown when printing or when JavaScript is disabled. Browser Reader availability and search indexing depend on the reader or crawler. Review both the article and the live scene, including the transition between their links and controls.
What gets extracted
Extraction follows authored source order, component inputs, and projected
children. It resolves statically known values, conditions, and bounded repeats.
A literal markdown=true uses Markdown for that Text; raw HTML and unsafe
link schemes are omitted.
The compiler does not run Rust defaults, lifecycle handlers, or arbitrary functions. Two-way bindings, viewport-dependent values, and unresolved branches can therefore be absent. Pass essential stable copy through known template inputs.
Imported settings and runtime slot projection can also leave content unresolved. Review build diagnostics and the generated article. Rebuild after template edits: Pax hot reload updates the live interface, not the extracted article. See extracted route text for route-specific HTML.
Component contracts for reader content
The extractor normally follows the component template and slots. If a component arranges projected children through Rust, it can declare that visiting each authored child once in source order gives its reading content:
#![allow(unused)] fn main() { #[pax] #[file("carousel.pax")] #[pax_document(children)] pub struct Carousel {} }
Use this only when all those children belong in the document. Stacker and Scroller use this contract. A template-less primitive without a contract omits its children; unresolved runtime projection produces a build diagnostic.
Current limitations
Pax's broader accessibility model is still incomplete. Pax has no general authoring API for accessible names, descriptions, roles, label associations, or a reading order independent of visual layout. Placing a Text label beside a field does not associate it with that field for assistive technology. Image and NativeImage expose no alternative-text property, and custom drawings do not automatically acquire control semantics.
Read more
Continue to Animation & Motion, including motion choices. User Interface Controls covers forms and bindings, and Routing explains route-specific reader content.