-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Migrate button demos to base (#31395)
- Loading branch information
1 parent
fa03dbd
commit 40be8b4
Showing
47 changed files
with
99 additions
and
257 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 |
---|---|---|
@@ -1,17 +1,49 @@ | ||
--- | ||
product: base | ||
title: React button unstyled | ||
title: Unstyled React button | ||
components: ButtonUnstyled | ||
githubLabel: 'component: button' | ||
waiAria: https://www.w3.org/TR/wai-aria-practices/#button | ||
--- | ||
|
||
# Button unstyled | ||
# Unstyled button | ||
|
||
<p class="description">Buttons allow users to take actions, and make choices, with a single tap.</p> | ||
<p class="description">Buttons allow users to take actions and make choices with a single tap.</p> | ||
|
||
## Basic usage | ||
|
||
```js | ||
import ButtonUnstyled from '@mui/base/ButtonUnstyled'; | ||
``` | ||
|
||
{{"demo": "UnstyledButtonsSimple.js"}} | ||
|
||
## Customizing the root element | ||
|
||
By default, the `ButtonUnstyled` component renders a native `button` HTML element. | ||
You can override this by setting the `component` or `components.Root` prop. | ||
If you provide a non-interactive element, such as a `span`, the `ButtonUnstyled` component will automatically add the necessary accessibility attributes. | ||
|
||
{{"demo": "UnstyledButtonsSpan.js"}} | ||
|
||
Compare the attributes on the `span` with the `button` from the previous demo. | ||
|
||
## Complex customization | ||
|
||
## `useButton` hook | ||
In addition to HTML elements, you can also use SVGs with the `ButtonUnstyled` component. | ||
|
||
{{"demo": "UnstyledButtonCustom.js"}} | ||
|
||
## useButton hook | ||
|
||
```js | ||
import { useButton } from '@mui/base/ButtonUnstyled'; | ||
``` | ||
|
||
The `useButton` hook lets you use the functionality of `ButtonUnstyled` in other components. | ||
It returns props to be placed on a custom button element, along with fields representing the internal state of the button. | ||
|
||
The `useButton` hook requires the `ref` of the element it's used on. | ||
Additionally, you need to provide the `component` prop (unless you intend to use the plain `button`). | ||
|
||
{{"demo": "UseButton.js"}} |
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.