Link
An anchor element that derives its href from a directory, file, module export,
or from the RootProvider config.
import { Link, JavaScriptFile } from 'renoun' const file = new JavaScriptFile({ path: '../../packages/renoun/src/components/Link/Link.tsx', }) export async function ViewSource() { return <Link source={file}>View Source</Link> }
The Link component is an anchor element that derives its href from a directory, file, or module export, or from the RootProvider config.
It supports the following variants:
Variants
-
source(default),edit,history,raw,blame,editor -
repository,owner,branch,issue
Examples
Git Repository
View Sourceimport { Link } from 'renoun' export function GitRepository() { return ( <Link variant="repository" css={{ display: 'flex', width: '1.5rem', height: '1.5rem' }} /> ) }
Git Repository Custom
View Sourceimport { Link, Logo } from 'renoun' export function GitRepositoryCustom() { return ( <Link variant="repository" css={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }} > <Logo variant="gitHost" width="1em" height="1em" /> <span>View Repository</span> </Link> ) }
Custom Element
View Sourceimport { Link, JavaScriptFile } from 'renoun' const file = new JavaScriptFile({ path: '../../packages/renoun/src/components/Link/Link.tsx', }) export async function CustomElement() { return ( <Link source={file} variant="edit"> {(href) => <a href={href}>Edit Source</a>} </Link> ) }
Config Links
View Sourceimport { Link } from 'renoun' export function ConfigLinks() { return ( <ul> <li> <Link variant="repository">Repository</Link> </li> <li> <Link variant="owner">Owner</Link> </li> <li> <Link variant="branch" options={{ ref: 'release' }}> Branch </Link> </li> <li> <Link variant="issue">New Issue</Link> </li> </ul> ) }
API Reference
Type
"source" | "edit" | "raw" | "blame" | "history" | "editor" | "repository" | "owner" | "branch" | "issue"Variant extends LinkVariant
| Property | Type | |
|---|---|---|
| css? | CSSObject | |
| source | Source | |
| variant? | Variant | |
| options? | VariantOptions<Source, Variant> | |
| children? | ReactNode | (href: string) => ReactNode | |
Variant extends ConfigVariants
| Property | Type | |
|---|---|---|
| css? | CSSObject | |
| children? | ReactNode | (href: string) => ReactNode | |
An anchor element that derives its href from a directory, file, module export,
or from the RootProvider config.
Properties
LinkProps<Source, Variant>Last updated