Skip to content

Commit a31337f

Browse files
committed
Use <Keyboard> and <SlotProvider> to get kbd styles
1 parent 7caa267 commit a31337f

File tree

26 files changed

+81
-53
lines changed

26 files changed

+81
-53
lines changed

packages/@react-aria/breadcrumbs/docs/useBreadcrumbs.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default Layout;
1212

1313
import docs from 'docs:@react-aria/breadcrumbs';
1414
import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType} from '@react-spectrum/docs';
15+
import {Keyboard} from '@react-spectrum/text';
1516
import packageData from '@react-aria/breadcrumbs/package.json';
1617
import Anatomy from './anatomy.svg';
1718

@@ -58,7 +59,7 @@ Breadcrumbs provide a list of links to parent pages of the current page in hiera
5859
Breadcrumbs consist of a navigation landmark element and a list of links, typically with a visual separator
5960
icon between each item. The last link represents the current page in the hierarchy, with the previous links representing the
6061
parent pages of the current page. Each of these parent links can be clicked, tapped, or
61-
triggered via the <kbd>Enter</kbd> key to navigate to that page. Optionally, breadcrumbs can be used
62+
triggered via the <Keyboard>Enter</Keyboard> key to navigate to that page. Optionally, breadcrumbs can be used
6263
in place of a page title, in which case the last breadcrumb acts as a heading.
6364

6465
`useBreadcrumbs` returns props to be spread onto the navigation element:

packages/@react-aria/button/docs/useButton.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default Layout;
1212

1313
import docs from 'docs:@react-aria/button';
1414
import {HeaderInfo, FunctionAPI} from '@react-spectrum/docs';
15+
import {Keyboard} from '@react-spectrum/text';
1516
import packageData from '@react-aria/button/package.json';
1617

1718
```jsx import
@@ -49,13 +50,13 @@ cross browser inconsistencies in interactions and accessibility features to cons
4950
* `<a>` and custom element type support via ARIA
5051
* Mouse and touch event handling, and press state management
5152
* Keyboard focus management and cross browser normalization
52-
* Keyboard event support for <kbd>Space</kbd> and <kbd>Enter</kbd> keys
53+
* Keyboard event support for <Keyboard>Space</Keyboard> and <Keyboard>Enter</Keyboard> keys
5354

5455
## Anatomy
5556

5657
Buttons consist of a clickable area usually containing a textual label or an icon
5758
that users can click to perform an action. In addition, keyboard users may activate
58-
buttons using the <kbd>Space</kbd> or <kbd>Enter</kbd> keys.
59+
buttons using the <Keyboard>Space</Keyboard> or <Keyboard>Enter</Keyboard> keys.
5960

6061
If a visual label is not provided (e.g. an icon only button), then an `aria-label` or
6162
`aria-labelledby` prop must be passed to identify the button to assistive technology.

packages/@react-aria/button/docs/useToggleButton.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default Layout;
1313
import docs from 'docs:@react-aria/button';
1414
import statelyDocs from 'docs:@react-stately/toggle';
1515
import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink} from '@react-spectrum/docs';
16+
import {Keyboard} from '@react-spectrum/text';
1617
import packageData from '@react-aria/button/package.json';
1718

1819
```jsx import
@@ -50,13 +51,13 @@ represents a toggle button, so React Aria implements it using ARIA attributes.
5051
* Exposed as a toggle button via ARIA
5152
* Mouse and touch event handling, and press state management
5253
* Keyboard focus management and cross browser normalization
53-
* Keyboard event support for <kbd>Space</kbd> and <kbd>Enter</kbd> keys
54+
* Keyboard event support for <Keyboard>Space</Keyboard> and <Keyboard>Enter</Keyboard> keys
5455

5556
## Anatomy
5657

5758
Toggle buttons consist of a clickable area usually containing a textual label or an icon
5859
that users can click to toggle a selection state. In addition, keyboard users may toggle
59-
the state using the <kbd>Space</kbd> or <kbd>Enter</kbd> keys.
60+
the state using the <Keyboard>Space</Keyboard> or <Keyboard>Enter</Keyboard> keys.
6061

6162
`useToggleButton` returns props to be spread onto the button element, along with a boolean indicating
6263
whether the user is currently pressing the button:

packages/@react-aria/checkbox/docs/useCheckbox.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import hiddenDocs from 'docs:@react-aria/visually-hidden';
1515
import focusDocs from 'docs:@react-aria/focus';
1616
import statelyDocs from 'docs:@react-stately/toggle';
1717
import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink} from '@react-spectrum/docs';
18+
import {Keyboard} from '@react-spectrum/text';
1819
import packageData from '@react-aria/checkbox/package.json';
1920
import Anatomy from './checkbox-anatomy.svg';
2021

@@ -61,7 +62,7 @@ that can be styled as needed.
6162

6263
A checkbox consists of a visual selection indicator and a label. Checkboxes support three
6364
selection states: checked, unchecked, and indeterminate. Users may click or touch a checkbox
64-
to toggle the selection state, or use the <kbd>Tab</kbd> key to navigate to it and the <kbd>Space</kbd> key to toggle it.
65+
to toggle the selection state, or use the <Keyboard>Tab</Keyboard> key to navigate to it and the <Keyboard>Space</Keyboard> key to toggle it.
6566

6667
`useCheckbox` returns props to be spread onto its input element:
6768

packages/@react-aria/checkbox/docs/useCheckboxGroup.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import hiddenDocs from 'docs:@react-aria/visually-hidden';
1515
import focusDocs from 'docs:@react-aria/focus';
1616
import statelyDocs from 'docs:@react-stately/checkbox';
1717
import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink} from '@react-spectrum/docs';
18+
import {Keyboard} from '@react-spectrum/text';
1819
import packageData from '@react-aria/checkbox/package.json';
1920
import Anatomy from './checkboxgroup-anatomy.svg';
2021

@@ -66,8 +67,8 @@ checkbox groups that can be styled as needed.
6667
A checkbox group consists of a set of checkboxes, and a label. Each checkbox
6768
includes a label and a visual selection indicator. Zero or more checkboxes
6869
within the group can be selected at a time. Users may click or touch a checkbox
69-
to select it, or use the <kbd>Tab</kbd> key to navigate to it
70-
and the <kbd>Space</kbd> key to toggle it.
70+
to select it, or use the <Keyboard>Tab</Keyboard> key to navigate to it
71+
and the <Keyboard>Space</Keyboard> key to toggle it.
7172

7273
`useCheckboxGroup` returns props for the group and its label, which you should spread
7374
onto the appropriate element:

packages/@react-aria/dialog/docs/useDialog.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import docs from 'docs:@react-aria/dialog';
1414
import overlaysDocs from 'docs:@react-aria/overlays';
1515
import focusDocs from 'docs:@react-aria/focus';
1616
import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink} from '@react-spectrum/docs';
17+
import {Keyboard} from '@react-spectrum/text';
1718
import packageData from '@react-aria/dialog/package.json';
1819
import Anatomy from './anatomy.svg';
1920

@@ -51,7 +52,7 @@ helps achieve accessible dialogs that can be styled as needed.
5152
* Contains focus inside the dialog when combined with &lt;<TypeLink links={focusDocs.links} type={focusDocs.exports.FocusScope} />&gt;
5253
* Hides content behind the dialog from screen readers when combined with <TypeLink links={overlaysDocs.links} type={overlaysDocs.exports.useModal} />
5354
* Prevents scrolling the page behind the dialog when combined with <TypeLink links={overlaysDocs.links} type={overlaysDocs.exports.usePreventScroll} />
54-
* Handles closing the dialog when interacting outside and pressing the <kbd>Escape</kbd> key, when combined with <TypeLink links={overlaysDocs.links} type={overlaysDocs.exports.useOverlay} />
55+
* Handles closing the dialog when interacting outside and pressing the <Keyboard>Escape</Keyboard> key, when combined with <TypeLink links={overlaysDocs.links} type={overlaysDocs.exports.useOverlay} />
5556

5657
## Anatomy
5758

@@ -81,7 +82,7 @@ and hides content outside the dialog
8182
with <TypeLink links={overlaysDocs.links} type={overlaysDocs.exports.useModal} />.
8283

8384
The modal can be closed by clicking or interacting outside the dialog if the `isDismissable`
84-
prop is set to true, or by pressing the <kbd>Escape</kbd> key.
85+
prop is set to true, or by pressing the <Keyboard>Escape</Keyboard> key.
8586
This is handled by <TypeLink links={overlaysDocs.links} type={overlaysDocs.exports.useOverlay} />.
8687

8788
Focus is contained within the dialog while it is open using a

packages/@react-aria/focus/docs/FocusScope.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default Layout;
1212

1313
import docs from 'docs:@react-aria/focus';
1414
import {HeaderInfo, PropTable, FunctionAPI, TypeLink, ClassAPI} from '@react-spectrum/docs';
15+
import {Keyboard} from '@react-spectrum/text';
1516
import packageData from '@react-aria/focus/package.json';
1617

1718
```tsx import
@@ -61,7 +62,7 @@ from a component within the FocusScope. A focus manager supports the following m
6162

6263
A basic example of a focus scope that contains focus within it is below. Clicking the "Open"
6364
button mounts a FocusScope, which auto focuses the first input inside it. Once open, you can
64-
press the <kbd>Tab</kbd> key to move within the scope, but focus is contained inside. Clicking the "Close"
65+
press the <Keyboard>Tab</Keyboard> key to move within the scope, but focus is contained inside. Clicking the "Close"
6566
button unmounts the focus scope, which restores focus back to the button.
6667

6768
For a full example of building a modal dialog, see [useDialog](useDialog.html).

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {Layout} from '@react-spectrum/docs';
1111
export default Layout;
1212

1313
import {HeaderInfo, PropTable, TypeLink} from '@react-spectrum/docs';
14+
import {Keyboard} from '@react-spectrum/text';
1415

1516
---
1617
category: Concepts
@@ -73,10 +74,10 @@ Keyboard and focus support is important to allow users to navigate your app with
7374
who are unable to physically use a mouse or touch screen, but also nice for power users who may find it faster to navigate
7475
parts of your app without lifting their hands from the keyboard.
7576

76-
At a high level, keyboard navigation is broken up into **tab stops**, which may be navigated by pressing the <kbd>Tab</kbd> key to
77-
move to the next tab stop, and <kbd>Shift</kbd> + <kbd>Tab</kbd> to move to the previous tab stop. A tab stop may be an atomic
77+
At a high level, keyboard navigation is broken up into **tab stops**, which may be navigated by pressing the <Keyboard>Tab</Keyboard> key to
78+
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
7879
component like a text field or button, or a composite component like a listbox, radio group, grid, or toolbar. Composite components
79-
behave as a single tab stop. Elements within a composite component are typically navigated with the arrow keys, while the <kbd>Tab</kbd>
80+
behave as a single tab stop. Elements within a composite component are typically navigated with the arrow keys, while the <Keyboard>Tab</Keyboard>
8081
key continues to navigate to the next/previous tab stop. React Aria implements hooks for many of these composite components and handles
8182
all of the keyboard navigation behavior for elements inside them.
8283

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default Layout;
1313
import docs from 'docs:@react-aria/interactions';
1414
import typesDocs from 'docs:@react-types/shared/src/events.d.ts';
1515
import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink} from '@react-spectrum/docs';
16+
import {Keyboard} from '@react-spectrum/text';
1617
import packageData from '@react-aria/interactions/package.json';
1718

1819
```jsx import
@@ -44,7 +45,7 @@ start again if the pointer re-enters the target. `usePress` returns the current
4445
the visual appearance of the target. If the pointer is released over the target, then an `onPress` event is fired.
4546

4647
* Handles mouse and touch events
47-
* Handles <kbd>Enter</kbd> or <kbd>Space</kbd> key presses
48+
* Handles <Keyboard>Enter</Keyboard> or <Keyboard>Space</Keyboard> key presses
4849
* Handles screen reader virtual clicks
4950
* Uses pointer events where available, with fallbacks to mouse and touch events
5051
* Normalizes focus behavior on mouse and touch interactions across browsers
@@ -80,7 +81,7 @@ type of event that triggered the interaction.
8081
This example shows a simple target that handles press events with `usePress` and logs them to a list below.
8182
It also uses the `isPressed` state to adjust the background color when the target is pressed.
8283
Press down on the target and drag your pointer off and over to see when the events are fired, and try focusing
83-
the target with a keyboard and pressing the <kbd>Enter</kbd> or <kbd>Space</kbd> keys to trigger events as well.
84+
the target with a keyboard and pressing the <Keyboard>Enter</Keyboard> or <Keyboard>Space</Keyboard> keys to trigger events as well.
8485

8586
**NOTE: for more advanced button functionality, see [useButton](useButton.html).**
8687

packages/@react-aria/link/docs/useLink.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default Layout;
1212

1313
import docs from 'docs:@react-aria/link';
1414
import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType} from '@react-spectrum/docs';
15+
import {Keyboard} from '@react-spectrum/text';
1516
import packageData from '@react-aria/link/package.json';
1617

1718
```jsx import
@@ -53,7 +54,7 @@ handled client side with JavaScript instead, it will not be exposed to assistive
5354

5455
A link consists of a pressable area usually containing a textual label or an icon
5556
that users can click or tap to navigate to another page or resource. In addition,
56-
keyboard users may activate links using the <kbd>Enter</kbd> key.
57+
keyboard users may activate links using the <Keyboard>Enter</Keyboard> key.
5758

5859
`useLink` returns props to be spread onto the link element:
5960

0 commit comments

Comments
 (0)