Files
2026-08-06 15:26:13 -04:00

35 lines
771 B
TypeScript

import type { JSX } from "solid-js"
import type { RGBA } from "@opentui/core"
import open from "open"
export interface LinkProps {
href: string
children?: JSX.Element | string
fg?: RGBA
bg?: RGBA
width?: number | "auto" | `${number}%`
wrapMode?: "word" | "none"
}
/**
* Link component that renders clickable hyperlinks.
* Clicking anywhere on the link text opens the URL in the default browser.
*/
export function Link(props: LinkProps) {
const displayText = props.children ?? props.href
return (
<text
fg={props.fg}
bg={props.bg}
width={props.width}
wrapMode={props.wrapMode}
onMouseUp={() => {
open(props.href).catch(() => {})
}}
>
<a href={props.href}>{displayText}</a>
</text>
)
}