Skip to content

Commit ea00033

Browse files
authored
chore: add docs for actionbutton pending (#8912)
1 parent 2ac8194 commit ea00033

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

packages/dev/s2-docs/pages/s2/ActionBar.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let rows = [
2525

2626
function Example(props) {
2727
return (
28-
<TableView
28+
<TableView
2929
aria-label="Table with action bar"
3030
selectionMode="multiple"
3131
defaultSelectedKeys={[2]}

packages/dev/s2-docs/pages/s2/ActionButton.mdx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import docs from 'docs:@react-spectrum/s2';
1111
<VisualExample
1212
component={ActionButton}
1313
docs={docs.exports.ActionButton}
14-
props={['children', 'size', 'staticColor', 'isQuiet', 'isDisabled']}
14+
props={['children', 'size', 'staticColor', 'isQuiet', 'isDisabled', 'isPending']}
1515
initialProps={{children: 'Action'}}
1616
slots={{icon: true, avatar: true, badge: true}}
1717
importSource="@react-spectrum/s2"
@@ -39,6 +39,36 @@ function Example() {
3939
}
4040
```
4141

42+
## Pending
43+
44+
Use the `isPending` prop to display a pending state. Pending buttons remain focusable, but are otherwise disabled. After a 1 second delay, an indeterminate spinner will be displayed in place of the button label and icon.
45+
46+
```tsx render
47+
"use client";
48+
import {ActionButton} from '@react-spectrum/s2';
49+
import {useState} from 'react';
50+
51+
function PendingButton() {
52+
let [isPending, setPending] = useState(false);
53+
54+
return (
55+
<ActionButton
56+
variant="primary"
57+
///- begin highlight -///
58+
isPending={isPending}
59+
///- end highlight -///
60+
onPress={() => {
61+
setPending(true);
62+
setTimeout(() => {
63+
setPending(false);
64+
}, 5000);
65+
}}>
66+
Save
67+
</ActionButton>
68+
);
69+
}
70+
```
71+
4272
## API
4373

4474
```tsx links={{ActionButton: '#actionbutton', Avatar: 'Avatar.html'}}

0 commit comments

Comments
 (0)