Skip to main content

Link

Link is a text control that opens a destination, such as a help article, an external website, or another screen.

Import

import { Link } from '@vortexlabs/vortex-native';
import type { LinkProps } from '@vortexlabs/vortex-native';

Other links

import { Link } from "@vortexlabs/vortex-native";

<Link
  href="https://vortex.mobile"
  tone="neutral"
  size="md"
  variant="plain"
  weight="medium"
>
  Vortex
</Link>

Features

  • Opens URLs through React Native Linking.
  • Supports standalone links and inline links within Vortex Text.
  • Supports brand and semantic tones, sizes, and icons.

Variants

Use plain for standalone links and underline for links in a sentence.

<Stack direction="row" gap={2} wrap>
  <Link href="https://vortex.mobile" variant="plain">Vortex</Link>
  <Link href="https://vortex.mobile" variant="underline">Vortex</Link>
</Stack>

Sizes

Standalone links use md by default. Inline links keep the surrounding text size until you set size.

<Stack direction="row" align="center" gap={2} wrap>
  <Link href="https://vortex.mobile" size="sm">Vortex</Link>
  <Link href="https://vortex.mobile" size="md">Vortex</Link>
  <Link href="https://vortex.mobile" size="lg">Vortex</Link>
</Stack>

Tone

Use secondary for the theme’s secondary brand color.

<Stack direction="row" gap={2} wrap>
  <Link href="https://vortex.mobile" tone="neutral">Vortex</Link>
  <Link href="https://vortex.mobile" tone="primary">Vortex</Link>
  <Link href="https://vortex.mobile" tone="secondary">Vortex</Link>
  <Link href="https://vortex.mobile" tone="critical">Vortex</Link>
</Stack>

Icons

Pass startIcon or endIcon an SVG source.

<Stack direction="row" gap={2} wrap>
  <Link href="https://vortex.mobile" startIcon={Hexagon}>Vortex</Link>
  <Link href="https://vortex.mobile" endIcon={Hexagon}>Vortex</Link>
</Stack>

Weight

Use weight to adjust emphasis. The default is medium.

<Stack direction="row" gap={2} wrap>
  <Link href="https://vortex.mobile" weight="regular">Vortex</Link>
  <Link href="https://vortex.mobile" weight="medium">Vortex</Link>
  <Link href="https://vortex.mobile" weight="bold">Vortex</Link>
</Stack>

Place Link inside Text to keep it in the sentence. Use variant="underline" to make the link identifiable by more than color.

<Text>
  Read the <Link href="https://vortex.mobile" tone="secondary" variant="underline">Vortex guide</Link>.
</Text>

Press Handling

onPress runs before the URL opens. Call event.preventDefault() to let your app confirm the destination before opening it.

import { Link } from "@vortexlabs/vortex-native";

type Props = {
  helpUrl: string;
  confirmOpen: (url: string) => void;
};

export const HelpLink = (props: Props) => {
  const { helpUrl, confirmOpen } = props;

  return (
    <Link
      href={helpUrl}
      onPress={(event) => {
        event.preventDefault();
        confirmOpen(helpUrl);
      }}
    >
      Help center
    </Link>
  );
};

Router Integration

Use render to wrap the supplied pressable in your routing component.

import { Link } from "@vortexlabs/vortex-native";
import { Link as RouterLink } from "expo-router";

<Link render={(element) => <RouterLink href="/settings" asChild>{element}</RouterLink>}>
  Settings
</Link>

Disabled

Set disabled to prevent presses and navigation.

<Stack direction="row" gap={3} wrap>
  <Link href="https://vortex.mobile">Vortex</Link>
  <Link href="https://vortex.mobile" disabled>Vortex</Link>
</Stack>

Accessibility

Description
Use link text that identifies the destination.
Use a standalone link when you need the theme's full touch target.