Raxol.Core.Accessibility (Raxol v0.5.0)
View SourceAccessibility module for Raxol terminal UI applications.
This module provides accessibility features including:
- Screen reader announcements
- Keyboard navigation enhancements
- High contrast mode
- Reduced motion support
- Focus management
- Large text support
Usage
# Enable accessibility features
Accessibility.enable()
# Make an announcement for screen readers
Accessibility.announce("You have selected the search button")
# Enable high contrast mode
Accessibility.set_high_contrast(true)
# Enable reduced motion mode
Accessibility.set_reduced_motion(true)
# Enable large text mode
Accessibility.set_large_text(true)
Summary
Functions
Make an announcement for screen readers.
Make an announcement for screen readers with a specific priority.
Make an announcement for screen readers with a specific priority and user preferences.
Clear all pending announcements.
Disable accessibility features.
Enable accessibility features with the given options.
Get the current color scheme based on accessibility settings.
Get style settings for a component type.
Get metadata for an element.
Get the next announcement to be read by screen readers.
Gets an accessibility option value.
Get the current text scale factor based on the large text setting.
Delegates theme changed events to the EventHandlers module.
Register style settings for a component type.
Register metadata for an element to be used for accessibility features.
Enable or disable high contrast mode.
Enable or disable large text mode.
Sets an accessibility option value.
Enable or disable reduced motion.
Functions
Make an announcement for screen readers.
Parameters
message
- The message to announce
Examples
iex> Accessibility.announce("You have selected the search button")
:ok
Make an announcement for screen readers with a specific priority.
Parameters
message
- The message to announcepriority
- The priority of the announcement (:polite or :assertive)
Examples
iex> Accessibility.announce("You have selected the search button", :assertive)
:ok
Make an announcement for screen readers with a specific priority and user preferences.
Parameters
message
- The message to announcepriority
- The priority of the announcement (:polite or :assertive)user_preferences_pid_or_name
- The PID or registered name of the UserPreferences process to use (optional)
Examples
iex> Accessibility.announce("You have selected the search button", :assertive, :user_preferences)
:ok
Clear all pending announcements.
Examples
iex> Accessibility.clear_announcements()
:ok
Disable accessibility features.
Examples
iex> Accessibility.disable()
:ok
Enable accessibility features with the given options.
Parameters
options
- Options to override the default accessibility settingsuser_preferences_pid_or_name
- The PID or registered name of the UserPreferences process to use (optional).
Options
:high_contrast
- Enable high contrast mode (default:false
):reduced_motion
- Enable reduced motion (default:false
):large_text
- Enable large text (default:false
):screen_reader
- Enable screen reader support (default:true
):keyboard_focus
- Enable keyboard focus indicators (default:true
):silence_announcements
- Silence screen reader announcements (default:false
)
Examples
iex> Accessibility.enable(high_contrast: true)
:ok
iex> Accessibility.enable(reduced_motion: true, screen_reader: false)
:ok
Get the current color scheme based on accessibility settings.
Examples
iex> Accessibility.get_color_scheme()
%{background: ...} # Returns the current color scheme
Get style settings for a component type.
Parameters
component_type
- Atom representing the component type
Returns
- The style map for the component type, or empty map if not found
Examples
iex> Accessibility.get_component_style(:button)
%{background: :blue}
Get metadata for an element.
Parameters
element_id
- Unique identifier for the element
Returns
- The metadata map for the element, or
nil
if not found
Examples
iex> Accessibility.get_element_metadata("search_button")
%{label: "Search"}
Get the next announcement to be read by screen readers.
This function is typically called by the screen reader integration.
Examples
iex> Accessibility.get_next_announcement()
"Button clicked"
Gets an accessibility option value.
Get the current text scale factor based on the large text setting.
Parameters
user_preferences_pid_or_name
- The PID or registered name of the UserPreferences process to use (optional).
Examples
iex> Accessibility.get_text_scale()
1.0 # or 1.5 if large_text is enabled
Delegates theme changed events to the EventHandlers module.
Register style settings for a component type.
Parameters
component_type
- Atom representing the component typestyle
- Style map to associate with the component type
Examples
iex> Accessibility.register_component_style(:button, %{background: :blue})
:ok
Register metadata for an element to be used for accessibility features.
Parameters
element_id
- Unique identifier for the elementmetadata
- Metadata to associate with the element
Examples
iex> Accessibility.register_element_metadata("search_button", %{label: "Search"})
:ok
Enable or disable high contrast mode.
Parameters
enabled
-true
to enable high contrast,false
to disable.user_preferences_pid_or_name
- The PID or registered name of the UserPreferences process to use (optional).
Examples
iex> Accessibility.set_high_contrast(true)
:ok
Enable or disable large text mode.
Parameters
enabled
-true
to enable large text,false
to disable.user_preferences_pid_or_name
- The PID or registered name of the UserPreferences process to use (optional).
Examples
iex> Accessibility.set_large_text(true)
:ok
Sets an accessibility option value.
Enable or disable reduced motion.
Parameters
enabled
-true
to enable reduced motion,false
to disable.user_preferences_pid_or_name
- The PID or registered name of the UserPreferences process to use (optional).
Examples
iex> Accessibility.set_reduced_motion(true)
:ok