import { CodeSnippet } from '@fluentui/docs-components';
import * as React from 'react';
import { Header } from '@fluentui/react-northstar';
import DocPage from '../components/DocPage';
import { code, link } from '../utils/helpers';
import { Link } from 'react-router-dom';
export default () => (
In Fluent UI, accessibility behaviors encapsulate the logic needed for keyboard navigation, focus handling and
screen reading. They essentially add ARIA roles, ARIA attributes and event handlers to components' parts. The idea
is to compose visual components and apply a behavior on top of them to achieve the desired keyboard navigation and
screen reader support.
Each relevant component comes with its default accessibility behavior. For some components there are additional
behaviors to choose from. In addition to that, user can create custom behaviors and use them instead of the
standard ones.
Users are also able to add or override attributes generated by the accessibility behaviors if customization is
needed.
Accessibility behavior type is a callback function which receives "props" as parameters and returns an
accessibility behavior object. Type: {code('(props: any) => AccessibilityDefinition')}.
Type: {code('{ [partName: string]: AccessibilityAttributes }')}. Type: {code('{ [partName: string]: { [actionName: string]: KeyAction } }')}. Type: {code('{ props?: FocusZoneProps }')}.
Accessible Rich Internet Applications (ARIA) is a set of attributes that define ways to make web content more
accessible to people with disabilities.
ARIA attributes are applied according to {link('ARIA specification', 'https://www.w3.org/TR/wai-aria-1.1/')} and{' '}
{link('ARIA best practices', 'https://www.w3.org/TR/wai-aria-practices-1.1/')}.
For example, Menu component:
Default accessibility behavior for {code('Menu')} component is {code('menuBehavior')} ({code('menuItemBehavior')}{' '}
for the {code('MenuItem')}). These behaviors add appropriate ARIA roles by default:
Rendered HTML: Menu behavior - role "menu" is applied to root part (container) of the component:
Menu item behavior - role "presentation" is applied to wrapper part of the component (which is {code('
User can override the default behavior by using the {code('accessibility')} attribute, as well as override generated attributes:
Apart from overriding the default behavior with an existent one, it is also possible to create your own custom behavior.
Also, if a particular behavior matches your needs but you want to change some of the props, you can create a new behavior based on an existent one and override what is needed.
For example, using {code('menuBehavior')}, creates a new behavior with some of its FocusZone's props overridden.
All Fluent UI behaviors implementations can be found on the{' '} {link( 'GitHub', 'https://github.com/microsoft/fluentui/tree/master/packages/fluentui/accessibility/src/behaviors', )} .
The default and other available behaviors for all the components can be found in the {link('documentation', '/')}, together with notes on other accessibility considerations for using the component. The examples show the recommended way of using the components in different variations. It is possible to edit example's code, see the rendered HTML, change themes and validate the rendering in RTL scenario, or with different behaviors.
Read more about: