-
Notifications
You must be signed in to change notification settings - Fork 1.4k
docs: Add Quality page #9099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+183
−54
Merged
docs: Add Quality page #9099
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1403064
docs: Add concepts page
devongovett dfb9f99
Fix description
devongovett 1c4825a
Merge branch 'main' of github.com:adobe/react-spectrum into concepts
devongovett 08de791
updates
devongovett 059ec9b
Merge branch 'main' of github.com:adobe/react-spectrum into concepts
devongovett 7c2c718
Rename to quality
devongovett 96093da
Standardize format of guide page descriptions
devongovett 979ccdf
fix links
devongovett 44c4e85
relative URLs
devongovett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| import {Layout} from '../../src/Layout'; | ||
| export default Layout; | ||
|
|
||
| export const section = 'Guides'; | ||
| export const description = 'Learn about Accessibility, Internationalization, and Interactions in React Aria'; | ||
|
|
||
| # Concepts | ||
|
|
||
| <PageDescription>React Aria is built around three core principles: **Accessibility**, **Internationalization**, and **Interactions**. Together, these ensure that every component you build works for everyone, everywhere, and on every device.</PageDescription> | ||
|
|
||
| ## Accessibility | ||
|
|
||
| Accessible applications are usable by everyone, including people with disabilities. Accessibility benefits all users — not just those using assistive technologies — by improving efficiency, consistency, and usability. | ||
|
|
||
| React Aria provides built-in support for screen readers and keyboard navigation, following the [WAI-ARIA](https://www.w3.org/TR/wai-aria-1.2/) and [ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/) guidelines. It supplies the correct semantics via ARIA roles and attributes, handles keyboard and pointer events, manages focus, and provides screen reader announcements. React Aria components are tested across a wide variety of devices, browsers, and screen readers. | ||
|
|
||
| You’re responsible for providing meaningful labels and ensuring your visual design supports all users. This includes designing with sufficient [color contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast) and [hit target sizes](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced), including visible [focus rings](https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance), respecting [motion preferences](https://www.w3.org/WAI/WCAG21/Understanding/animation-from-interactions), and more. The [WCAG guidelines](https://www.w3.org/WAI/WCAG22/Understanding/) are a good resource to reference when designing and building components with React Aria. | ||
|
|
||
| ### Labeling | ||
|
|
||
| Most components should have a visible label, which is usually provided by rendering a `<Label>` element within it. This is associated with the component automatically. | ||
|
|
||
| ```tsx | ||
| import {TextField, Label, Input} from 'react-aria-components'; | ||
|
|
||
| <TextField> | ||
| {/*- begin highlight -*/} | ||
| <Label>First name</Label> | ||
| {/*- end highlight -*/} | ||
| <Input /> | ||
| </TextField> | ||
| ``` | ||
|
|
||
| When a component doesn't have a visible label, it must have an [aria-label](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label) or [aria-labelledby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby) prop to provide an accessible name. | ||
|
|
||
| ```tsx | ||
| import {ProgressBar} from 'react-aria-components'; | ||
|
|
||
| <ProgressBar | ||
| /*- begin highlight -*/ | ||
| aria-label="Processing" /> | ||
| /*- end highlight -*/ | ||
| ``` | ||
|
|
||
| ### Supported screen readers | ||
|
|
||
| React Aria is tested across a variety of devices, browsers, and screen readers. | ||
|
|
||
| * [VoiceOver on macOS](https://www.apple.com/accessibility/mac/vision/) in Safari and Chrome | ||
| * [JAWS](https://www.freedomscientific.com/products/software/jaws/) on Windows in Firefox and Chrome | ||
| * [NVDA](https://www.nvaccess.org) on Windows in Firefox and Chrome | ||
| * [VoiceOver on iOS](https://www.apple.com/accessibility/iphone/vision/) | ||
| * [TalkBack](https://www.android.com/accessibility/) on Android in Chrome | ||
|
|
||
| ### Automated testing | ||
|
|
||
| Automated accessibility testing tools sometimes catch false positives in React Aria. These are documented in our [wiki](https://github.com/adobe/react-spectrum/wiki/Known-accessibility-false-positives). Use the rules below to ignore these issues in your own testing tools, such as in the [Storybook test runner](https://storybook.js.org/docs/7.1/react/writing-tests/accessibility-testing#a11y-config-with-the-test-runner) or [Storybook a11y addon](https://storybook.js.org/docs/7.1/react/writing-tests/accessibility-testing#global-a11y-configuration). | ||
reidbarber marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```tsx | ||
| { | ||
| rules: [ | ||
| { | ||
| id: 'aria-hidden-focus', | ||
| selector: 'body *:not([data-a11y-ignore="aria-hidden-focus"])' | ||
snowystinger marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ## Internationalization | ||
|
|
||
| Localization is an important way to make your application usable by the widest number of people. React Aria includes localized strings for 30+ languages, handles dates and numbers in many calendar and numbering systems, and supports right-to-left interactions (e.g. keyboard navigation). | ||
|
|
||
| You’re responsible for ensuring your design supports right-to-left layout, and adapts to different languages (e.g. using appropriate fonts). Modern CSS grid and flex layouts are automatically mirrored depending on the direction, and [logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values) can be used to adapt margins, paddings, borders, etc. | ||
|
|
||
| ### Setting the locale | ||
|
|
||
| React Aria automatically detects the user's current language by default. Use the `I18nProvider` component to set the locale to a specific value. You should also set the `lang` and `dir` attributes on the root-most element of your application. | ||
|
|
||
| ```tsx | ||
| import {I18nProvider, useLocale} from 'react-aria-components'; | ||
|
|
||
| <I18nProvider locale="fr-FR"> | ||
| <App /> | ||
| </I18nProvider> | ||
|
|
||
| function App() { | ||
| let {locale, direction} = useLocale(); | ||
|
|
||
| return ( | ||
| <html lang={locale} dir={direction}> | ||
| {/* your app here */} | ||
| </html> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ### Supported locales | ||
|
|
||
| <ul style={{columnWidth: 200, paddingLeft: 16, fontFamily: 'adobe-clean-spectrum-vf'}}> | ||
| <li>Arabic (United Arab Emirates)</li> | ||
| <li>Bulgarian (Bulgaria)</li> | ||
| <li>Chinese (Simplified)</li> | ||
| <li>Chinese (Traditional)</li> | ||
| <li>Croatian (Croatia)</li> | ||
| <li>Czech (Czech Republic)</li> | ||
| <li>Danish (Denmark)</li> | ||
| <li>Dutch (Netherlands)</li> | ||
| <li>English (Great Britain)</li> | ||
| <li>English (United States)</li> | ||
| <li>Estonian (Estonia)</li> | ||
| <li>Finnish (Finland)</li> | ||
| <li>French (Canada)</li> | ||
| <li>French (France)</li> | ||
| <li>German (Germany)</li> | ||
| <li>Greek (Greece)</li> | ||
| <li>Hebrew (Israel)</li> | ||
| <li>Hungarian (Hungary)</li> | ||
| <li>Italian (Italy)</li> | ||
| <li>Japanese (Japan)</li> | ||
| <li>Korean (Korea)</li> | ||
| <li>Latvian (Latvia)</li> | ||
| <li>Lithuanian (Lithuania)</li> | ||
| <li>Norwegian (Norway)</li> | ||
| <li>Polish (Poland)</li> | ||
| <li>Portuguese (Brazil)</li> | ||
| <li>Romanian (Romania)</li> | ||
| <li>Russian (Russia)</li> | ||
| <li>Serbian (Serbia)</li> | ||
| <li>Slovakian (Slovakia)</li> | ||
| <li>Slovenian (Slovenia)</li> | ||
| <li>Spanish (Spain)</li> | ||
| <li>Swedish (Sweden)</li> | ||
| <li>Turkish (Turkey)</li> | ||
| <li>Ukrainian (Ukraine)</li> | ||
| </ul> | ||
|
|
||
| ## Interactions | ||
|
|
||
| Modern web apps run on everything from desktops to mobile devices to TVs, with users interacting through mouse, touch, keyboard, and assistive technologies. React Aria normalizes these differences, delivering consistent “press”, “hover”, and “focus” behaviors across all browsers and input types. | ||
|
|
||
| React Aria components provide data attributes and render props to style these states: | ||
|
|
||
| * `data-pressed` – like the `:active` pseudo class, but removed when dragging off the element. | ||
| * `data-hovered` – like `:hover`, but does not apply on touch devices to avoid sticky hover states. | ||
| * `data-focus-visible` – like `:focus-visible`, but avoids false positives from programmatic focus. | ||
|
|
||
| These states also come with corresponding events such as `onPress` and `onHoverStart`. To use these events in your own custom components, see hooks such as [usePress](usePress.html), [useHover](useHover.html), [useMove](useMove.html), and [useFocusRing](useFocusRing.html). | ||
|
|
||
| Read our blog post series to learn more about the intricacies behind these interactions. | ||
|
|
||
| * [Building a Button Part 1: Press Events](https://react-spectrum.adobe.com/blog/building-a-button-part-1.html) | ||
| * [Building a Button Part 2: Hover Interactions](https://react-spectrum.adobe.com/blog/building-a-button-part-2.html) | ||
| * [Building a Button Part 3: Keyboard Focus Behavior](https://react-spectrum.adobe.com/blog/building-a-button-part-3.html) | ||
|
|
||
| Higher level interaction patterns such as [selection](selection.html) and [drag and drop](dnd.html) are also built on top of these low level primitives. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.