Links
Navigate with native semantic anchors and theme-aware underline styling.
This guide covers Material UI Core with the default Emotion engine; extensions and additional demos are explicitly classified.
Use case and business boundary
Navigation links require real destinations; buttons are for actions and framework routing needs a compatible adapter.
Native composition and scope
Link
Preserve native Material UI composition and types; do not substitute JGuang UI/Base UI/Radix APIs. Example entries are not extra components.
Native installation and initialization
npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1
Use native npm and Emotion, not an invented JGuang UI Registry URL. Place examples inside native ThemeProvider; choose CssBaseline or ScopedCssBaseline for the project. Inspect React, existing providers, lockfile and SSR first. Never overwrite files or conceal peer conflicts. This batch verified React 19.2.8; React 18 and below require matching react-is. See the included bilingual setup guide.
Practical native parameters
These selected parameters are not a flattened universal API. Preserve the native declaring owner, slot structure, nullable values and generics.
| Owner.prop | Practical role | Declaration source |
|---|---|---|
Link.href | Real anchor destination; actions should use button semantics. | React.AnchorHTMLAttributes |
Link.underline | Native Link underline policy: always, hover or none. | Link |
Link.component | Rendered native element/component type; preserve valid semantics and refs. | Link |
Runnable native examples
Machine keys select example entries, not universal variant props. Native demo JSX/data stay unchanged; JGuang-authored acceptance fixtures are explicitly labelled.
- Basic links ·
Links· upstream native demo - Underline ·
UnderlineLink· upstream native demo - Accessibility ·
ButtonLink· upstream native demo
Actual usage example
Unmodified pinned native demo; copy its required local helper files together.
import * as React from 'react';
import Box from '@mui/material/Box';
import Link from '@mui/material/Link';
const preventDefault = (event: React.SyntheticEvent) => event.preventDefault();
export default function Links() {
return (
<Box
sx={{
typography: 'body1',
'& > :not(style) ~ :not(style)': {
ml: 2,
},
}}
onClick={preventDefault}
>
<Link href="#">Link</Link>
<Link href="#" color="inherit">
{'color="inherit"'}
</Link>
<Link href="#" variant="body2">
{'variant="body2"'}
</Link>
</Box>
);
}
Example dependency boundaries
react, @mui/material/Box, @mui/material/Link
Direct Icons/System/Utils example imports require their matching 9.4.0 packages. Relative data/helpers are part of the example closure, not extra components. Remote images and simulated operations do not supply a backend.
Pinned upstream API metadata reference
These tables retain the upstream metadata, not a newly inferred generic type system. Conditional generics, inherited props and callback details are defined by the source declarations below. Theme defaults may override metadata defaults.
Link
import Link from '@mui/material/Link';
import { Link } from '@mui/material';
Native inheritance: Typography. Parent/DOM props are not fabricated as additional own props.
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
children | no | node | — |
classes | no | object | — |
color | no | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning' | 'textPrimary' | 'textSecondary' | 'textDisabled' | string | 'primary' |
component | no | element type | — |
sx | no | Array<func | object | bool> | func | object | — |
TypographyClasses | no | object | — |
underline | no | 'always' | 'hover' | 'none' | 'always' |
variant | no | 'body1' | 'body2' | 'button' | 'caption' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'inherit' | 'overline' | 'subtitle1' | 'subtitle2' | string | 'inherit' |
Native source declarations
Declarations/imports are extracted from pinned source without flattening unions or external inheritance. Original English comments/types are source reference, not a claim of translated upstream prose. Shared types stay in their native packages.
vendor/src/Link/Link.d.ts
import * as React from 'react';
import { DistributiveOmit } from '@mui/types';
import { SxProps } from '@mui/system';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { Theme } from '../styles';
import { TypographyOwnProps } from '../Typography';
import { LinkClasses } from './linkClasses';
export interface LinkOwnProps extends DistributiveOmit<LinkBaseProps, 'classes'> {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<LinkClasses> | undefined;
/**
* The color of the link.
* @default 'primary'
*/
color?: TypographyOwnProps['color'] | 'inherit' | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* `classes` prop applied to the [`Typography`](https://mui.com/material-ui/api/typography/) element.
*/
TypographyClasses?: TypographyOwnProps['classes'] | undefined;
/**
* Controls when the link should have an underline.
* @default 'always'
*/
underline?: 'none' | 'hover' | 'always' | undefined;
/**
* Applies the theme typography styles.
* @default 'inherit'
*/
variant?: TypographyOwnProps['variant'] | undefined;
}
export interface LinkTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'a'> {
props: AdditionalProps & LinkOwnProps;
defaultComponent: RootComponent;
}
declare const Link: OverridableComponent<LinkTypeMap>;
export type LinkBaseProps = DistributiveOmit<
TypographyOwnProps,
'children' | 'color' | 'variant' | 'classes'
>;
export type LinkProps<
RootComponent extends React.ElementType = LinkTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<LinkTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
Post-install acceptance
Run strict types, production build and real interactions. Check keyboard labels/focus, disabled/error/read-only semantics where natively supported, both themes, narrow screens and reduced motion. Verify callbacks against the real host data; do not declare installation complete from copying a prompt. Initialization fixtures also require server HTML and warning-free hydration.
Source and license
https://github.com/mui/material-ui/tree/809a7717b4c050ba3f69b75300689f07c050a16e
MIT · @mui/material@9.4.0. Vendor originals and license are preserved. Full original upstream prose remains in vendor/docs and is not represented as fully translated.