Link
The link serves as a navigational element. It provides a clickable area with styled text and an optional icon, allowing users to access different pages, sections, or external resources within the application.
Basic
Source Code
import { ArrowLaunchOutline } from '@ocean-network-express/magenta-ui/icons';
import { Link } from '@ocean-network-express/magenta-ui/react';
export function LinkBasic() {
return (
<div className="flex gap-x-24">
<Link href="#basic">Basic Link</Link>
<Link href="#basic">
Link with Icon
<ArrowLaunchOutline size={'sm'} style={{ marginLeft: '8px' }} />
</Link>Color
-
Link supports 2 colors
secondaryandredand can be changed by passing thecolorprop. -
Default color is
secondary.Source Code
import { Link } from '@ocean-network-express/magenta-ui/react'; import React from 'react'; export function Color() { return ( <div className="flex gap-x-24"> <Link color="secondary" href="#"> Secondary Link (default) </Link> <Link color="red" href="#"> Red Link
Sizes
- Link supports 4 sizes
sm,md,lgandresponsiveand can be changed by passing thesizeprop. - Default size is
responsive.
Source Code
import { Link } from '@ocean-network-express/magenta-ui/react';
export function LinkSizes() {
return (
<div className="flex gap-x-24">
<Link href="#sizes" size="sm">
Link size sm
</Link>
<Link href="#sizes" size="md">
Link size md
</Link>
<Link href="#sizes" size="lg">- With size
responsive, the component will be responsive to the viewport.
Screen prefix | Screen width | Component size |
|---|---|---|
xs → xl | 0px → 1279px | sm |
xl → 3xl | 1280px → 1919px | md |
3xl → ∞ | 1920px → ∞ | lg |
Source Code
import { Link } from '@ocean-network-express/magenta-ui/react';
export function LinkSizeResponsive() {
return <Link href="#sizes">Responsive Link</Link>;
}
Underline
- The
underlineprop can be used to set the underline behavior. The default isalways.
Source Code
import { Link } from '@ocean-network-express/magenta-ui/react';
export function LinkUnderline() {
return (
<div className="flex gap-x-24">
<Link href="#underline" underline="always">
underline-always
</Link>
<Link href="#underline" underline="hover">
underline-hover
</Link>Security
- When you use
target="_blank"with Links, it is recommended to always setrel="noopener"orrel="noreferrer"when linking to third party contentrel="noopener"prevents the new page from being able to access thewindow.openerproperty and ensures it runs in a separate process. Without this, the target page can potentially redirect your page to a malicious URL.rel="noreferrer"has the same effect, but also prevents the Referer header from being sent to the new page. ⚠️ Removing the referrer header will affect analytics.
- Read more about
relhere
Source Code
import { Link } from '@ocean-network-express/magenta-ui/react';
export function LinkSecurity() {
return (
<div className="flex gap-x-24">
<Link href="#security" rel="noopener" target="_blank">
Link noopener
</Link>
<Link href="#security" rel="noreferrer" target="_blank">
Link noreferrer
</Link>
</div>Downloadable
- The
downloadprop can be used to set the downloadable Link.
Source Code
import { Link } from '@ocean-network-express/magenta-ui/react';
export function LinkDownloadable() {
return (
<Link href="#downloadable" download>
Downloadable
</Link>
);
}
Target
- Link supports 4 target as
aHTML tag :_self,_blank,_parentand_top. - Default target is
_self.
Source Code
import { Link } from '@ocean-network-express/magenta-ui/react';
export function LinkTarget() {
return (
<div className="flex gap-x-24">
<Link href="#target" target="_self">
Link self
</Link>
<Link href="#target" target="_blank">
Link blank
</Link>
<Link href="#target" target="_parent">Disabled
- The
disabledprop can be used to set the Disabled Link.
Source Code
import { Link } from '@ocean-network-express/magenta-ui/react';
export function LinkDisabled() {
return (
<Link href="#disabled" disabled>
Disabled
</Link>
);
}
Was this page helpful?
Anchor
Hyperlink
Link - Examples