Import
Copy code
import { Anchor } from '@k8ordo/ui';Usage
Copy code
<Anchor href="https://example.com" openInNewTab>
External Link
</Anchor>Opening in a new tab
Copy code
<Anchor href="#">
Same Tab Link
</Anchor>
<Anchor href="https://example.com" openInNewTab>
New Tab Link
</Anchor>Replacing the element
To swap in a framework link such as Next.js’s Link, pass renderAnchor. Spread the props it receives onto the replacement element, after taking out kind. It says whether the link is internal or external, and it is not an attribute.
Copy code
// Swap in the Next.js Link
import Link from 'next/link';
<Anchor
href="/about"
renderAnchor={({ children, ...rest }) => (
<Link {...rest}>{children}</Link>
)}
>
About
</Anchor>Props
children- Type:
ReactNode - Default: -
href- Type:
T - Default: -
openInNewTab?- Type:
boolean - Default:
false renderAnchor?- Type:
(props: RenderAnchorProps<T>) => ReactNode - Default:
defaultRenderAnchor
| Prop | Type | Default |
|---|---|---|
children | ReactNode | - |
href | T | - |
openInNewTab? | boolean | false |
renderAnchor? | (props: RenderAnchorProps<T>) => ReactNode | defaultRenderAnchor |
Inherited attributes (except the ones set internally): AnchorHTMLAttributes<HTMLAnchorElement>