Link
A real anchor in the accent colour. Pressed, it dims while held and opens on release, in a new tab unless you handle it. Flat, as on iOS: no glass.
import { Link } from "@adamexu/glass";Basic
<Link destination="/docs">Documentation</Link>
<Link destination="/docs/button" tint="#FF9500">Button docs</Link>
<Link destination="/docs" disabled>Unavailable</Link>Handling the open
By default a click opens destination in a new tab. openURL runs first: return true when you have handled it, as an app with its own router or an Electron shell would.
not opened yet
const [opened, setOpened] = useState<string | null>(null);
<Link
destination="/docs/sheet"
openURL={(url) => {
setOpened(url);
return true;
}}
>
Open in place
</Link>In a List
In a List's row the whole row takes the press and opens on release, with no chevron; the title keeps its tint.
<NavigationStack
root={
<NavigationPage title="About">
<List>
<Section header="Link">
<Link destination="/docs">
<Text>Documentation</Text>
</Link>
<Link destination="/docs/button">
<Label title="With an icon" icon={<Star size={20} />} />
</Link>
<Link destination="/docs" disabled>
<Text>Disabled</Text>
</Link>
</Section>
</List>
</NavigationPage>
}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| destination | string | - | Required. The URL; the anchor's href. |
| children | ReactNode | - | The title, or a Label. Drawn in the tint. |
| tint | string | accent blue | The title's colour. |
| disabled | boolean | false | The title at a quarter of its colour, no href, aria-disabled. |
| openURL | (url: string) => boolean | void | - | Runs on click; return true when you've handled it, else a new tab opens. |
| className, style | string, CSSProperties | - | On the anchor. |
SwiftUI
| SwiftUI | @adamexu/glass |
|---|---|
| Link(title, destination:) | <Link destination>title</Link> |
| .environment(\.openURL, OpenURLAction { }) | openURL |
| .tint(c) | tint={c} |
| .disabled(true) | disabled |