Config File
AMA comes with predefined rules and severity levels for the built-in components and hooks. These rules have been created to improve the accessibility of each element and should always be respected.
Customizing log levels can be done via the ama.config.json file to handle edge cases that are out of our control, and require breaking a rule or two.
The library does not perform any accessibility checks on the production build!
Log Levels
AMA guidelines are categorised as:
- and : Those best practices are enforced and AMA overlays an error when they fail
- and : Those best practices are preferred and AMA prints only a warning message when they fail
The possible log levels are:
- error: The AMA error overlay is shown when a check fails
- warn: A
console.warnis performed when a check fails
ama.config rules
| Log key | Guideline | Default | Can override |
|---|---|---|---|
| BOTTOM_SHEET_CLOSE_ACTION | error | ||
| CONTRAST_FAILED | error | ||
| CONTRAST_FAILED_AAA | warn | ||
| FLATLIST_NO_COUNT_IN_SINGULAR_MESSAGE | warn | ||
| FLATLIST_NO_COUNT_IN_PLURAL_MESSAGE | error | ||
| IMAGE_MISSING_ALT_TEXT | error | ||
| INCOMPATIBLE_ACCESSIBILITY_ROLE | error | ||
| INCOMPATIBLE_ACCESSIBILITY_STATE | error | ||
| INPUT_HAS_FOCUSABLE_LABEL | error | ||
| INPUT_HAS_NO_VISIBLE_LABEL | error | ||
| INPUT_HAS_NO_VISIBLE_LABEL_ENDING_WITH_ASTERISK | error | ||
| INPUT_INVALID_RETURN_KEY | error | ||
| MINIMUM_SIZE | error | ||
| NO_ACCESSIBILITY_LABEL 1 | error | ||
| NO_ACCESSIBILITY_ROLE 1 | error | ||
| NO_ACCESSIBILITY_STATE_SET | error | ||
| NO_FORM_ERROR | error | ||
| NO_HEADER_FOUND | error | ||
| NO_KEYBOARD_TRAP 1 | error | ||
| NO_UNDEFINED 1 | error | ||
| NO_UPPERCASE_ACCESSIBILITY_LABEL | warn | ||
| NO_UPPERCASE_TEXT | error | ||
| UPPERCASE_TEXT_NO_ACCESSIBILITY_LABEL | error |
Rules marked with are considered essential practices and cannot be turned off.
Customizing the Log Levels
A JSON file called ama.config.json should have been automatically generated in the project's root folder (if it didn't, simply create it). Specify the custom log level for the keys you want to override. Any changes to this file are automatically picked up by AMA in dev mode — you will need to restart your application to see them applied.
Example
The JSON file does not need to contain all log keys. AMA uses the default rule if a key is not present:
{
"rules": {
"CONTRAST_FAILED": "warn",
"CONTRAST_CHECKER_MAX_DEPTH": 0
},
"accessibilityLabelExceptions": ["FAQ"],
"highlight": {
"mode": "border",
"borderWidth": 2,
"gap": 8
},
"log": "always",
"uppercaseMinLength": 5,
"checks": {
"ui": true,
"forms": true,
"delay": 300
}
}
Configuration keys
rules
Per-rule severity overrides. Each key is an AmaRule string (see table above) and each value is one of:
| Value | Effect |
|---|---|
"MUST" / "MUST_NOT" | Triggers the AMA error overlay |
"SHOULD" / "SHOULD_NOT" | Prints a console.warn |
"PLEASE_FORGIVE_ME" | Silences the rule entirely |
Non-overridable rules (marked in the table) ignore any value set here.
accessibilityLabelExceptions
AMA performs various checks, including one for uppercase. This key allows specifying a list of approved all-caps accessibility labels that should not trigger the uppercase rule.
{
"accessibilityLabelExceptions": ["FAQ"]
}
accessibilityLabelExceptions is a top-level key, not nested under rules.
highlight
Controls how AMA visually marks failing elements in the dev overlay.
| Key | Type | Default | Description |
|---|---|---|---|
mode | "border" | "background" | "both" | "both" | Whether to outline, fill, or both when highlighting a failing element |
borderWidth | number | 3 | Width of the highlight border in dp |
gap | number | 4 | Minimum gap between highlighted elements in dp |
{
"highlight": {
"mode": "border",
"borderWidth": 2,
"gap": 8
}
}
log
Controls when AMA logs accessibility issues to the console.
| Value | Behaviour |
|---|---|
"inspect" (default) | Logs only when the AMA inspector is open |
"always" | Always logs to the console in dev mode |
{
"log": "always"
}
uppercaseMinLength
The minimum number of characters a text string must have before the uppercase rule (NO_UPPERCASE_TEXT) is applied. Strings shorter than this value are not checked for uppercase.
| Type | Default |
|---|---|
| number | 4 |
{
"uppercaseMinLength": 5
}
checks
Feature gates that enable or disable categories of AMA runtime checks.
| Key | Type | Default | Description |
|---|---|---|---|
ui | boolean | true | Enable UI interaction checks |
forms | boolean | true | Enable form and node checks |
delay | number | 1000 | Milliseconds to wait before re-checking after an interaction |
{
"checks": {
"ui": true,
"forms": true,
"delay": 300
}
}
Constants
These values are set inside the rules object and control internal check behaviour rather than rule severity.
| Constant key | Default | Description |
|---|---|---|
CONTRAST_CHECKER_MAX_DEPTH | 5 | How many levels deep AMA checks children for contrast. Set to 0 to disable contrast checking entirely. |
IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS | false | When true, contrast checks are skipped for elements that are disabled. |
{
"rules": {
"CONTRAST_CHECKER_MAX_DEPTH": 0,
"IGNORE_CONTRAST_FOR_DISABLED_ELEMENTS": true
}
}