By default, the navigation is performed with a native <a>
element. You can customize it to use your own router. For instance, using Next.js's Link or react-router.
true
, the touch ripple effect is disabled.",
"focusRipple": "If true
, the base button will have a keyboard focus ripple.",
"focusVisibleClassName": "This prop can help identify which element has keyboard focus. The class name will be applied when the element gains the focus through keyboard interaction. It's a polyfill for the CSS :focus-visible selector. The rationale for using this feature is explained here. A polyfill can be used to apply a focus-visible
class to other components if needed.",
+ "LinkComponent": "The component used to render a link when the href
prop is provided.",
"onFocusVisible": "Callback fired when the component is focused with a keyboard. We trigger a onFocus
callback too.",
"sx": "The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details.",
"TouchRippleProps": "Props applied to the TouchRipple
element."
diff --git a/docs/translations/translations.json b/docs/translations/translations.json
index ae30e831946f55..5786d09d6cea6c 100644
--- a/docs/translations/translations.json
+++ b/docs/translations/translations.json
@@ -296,6 +296,7 @@
"/guides/interoperability": "Style Library Interoperability",
"/guides/minimizing-bundle-size": "Minimizing Bundle Size",
"/guides/composition": "Composition",
+ "/guides/routing": "Routing",
"/guides/server-rendering": "Server Rendering",
"/guides/responsive-ui": "Responsive UI",
"/guides/pickers-migration": "Migration from @material-ui/pickers",
diff --git a/examples/nextjs-with-typescript/README.md b/examples/nextjs-with-typescript/README.md
index 6731bfecd5de1f..d3aed748a67626 100644
--- a/examples/nextjs-with-typescript/README.md
+++ b/examples/nextjs-with-typescript/README.md
@@ -27,47 +27,5 @@ The project uses [Next.js](https://github.com/zeit/next.js), which is a framewor
## The link component
Next.js has [a custom Link component](https://nextjs.org/docs/api-reference/next/link).
-The example provides adapters for usage with Material-UI.
-
-- The first version of the adapter is the `NextLinkComposed` component.
- This component is unstyled and only responsible for handling the navigation.
- The prop `href` was renamed `to`.
-
- ```tsx
- import Button from '@material-ui/core/Button';
- import { NextLinkComposed } from '../src/Link';
-
- export default function Index() {
- return (
-
- );
- }
- ```
-
-- The second version of the adapter is the `Link` component.
- This component is styled, it leverages the [link component of Material-UI](https://material-ui.com/components/links/) with `NextLinkComposed`.
-
- ```tsx
- import Link from '../src/Link';
-
- export default function Index() {
- return (
-
- Link
-
- );
- }
- ```
+The example folder provides adapters for usage with Material-UI.
+More information [in the documentation](https://next.material-ui.com/guides/routing/#next-js).
diff --git a/examples/nextjs/README.md b/examples/nextjs/README.md
index bbf95025ae26db..d03e247066f495 100644
--- a/examples/nextjs/README.md
+++ b/examples/nextjs/README.md
@@ -27,47 +27,5 @@ The project uses [Next.js](https://github.com/zeit/next.js), which is a framewor
## The link component
Next.js has [a custom Link component](https://nextjs.org/docs/api-reference/next/link).
-The example provides adapters for usage with Material-UI.
-
-- The first version of the adapter is the `NextLinkComposed` component.
- This component is unstyled and only responsible for handling the navigation.
- The prop `href` was renamed `to`.
-
- ```tsx
- import Button from '@material-ui/core/Button';
- import { NextLinkComposed } from '../src/Link';
-
- export default function Index() {
- return (
-
- );
- }
- ```
-
-- The second version of the adapter is the `Link` component.
- This component is styled, it leverages the [link component of Material-UI](https://material-ui.com/components/links/) with `NextLinkComposed`.
-
- ```tsx
- import Link from '../src/Link';
-
- export default function Index() {
- return (
-
- Link
-
- );
- }
- ```
+The example folder provides adapters for usage with Material-UI.
+More information [in the documentation](https://next.material-ui.com/guides/routing/#next-js).
diff --git a/packages/material-ui/src/ButtonBase/ButtonBase.d.ts b/packages/material-ui/src/ButtonBase/ButtonBase.d.ts
index 0f50cee128f328..e0c6fecb2ef8d8 100644
--- a/packages/material-ui/src/ButtonBase/ButtonBase.d.ts
+++ b/packages/material-ui/src/ButtonBase/ButtonBase.d.ts
@@ -71,6 +71,11 @@ export interface ButtonBaseTypeMap', () => {
expect(button).to.have.attribute('href', 'https://google.com');
});
+ it('should use custom LinkComponent when provided in the theme', () => {
+ const CustomLink = React.forwardRef((props, ref) => {
+ return (
+
+ {props.children}
+
+ );
+ });
+ const theme = createMuiTheme({
+ components: {
+ MuiButtonBase: {
+ defaultProps: {
+ LinkComponent: CustomLink,
+ },
+ },
+ },
+ });
+
+ const { container, getByTestId } = render(
+