Skip to content

Accessibility

A PAM Desktop interface is made of platform views, so it reaches assistive technology through each system’s own API: AT-SPI on Linux (through GTK), NSAccessibility on macOS and UI Automation on Windows. You describe roles, names, states and actions once in PHP; the render core resolves them and each backend maps the result.

Element Default role
Text Static text, named by its text
Button, any element with a press handler Button
Input Text input; the native field describes its value, caret and selection
Image Image; without a label it is treated as decoration and hidden
Toggle Switch, with its checked state
ActivityIndicator Progress bar
Modal, BottomSheet, UI\Window Dialog
VirtualizedList, FlatList, SectionList List

An element with enabled(false) is reported as disabled, and a Button in its loading() state as busy.

use Pam\Desktop\AccessibilityRole;
Pressable::make(Image::make('asset://assets/trash.png')->style(new Style(width: 20, height: 20)))
->accessibilityLabel('Delete invoice')
->accessibilityHint('Moves the invoice to the trash')
->onPress($this->delete(...));
Text::make('Invoices')->accessibilityRole(AccessibilityRole::Header);
Image::make('asset://assets/revenue.png')
->accessibilityLabel('Revenue by month, rising since March')
->style(new Style(width: 320, height: 180));
Method Meaning
accessibilityLabel($label) The accessible name; replaces the element’s text as its name.
accessibilityHint($hint) What the element does.
accessibilityRole(AccessibilityRole) The role, when the default is wrong.
accessible(false) Hides the element; its children stay exposed.
accessibilityImportance(AccessibilityImportance::NoHideDescendants) Hides the element and everything inside it.
testId($id) A stable identifier for automation and tests.

AccessibilityRole includes Button, Checkbox, ComboBox, Header, Link, List, ListItem, Menu, MenuItem, ProgressBar, Radio, Search, Tab, TabList, ToggleButton, Toolbar, Adjustable (a slider) and more; None and Presentation hide the element.

use Pam\Desktop\AccessibilityCheckedState;
use Pam\Desktop\AccessibilityLiveRegion;
Pressable::make(Text::make('Bold'))
->accessibilityRole(AccessibilityRole::ToggleButton)
->accessibilityChecked($this->bold ? AccessibilityCheckedState::Checked : AccessibilityCheckedState::Unchecked)
->onPress(fn () => $this->bold = !$this->bold);
View::make()
->accessibilityRole(AccessibilityRole::Adjustable)
->accessibilityLabel('Volume')
->accessibilityValue(0, 100, $this->volume, "{$this->volume} percent");
Text::make($this->status)->accessibilityLiveRegion(AccessibilityLiveRegion::Polite);

accessibilitySelected(), accessibilityExpanded() and accessibilityBusy() report the other common states. A live region announces the element’s new name whenever it changes.

use Pam\Desktop\System\Accessibility;
Accessibility::announce('Upload finished', function (bool $delivered): void {
// false when no screen reader was running to speak it
});
Accessibility::screenReaderEnabled(fn (bool $enabled) => $this->screenReader = $enabled);

Announcements are polite: they do not interrupt what is being read. The text holds 1 to 4096 characters.

The default action of a pressable is its press. Custom actions give assistive technology more verbs:

use Pam\Desktop\AccessibilityAction;
Row::make(Text::make($message))
->accessibilityActions(
new AccessibilityAction('archive', 'Archive'),
new AccessibilityAction('delete', 'Delete'),
)
->onAccessibilityAction(fn (string $name) => match ($name) {
'archive' => $this->archive($index),
'delete' => $this->remove($index),
default => null,
});

An element takes one to eight actions. Custom actions are exposed on macOS; the Linux and Windows backends do not expose them yet, so always provide another way to reach the same command.

  • Tab and Shift+Tab move focus between pressables and text inputs.
  • Enter and Space activate the focused pressable.
  • Escape closes the topmost modal or sheet.
  • Alt+Left (Cmd+[ on macOS) goes back in a navigator.
  • F5 or Ctrl+R refreshes a visible list with onRefresh.
  • The menu key and Shift+F10 open the context menu of the focused element.

Style focus with :focus-visible so keyboard users see where they are without a ring after every click:

.item:focus-visible { border-color: #2563EB; border-width: 2px; }

Text is not selectable by default. selectable() enables drag, double-click and triple-click selection, Shift+click extension and copying with Ctrl+C (Cmd+C). Text inside a pressable is not selectable, because a press wins.

The host reads the system text scale and the reduced-motion setting and follows their changes while the application runs:

System Text scale Reduced motion
Linux gtk-xft-dpi gtk-enable-animations
macOS Always 1 Reduce Motion
Windows The system text size setting The system animation setting

Size containers so text can grow: prefer minHeight over a fixed height for rows that hold text, and test at a 1.5 text scale with Accessibility::setTextScale(1.5). See Styling.