Skip to content
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

Adds basic documentation for the ToolbarButton component. #23909

Merged
merged 8 commits into from
Jul 14, 2020
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,12 @@
"markdown_source": "../packages/components/src/toggle-control/README.md",
"parent": "components"
},
{
"title": "ToolbarButton",
"slug": "toolbar-button",
"markdown_source": "../packages/components/src/toolbar-button/README.md",
"parent": "components"
},
{
"title": "Toolbar",
"slug": "toolbar",
Expand Down
26 changes: 26 additions & 0 deletions packages/components/src/toolbar-button/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ToolbarButton

A ToolbarButton can be used to add actions to your block control, usually inside a ToolbarGroup. It has similar features to the [Button](/packages/components/src/button/README.md) component. Using `ToolbarButton` will ensure the correct styling for a button in a toolbar, and also that keyboard interactions in a toolbar are consistent with the [WAI ARIA toolbar pattern](https://www.w3.org/TR/wai-aria-practices/#toolbar).

## Usage

```jsx
import { ToolbarButton } from "@wordpress/components";
import { edit } from "@wordpress/icons";

const MyToolbarButton = () => (
<MyToolbarButton
title="Edit"
icon={ edit }
onClick={ onEdit } />
);
```

## Props

This component accepts [the same API of the Button](/packages/components/src/button/README.md#props) component.

## Related components

* If you wish to implement a control to select options grouped as icon buttons you can use the [Toolbar](/packages/components/src/toolbar/README.md) component, which already handles this strategy.
* The ToolbarButton may be used with other elements such as [Dropdown](/packages/components/src/dropdown/README.md) to display options in a popover.