Raxol.Core.Accessibility (Raxol v0.3.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.
Clear all pending announcements.
Gets the current color scheme.
Disable accessibility features.
Enable accessibility features with the given options.
Gets the current font size multiplier.
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.
Checks if high contrast mode is enabled.
Register style settings for a component type.
Register metadata for an element to be used for accessibility features.
Checks if screen reader support is enabled.
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.
This function adds a message to the announcement queue that will be read by screen readers.
Parameters
message
- The message to announceopts
- Options for the announcementuser_preferences_pid_or_name
- The PID or registered name of the UserPreferences process to use (optional).
Options
:priority
- Priority level (:low
,:medium
,:high
) (default::medium
):interrupt
- Whether to interrupt current announcements (default:false
)
Examples
iex> Accessibility.announce("Button clicked")
:ok
iex> Accessibility.announce("Error occurred", priority: :high, interrupt: true)
:ok
Clear all pending announcements.
Examples
iex> Accessibility.clear_announcements()
:ok
Gets the current color scheme.
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
Gets the current font size multiplier.
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
Checks if high contrast mode is enabled.
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
Checks if screen reader support is enabled.
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