• Organism
  • CORE COMPONENT
  • Taxonomic name: O-ACCESSIBILITY-SETTINGS
  • Added on: v4.7.0 (01/03/19)
  • Updated on: v5.10.0 (10/08/21)

Accessibility settings

This section eneables users to be able to control the accessibility settings for a single website. At this time, only the use of motion is controlable, but more options may be added in future.


Design and usage

Structure

  • Section to control accessibility settings.
  • Controls consist only of radio buttons.
  • Visual notification highlighting that accessibility changes only affect the current domain, eg. aviva.co.uk.
  • Controls are accompanied by label and explanatory text.
  • Upon submission, a notification highlighting that preferences have taken effect must be displayed.

Placement

  • Accessibility settings section sits below accessibility page introductory section.

Errors

  • If the user has not accepted or has disabled the use of cookies, an error notification must be displayed to inform the user that they will not be able to save their accessibility preferences.

Non-JS requirements and considerations

  • Accessibility settings section must be hidden, as the user is unable to save their settings without JS present.
  • All motion must be disabled.

Accessibility and screen readers

  • Aria-invalid must be used to indicate when an error has occurred with this element.
  • Aria-describedby must be used to link any help, instructional and/or error text with the element/form fields.

Examples

For a fully in-context example, view this site's accessibility page.

Interactive example

Code example

<div class="o-accessibility-settings" data-module="o-accessibility-settings" data-module-load="true">
	<hr class="a-divider-line a-divider-line--60-all a-divider-line--horizontal-solid" />	<div class="l-max l-max--9-column-large l-max--left">
		<h2 class="l-section__heading a-heading a-heading--1 u-margin--top-none">Accessibility settings</h2>		<div class="m-card m-card-notification m-card-notification--neutral" role="status">
			<div class="m-card-content">
				<div class="m-card-content__inner">
					<p>These settings only affect [ website domain ]</p>
					<p>This feature requires the use of a cookie to save your preference, alternatively this site also respects reduced motion preferences set on your device.</p>
				</div>
			</div>
		</div>		<div class="o-accessibility-settings__notification"></div>		<fieldset class="m-form-row m-form-row--full-width o-accessibility-settings__animation-toggle" aria-describedby="animations_toggle_exp">
			<legend class="a-label">Website animation</legend>
			<p class="m-form-row__explanatory-text" id="animations_toggle_exp">This includes all animations and transitions used across this website such as on video banners, form controls, expandable menus etc.</p>
			<div class="m-form-row__content">
				<ul class="m-form-row-group m-form-row-group--option-group">
					<li class="m-form-row-group-item m-form-row-group-item--full-width">
						<label class="a-radio" for="animations_toggle_on">
							<input class="a-radio__input" type="radio" name="animations_toggle" id="animations_toggle_on" value="On" checked />
							<span class="a-radio__label"><span class="a-radio__label-inner">On</span></span>
							<span class="a-radio__ui"></span>
						</label>
					</li>
					<li class="m-form-row-group-item m-form-row-group-item--full-width">
						<label class="a-radio" for="animations_toggle_off">
							<input class="a-radio__input" type="radio" name="animations_toggle" id="animations_toggle_off" value="Off" />
							<span class="a-radio__label"><span class="a-radio__label-inner">Off</span></span>
							<span class="a-radio__ui"></span>
						</label>
					</li>
				</ul>
			</div>
		</fieldset>		<ul class="m-button-group u-margin--bottom-none">
			<li class="m-button-group__item"><button class="a-button a-button--primary o-accessibility-settings__submit"><span class="a-button__inner">Submit</span></button></li>
		</ul>	</div>
</div>

Development and test

Notes for developers

In order to support the WCAG 2.3.3 accessibility guideline, all CSS and JavaScript animation/motion should be provided as an enhancement.

When JavaScript runs, if the user has not chosen to disable animations then a CSS class (u-animation) is added to the html element and a global JavaScript variable (FRAMEWORK.animation) is set to true that can then be used to enable animations on your components.

The following example shows how animation would be applied, firstly using CSS and secondly using JavaScript.

.a-example {
	transform: scale(1);
}
.a-example:hover,
.a-example:focus {
	transform: scale(2);
}
.u-animation .a-example {
	transition: transform .35s;
}
if ( FRAMEWORK.animation ) {
	element.slideDown( 350 );
} else {
	element.show();
}

The Framework also has some standard animation speeds (in milliseconds) available for use which will be automatically set to 0 if animation has been disabled. These can be used to keep code using animations more manageable.

FRAMEWORK.timings = {
	'current' : {
		t100ms : 100,
		t150ms : 150,
		t200ms : 200,
		t250ms : 250,
		t300ms : 300,
		t350ms : 350,
		t500ms : 500,
		t1s : 1000
	}
};

Between v4.3.0 and v4.8.0 the timings available were:

FRAMEWORK.timings = {
	'current' : {
		t150ms : 150,
		t350ms : 350,
		t500ms : 500,
		t1s : 1000
	}
};

As of v5.0.0 the jQuery.fx.off variable will be set on page load and if the animation setting is changed via the accessibility settings component, if jQuery is already present on the page. If your module loads jQuery as a dependancy ensure that the jQuery.fx.off variable is set appropriately when your module runs to ensure animations are not used when they shouldn't.

Aria usage for errors and help text

To aid screen reader users in completing forms without error and also with understanding and fixing any errors that have occured, some additional aria attributes are now recommended to be applied across all form fields/rows.

All form row help, explanatory text, form row instructions and form row errors must have a unique id assigned to them and be appropriately linked to either the individual form input or the form row using aria-describedby. This ensures that the help text is read out immediately on focus of the form input/fieldset. When there is more that one item that requires referencing within the aria-describedby attribute the id values must be supplied in the form of a space separated list. For example if there is an error with id of 'err1' and help text with id of 'help1' the value for the aria-describedby attribute would be 'err1 help1'.

All inline form error messages should start with the hidden text 'Error: ' so that when read by out by a screen reader it is immediately clear that the text being read is an error message.

All erroring form fields (or fieldset if a group or radios/checkboxes) must have aria-invalid="true" set on them, ensuring that when a user focus' on an errored form field, the field will be announced as invalid, so the user is then aware that there in an issue that requires fixing.

When linking help or errors, or even adding aria-invalid to the markup careful consideration must be taken as to where it is most appropriate to apply the value. The following rules should be used to decide where the attribute(s) should be applied.

  • Single form field - All attributes should be applied directly to that form field
  • Group of form fields but only one in error or help text applies to only one - Apply the attribute(s) to the only field in error or where the help text applies
  • Group of form field where all in error or the help text applies to all - Apply the attribute(s) to the groups surrounding fieldset (form row)

There may situations where more than one of these rules applies to the overall form row for example a date range where the instruction text applies to both fields so should be linked to the fieldset for the date range but one of the two fields is in error so the error should be linked to just that field not to the fieldset.

Controling the accessibility settings component programatically

Accessibility settings can be controlled programatically to turn animation preference on and off. The following method is available for use:

Method Description
setState( 'on' ) Set the animation state to either on or off with by passing in the string 'on' or 'off'.

For example:

document.addEventListener( 'frameworkready', function () {
	FRAMEWORK.require([ 'blocks/o-accessibility-settings' ], function ( oAccessibilitySettingsModule ) {
		var oAccessibilitySettingsEl = document.querySelector( '#accessibilitySettingsId' ),
			oAccessibilitySettingsInstance = oAccessibilitySettingsModule.initInstance( oAccessibilitySettingsEl );		oAccessibilitySettingsInstance.setState( 'off' );
	});
});

Changing locale settings

The notification message text can be updated for a particular locale.

en: {
	oAccessibilitySettings : {
		error : 'The ability to store your accessibility preferences for this website requires the use of cookies. Please enable cookies for this site so that we can save your preference, or use the prefer reduced motion setting on your device.',
		reduced : 'Animations and transitions have been automatically disabled for this website in accordance with your device settings.',
		success : 'Your preferences have been updated successfully.',
	},
},

For more information on this, see our page on how to change locale settings within JavaScript.


Notes for testers

  • Ensure that the selected option is visually clear.
  • Ensure that any notification messages (error or submission) are clear and read by screen readers.
  • Ensure that an error notification message is displayed and the submit button is disabled when users have not accepted or disabled cookies.

Classes overview

The following table gives you a quick overview of the CSS classes that can be applied.

Class Outcome Required Applied to Comments
.o-accessibility-settings Base class for the accessibility section Yes div  
.o-accessibility-settings__notification Class for the container where any notifications for the accessibility section will be displayed Yes .o-accessibility-settings div Should sit below the neutral notification and above the accessibility options
.o-accessibility-settings__animation-toggle Class for motion toggle form row Yes .o-accessibility-settings .m-form-row  
#animations_toggle_on ID for the motion toggle on option Yes .o-accessibility-settings__animation-toggle input  
#animations_toggle_off ID for the motion toggle off option Yes .o-accessibility-settings__animation-toggle input  
.o-accessibility-settings__submit Class for accessibility settings submit button Yes .o-accessibility-settings__animation-toggle .a-button--primary

Keyboard operations

TAB

Tabbing to an accessibility option or button, they will become it clearly visually different so that the focus point on the page is obvious to the user.

SPACE or ENTER

With focus on the submit button, pressing SPACE or ENTER will trigger the selected options to be saved to a cookie and notification displayed.

Component releases

  • Added on: v4.7.0 (01/03/19)
  • Updated on: v5.10.0 (10/08/21)

Latest update:

  • updated: aria-live="polite" has been removed from the notification card created by the JavaScript as this function is already performed for screenreaders by role="status"
  • updated: Accessibility settings can now be controlled programatically to turn animation preference on and off.

Full version history

A full history of changes and enhancements detailing all minor and major updates to the component.

View full version history

Want something new in Framework, or to chat about an issue you're having with it?

Contact the team