Skip to content

Commit 658423e

Browse files
authored
Update React Aria docs to introduce components by default (#5436)
1 parent fa2d591 commit 658423e

File tree

17 files changed

+494
-770
lines changed

17 files changed

+494
-770
lines changed

packages/@react-aria/i18n/docs/internationalization.mdx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ right-to-left mirroring and interactions.
2727

2828
Internationalization is the process of structuring your code and user interface to support localization. React Aria supports
2929
many aspects of localization for many components out of the box, including translations for builtin strings, localized
30-
date and number formatting, right-to-left interactions, and more. By using React Aria for your design system,
30+
date and number formatting, right-to-left interactions, and more. By using React Aria to build your components,
3131
these aspects of internationalization are handled for you. You can also use our hooks in your own custom components.
3232

3333
## Localization
@@ -46,7 +46,7 @@ also use our internationalization hooks in your own components. These are implem
4646
[Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) APIs under the hood, so there's no
4747
large libraries or locale data for users to download.
4848

49-
See [useMessageFormatter](useMessageFormatter.html), [useDateFormatter](useDateFormatter.html), [useNumberFormatter](useNumberFormatter.html),
49+
See [useDateFormatter](useDateFormatter.html), [useNumberFormatter](useNumberFormatter.html),
5050
and [useCollator](useCollator.html) for more information about using our internationalization hooks. The
5151
[Internationalized](../../internationalized/index.html) collection of libraries provides framework-agnostic utilities for representing
5252
and manipulating [dates and times](../../internationalized/date/index.html), and parsing and formatting
@@ -63,10 +63,9 @@ opposite side of the interface. For example, a button that would be displayed on
6363
would appear on the left side of the screen in a right-to-left language. In addition, elements within a component are also expected to
6464
mirror. For example, in a checkbox component, the label would be placed on the left side of the checkmark rather than the right.
6565

66-
Since React Aria provides no rendering, it is up to you to implement RTL support in your design. The documentation for individual react-aria hooks
67-
calls out when you need to be aware of this, so you can account for it in your CSS using
68-
[logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties) or other means. For example, flexbox and CSS grid
69-
both automatically flip their layouts depending on the direction.
66+
Since React Aria provides no styling, it is up to you to implement RTL support in your design. CSS flex and grid layouts automatically flip depending
67+
on the direction, and [logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties) are a great way to handle
68+
margins, paddings, borders, and more.
7069

7170
Even though it is not responsible for rendering or layout, React Aria is aware of the current directionality, and adjusts interactions
7271
accordingly. For example, when navigating using the left and right arrow keys, React Aria automatically flips the direction so that
@@ -76,10 +75,10 @@ the left arrow always navigates to the item physically to the left, and the righ
7675

7776
The root most element of your application should define the [lang](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
7877
and [dir](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) attributes so that the browser knows which language
79-
and direction the user interface should be rendered in. This can be done with the [useLocale](useLocale.html) hook from `@react-aria/i18n`.
78+
and direction the user interface should be rendered in. This can be done with the [useLocale](useLocale.html) hook.
8079

8180
```tsx
82-
import {useLocale} from '@react-aria/i18n';
81+
import {useLocale} from 'react-aria-components';
8382

8483
function YourApp() {
8584
let {locale, direction} = useLocale();
@@ -94,10 +93,10 @@ function YourApp() {
9493

9594
React Aria automatically detects the user's current language by default, and even updates this if the browser or system language changes.
9695
However, if you would like to override this with an application specific setting, you can do so using the [I18nProvider](I18nProvider.html)
97-
exposed by `@react-aria/i18n`.
96+
component.
9897

9998
```tsx
100-
import {I18nProvider} from '@react-aria/i18n';
99+
import {I18nProvider} from 'react-aria-components';
101100

102101
<I18nProvider locale="fr-FR">
103102
<YourApp />

packages/@react-aria/interactions/docs/interactions.mdx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ high level gesture events, or even the concept of a “press” event that works
3434
We just have low level events like mouse, touch, keyboard, and focus events, and it's up to developers to put them
3535
together properly. This leads to many web apps not working consistently across various types of devices and interaction models.
3636

37-
React Aria includes a collection of [Hooks](https://reactjs.org/docs/hooks-intro.html) that provide higher level abstractions
37+
React Aria includes a collection of [Hooks](https://react.dev/reference/react/hooks) that provide higher level abstractions
3838
over the low level events exposed by the web platform, and helps normalize the behavior across browsers and devices. This includes
3939
support for high level events like “press”, “hover”, and “focus”. Some of these seem simple at first, but you’d be surprised how
4040
complicated it is to handle these events in a cross-browser, cross-device way. There are many tiny behavioral
@@ -78,7 +78,7 @@ At a high level, keyboard navigation is broken up into **tab stops**, which may
7878
move to the next tab stop, and <Keyboard>Shift</Keyboard> + <Keyboard>Tab</Keyboard> to move to the previous tab stop. A tab stop may be an atomic
7979
component like a text field or button, or a composite component like a listbox, radio group, grid, or toolbar. Composite components
8080
behave as a single tab stop. Elements within a composite component are typically navigated with the arrow keys, while the <Keyboard>Tab</Keyboard>
81-
key continues to navigate to the next/previous tab stop. React Aria implements hooks for many of these composite components and handles
81+
key continues to navigate to the next/previous tab stop. React Aria implements many of these composite components and handles
8282
all of the keyboard navigation behavior for elements inside them.
8383

8484
Overlay elements like dialogs, popovers, and menus have additional focus behavior to ensure that focus stays within them while they
@@ -109,9 +109,7 @@ so that components receive a consistent stream of events regardless of the inter
109109
All React Aria components are tested across a wide variety of browsers and devices. We test across devices with
110110
mouse input, touchscreens, and also hybrid devices.
111111

112-
* Chrome 88+ on macOS and Windows
113-
* Firefox 85+ on macOS and Windows
114-
* Safari 13+ on macOS
115-
* Edge 88+ on Windows
116-
* Safari 13+ on iOS and iPadOS
117-
* Chrome 88+ on Android
112+
* Chrome on macOS, Windows, and Android
113+
* Firefox on macOS and Windows
114+
* Safari on macOS, iOS, and iPadOS
115+
* Edge on Windows

packages/dev/docs/pages/architecture.mdx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ and time, and reducing duplicated effort across the industry.
6161

6262
<figure className={style.float}>
6363
<Flex direction="column" gap="size-125">
64-
<View backgroundColor="magenta-600" height="size-900">
64+
<View backgroundColor="static-magenta-600" height="size-900">
6565
<Flex alignItems="center" justifyContent="center" height="100%">
6666
<span style={{color: 'white', fontSize: 18}}>Component</span>
6767
</Flex>
6868
</View>
69-
<View backgroundColor="green-600" height="size-900">
69+
<View backgroundColor="static-green-600" height="size-900">
7070
<Flex alignItems="center" justifyContent="center" height="100%">
7171
<span style={{color: 'white', fontSize: 18}}>Behavior Hook</span>
7272
</Flex>
7373
</View>
74-
<View backgroundColor="blue-500" height="size-900">
74+
<View backgroundColor="static-blue-600" height="size-900">
7575
<Flex alignItems="center" justifyContent="center" height="100%">
7676
<span style={{color: 'white', fontSize: 18}}>State Hook</span>
7777
</Flex>
@@ -89,7 +89,7 @@ other components, so each component has the pieces of this architecture
8989
that make sense for their purpose.
9090

9191
This architecture is made possible by
92-
[React Hooks](https://reactjs.org/docs/hooks-intro.html), which enable
92+
[React Hooks](https://react.dev/reference/react/hooks), which enable
9393
the ability to reuse behavior between multiple components. Hooks allow
9494
accessing React features like state and effects from functions which
9595
can be called from any component. If you're unfamiliar with hooks,
@@ -147,25 +147,30 @@ the state from the state hook to adjust its visual appearance.
147147
This allows complete control over the rendering of the component, including
148148
things like adding extra elements as needed for styling or layout control.
149149

150+
The component itself may be split into unstyled and styled parts. Unstyled components
151+
compose together hooks and abstract away the glue code necessary to connect them together
152+
by providing reusable contexts, DOM structure, and styling APIs. This simplifies design system
153+
components while retaining the flexibility to drop down to lower-level APIs when needed.
154+
150155
<div style={{clear: 'both'}} />
151156

152157
## Implementation
153158

154159
<figure className={style.float}>
155160
<Flex direction="column" gap="size-125">
156-
<View backgroundColor="magenta-600" height="size-900">
161+
<View backgroundColor="static-magenta-600" height="size-900">
157162
<Flex alignItems="center" justifyContent="center" height="100%">
158-
<span style={{color: 'white', fontSize: 18}}>@react-spectrum</span>
163+
<span style={{color: 'white', fontSize: 18}}>React Spectrum</span>
159164
</Flex>
160165
</View>
161-
<View backgroundColor="green-600" height="size-900">
166+
<View backgroundColor="static-green-600" height="size-900">
162167
<Flex alignItems="center" justifyContent="center" height="100%">
163-
<span style={{color: 'white', fontSize: 18}}>@react-aria</span>
168+
<span style={{color: 'white', fontSize: 18}}>React Aria</span>
164169
</Flex>
165170
</View>
166-
<View backgroundColor="blue-500" height="size-900">
171+
<View backgroundColor="static-blue-600" height="size-900">
167172
<Flex alignItems="center" justifyContent="center" height="100%">
168-
<span style={{color: 'white', fontSize: 18}}>@react-stately</span>
173+
<span style={{color: 'white', fontSize: 18}}>React Stately</span>
169174
</Flex>
170175
</View>
171176
</Flex>
@@ -208,20 +213,21 @@ by reading the docs.
208213
### React Aria
209214

210215
[React Aria](react-aria/index.html) implements behavior and [accessibility](react-aria/accessibility.html)
211-
for the web according to [WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.2/).
216+
for the web according to the W3C's [ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/).
212217
It includes full screen reader and keyboard navigation support, along with
213218
mouse and touch [interactions](react-aria/interactions.html) that have been
214219
tested across a wide variety of devices and browsers. It also implements
215220
[internationalization](react-aria/internationalization.html) for over 30
216221
languages, including right-to-left specific behavior, localized date and
217222
number formatting, and more.
218223

219-
Most importantly, React Aria is **fully customizable**, since it doesn't
220-
implement any rendering or impose a DOM structure or styling methodology.
221-
You just need to spread the props returned by each React Aria hook onto
222-
the appropriate DOM elements, and you get high quality interactions,
223-
behavior, and accessibility pretty much for free. All you need to do is
224-
provide the styling.
224+
Most importantly, React Aria is **fully customizable**. It offers both high-level
225+
unstyled components and low-level hooks depending on the level of customization you need.
226+
The components provide a default DOM structure and styling API, and handle all
227+
of the glue code necessary to connect the hooks together on your behalf.
228+
If you need even more control, you can drop down to the lower-level hook-based API,
229+
which enables [advanced customization](react-aria/advanced.html) use cases such
230+
as overriding DOM elements, intercepting events, customizing behavior, and more.
225231

226232
[Read more](react-aria/why.html) about React Aria and
227233
the problems it solves, and check out the docs to [get started](react-aria/getting-started.html)

packages/dev/docs/pages/react-aria/accessibility.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ with built-in semantics (e.g. `<button>` or `<select>`) for styling reasons, or
4646
ARIA is required to make presentational elements (e.g. `<div>`) have semantic meaning. This allows screen readers and
4747
other assistive technology to understand these elements and announce them properly to the user.
4848

49-
However, ARIA is a contract: it only specifies semantics, and it's up to the developer to implement the
50-
**behavior** and interactions for each control with JavaScript. There is an additional document published by the W3C
51-
called the [WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.2/), which provides patterns
49+
However, ARIA only specifies semantics, and it's up to the developer to implement the
50+
**behavior** and interactions for each control with JavaScript. The W3C also publishes
51+
the [ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/), which provides patterns
5252
and examples of implementing this behavior on top of ARIA. It specifies keyboard interactions that are expected
5353
by users of these controls, along with the required roles and states to make them accessible to assistive technology.
5454

55-
React Aria provides hooks for many ARIA patterns, which provide the semantics and behavior together. This makes building
56-
accessible components with custom styling much easier: just spread the props returned by the hooks onto the appropriate
57-
elements and you get accessibility and behavior pretty much for free. All you need to do is provide the styling.
55+
React Aria provides implementations of ARIA patterns as unstyled React components and hooks, which include both the
56+
semantics and behavior out of the box. This makes building accessible components with custom styling much easier, because
57+
you only need to implement your custom styles and get the accessibility and behavior for free.
5858

5959
## Labeling
6060

@@ -66,13 +66,13 @@ will automatically associate the visible label with the control so that assistiv
6666

6767
In case a visible label is not desired for some reason, or you're using a control that doesn't have a built-in label,
6868
you must use the `aria-label` or `aria-labelledby` props to identify it to assistive technology. Most React Aria
69-
hooks will display a console warning if you are missing both a visible label and an ARIA label.
69+
components will display a console warning if you are missing both a visible label and an ARIA label.
7070

7171
## Keyboard navigation
7272

7373
React Aria implements keyboard support for all components, which allows users who cannot use a mouse or touch screen
7474
to navigate your app. It also allows power users to navigate your application more quickly, without lifting their hands
75-
from the keyboard. All keyboard behavior is implemented according to the [WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.2/) guidelines,
75+
from the keyboard. All keyboard behavior is implemented according to the W3C's [ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/),
7676
and is designed to feel familiar to users of most commonly used desktop operating systems.
7777

7878
For more information about keyboard navigation and focus interactions, see the [interactions](interactions.html) overview.

packages/dev/docs/pages/react-aria/forms.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import {Layout} from '@react-spectrum/docs';
1414
export default Layout;
1515

1616
```css hidden
17+
@import '@react-aria/example-theme';
1718
@import 'react-aria-components/docs/TextField.mdx';
1819
@import 'react-aria-components/docs/Button.mdx';
1920
```
2021

2122
---
22-
category: Concepts
23+
category: Guides
2324
keywords: [forms, validation, frameworks, aria, next.js, remix, react server actions]
24-
order: 6
25+
order: 1
2526
---
2627

2728
# Forms

0 commit comments

Comments
 (0)