Skip to content

Accessibility

PAM Native renders real Android Views and UIKit controls, so the platform screen readers (TalkBack and VoiceOver), switch access, hardware keyboards and system text scaling already work with them. Your job is to give those tools the meaning they cannot guess: what an icon button does, which element is a heading, which value a slider holds, and what changes while the user waits.

This page shows the accessibility API on every element, the template attributes that mirror it, and the checks PAM runs for you.

Every element accepts a label (what it is), a hint (what happens when activated) and a role (how assistive technology should treat it):

use Pam\Native\AccessibilityRole;
use Pam\Native\UI\Image;
use Pam\Native\UI\Pressable;
use Pam\Native\UI\Text;
$title = Text::make('Orders')->accessibilityRole(AccessibilityRole::Header);
$delete = Pressable::make(Image::make('asset://assets/icons/trash.png'))
->accessibilityLabel('Delete order')
->accessibilityHint('Removes the order from this list')
->accessibilityRole(AccessibilityRole::Button)
->onPress($this->delete(...));

Roles available in AccessibilityRole (template names in lowercase): button, link, header, text, image, imagebutton, input, search, switch, checkbox, radio, radiogroup, combobox, adjustable (alias slider), progressbar, spinbutton, scrollbar, timer, alert, summary, tab, tablist, menu, menubar, menuitem, toolbar, list, listitem, grid, keyboardkey, togglebutton, presentation, none and generic.

A meaningful image needs a label; a decorative one must say so. Language 2 templates enforce this at compile time with diagnostic PAM2301:

<Image :source="$product->photo" :accessibilityLabel="$product->name" />
<Image source="asset://assets/divider.png" decorative="true" />

A Pressable or GestureDetector is one screen-reader element by default, so a row reads as a single item. Use accessible(false) to expose its children separately (for example a row with its own nested buttons):

$row = Pressable::make($avatar, $name, $followButton)
->accessible(false)
->onPress($this->openProfile(...));

Container roles (list, grid, menu, menubar, radiogroup, tablist, toolbar, alert) on a View, Row or Column keep children reachable while describing the group.

Hide decorative subtrees with accessibilityImportance():

use Pam\Native\AccessibilityImportance;
$background = View::make($confetti)
->accessibilityImportance(AccessibilityImportance::NoHideDescendants);

AccessibilityImportance has Auto, Yes, No and NoHideDescendants.

Announce state with accessibility properties, not only with color:

PHP Template Announces
accessibilityChecked(AccessibilityCheckedState::Checked) accessibilityCheckedState="checked" Checked, unchecked or mixed
accessibilityExpanded(true) accessibilityExpanded="true" Expanded or collapsed
accessibilitySelected(true) accessibilitySelected="true" Selected, without changing the visual selected state
accessibilityBusy() accessibilityBusy="true" Busy (loading)
accessibilityValue(0, 100, 40, '40 percent') accessibilityValueMin, accessibilityValueMax, accessibilityValueNow, accessibilityValueText A range value
enabled(false) enabled="false" Disabled; also removed from focus
<Pressable
p-for="$tab in $tabs"
:key="$tab['id']"
accessibilityRole="tab"
:accessibilitySelected="$tab['id'] === $active"
@press="select($tab['id'])"
>
<Text>{{ $tab['title'] }}</Text>
</Pressable>

An adjustable element with an on:accessibilityAction handler receives increment and decrement from VoiceOver’s swipe up/down and TalkBack’s slider gestures, without declaring them:

src/Components/QuantityStepper.php
<?php
declare(strict_types=1);
namespace App\Components;
use Pam\Native\AccessibilityRole;
use Pam\Native\Attributes\State;
use Pam\Native\Component;
use Pam\Native\Element;
use Pam\Native\UI\Row;
use Pam\Native\UI\Text;
final class QuantityStepper extends Component
{
#[State]
public int $quantity = 1;
public function render(): Element
{
return Row::make(Text::make("Quantity: {$this->quantity}"))
->accessibilityRole(AccessibilityRole::Adjustable)
->accessibilityLabel('Quantity')
->accessibilityValue(1, 10, $this->quantity, "{$this->quantity} items")
->onAccessibilityAction(function (string $action): void {
$this->quantity = match ($action) {
'increment' => min(10, $this->quantity + 1),
'decrement' => max(1, $this->quantity - 1),
default => $this->quantity,
};
});
}
}

Every swipe, drag, long press or context menu needs an alternative that a screen-reader user can reach. Expose it as a custom action; TalkBack lists it in its actions menu and VoiceOver in the actions rotor:

use Pam\Native\AccessibilityAction;
use Pam\Native\UI\Row;
use Pam\Native\UI\Text;
$row = Row::make(Text::make($message->subject))
->accessibilityLabel("Message from {$message->sender}")
->accessibilityActions(
new AccessibilityAction('reply', 'Reply'),
new AccessibilityAction('archive', 'Archive'),
)
->onAccessibilityAction(fn (string $action) => $this->perform($action, $message->id));

Names are stable lowercase identifiers (up to 64 bytes); labels are localized text (1–128 bytes). An element exposes between one and eight unique actions.

Announce content that changes while the user is elsewhere on the screen, such as a validation error or an upload status:

use Pam\Native\AccessibilityLiveRegion;
$status = Text::make($this->uploadStatus)
->accessibilityLiveRegion(AccessibilityLiveRegion::Polite);

Polite waits for the current announcement; Assertive interrupts it. Use Assertive only for errors that block the user. On iOS, PAM posts a VoiceOver announcement of the region’s label or visible text when it appears or changes.

Hardware keyboards, D-pads and switch access use the platform focus engine. Pressable and buttons participate automatically and show the system focus highlight; disabled controls leave the focus order.

$search->focusable()->autoFocus();
$rail->focusGroup(); // returning to the rail restores its last focused child
$card->nextFocus(down: 'checkout-button'); // D-pad down goes to the element with this testId
$button->focusRing(true);

autoFocus also works on inputs in templates (autoFocus="true"). nextFocus() targets reference other elements by their testId; directions you leave out keep the automatic choice.

Compact buttons and pressables keep their visual size while their native hit area expands to at least 48 dp on Android and 44 pt on iOS. You can extend it further with hitSlop; explicit values never shrink the platform minimum. Leave space between adjacent small controls so their expanded areas do not compete.

<Pressable hitSlop="12" accessibilityLabel="Close" @press="close">
<Icon name="close" />
</Pressable>

DesignTokens::TouchTarget (48) is the minimum height the built-in theme gives buttons and inputs.

System font scaling (Android font size, iOS Dynamic Type) is on by default for labels, button titles and inputs. Design for at least 200 % text: let rows grow, wrap instead of truncating, and avoid fixed heights on text containers.

PHP Template Effect
maxFontSizeMultiplier(1.5) maxFontSizeMultiplier="1.5" Caps growth at 150 % of the authored size. 0 means no cap.
allowFontScaling(false) allowFontScaling="false" Opts a label out. Reserve it for chrome that cannot grow, such as a tab badge.

To keep one consistent hierarchy at large sizes, set an app-wide cap by role at boot:

index.php
use Pam\Native\TextScalePolicy;
// Body text grows up to 160 %, display text (18 pt and larger) up to 130 %.
TextScalePolicy::set(maximum: 1.6, display: 1.3, displayFontSize: 18);

Per-element allowFontScaling and maxFontSizeMultiplier stay authoritative over the policy.

PAM follows one host policy: Android’s animator-duration setting and iOS Reduce Motion. When reduced motion is on, navigation transitions, shared elements, modals, sheets, keyframes, animation programs and press feedback commit their final state immediately; finite animations still fire their completion event exactly once. You do not need to branch on it in PHP.

For your own decorative motion in CSS, use the media query:

@media (prefers-reduced-motion: reduce) {
.hero { transition: none; }
}

App::windowMetrics()->reducedMotion exposes the same flag to PHP. See Animations.

The built-in themes are checked for WCAG AA contrast when they are built (see Theming). For your own colors:

  • reach 4.5:1 for body text and 3:1 for large text and focus indicators. Theme::contrastRatio($foreground, $background) computes the ratio for two ARGB colors;
  • never use color as the only signal: pair a red border with an error message, a green dot with “Online”.
use Pam\Native\Theme;
$ratio = Theme::contrastRatio(0xFF475569, 0xFFFFFFFF); // ≈ 7.6

PAM catches common mistakes before they reach a device:

  • PAM2301: an Image in a Language 2 template without accessibilityLabel or decorative="true";
  • PAM2302: an accessibility attribute no renderer applies (for example React Native’s accessibilityState or aria-*). It is a warning in development and an error in strict and release builds.

Automated checks prove the mapping, not the experience. Before a release, walk your main journeys with TalkBack and VoiceOver on real hardware, with the largest text size and with reduced motion on.

  • Every icon-only control has an accessibilityLabel.
  • Headings use AccessibilityRole::Header; decorative images are decorative.
  • Swipe, drag and long-press actions have a custom action or a visible button.
  • State is announced (checked, selected, expanded, busy), not only colored.
  • Layout survives 200 % text without clipped labels.
  • Content is reachable by keyboard and D-pad in a logical order.
  • Nothing sits under a system bar (Safe Areas).