Expo UI and Router for iOSExpo SDK 57 and later, iOS only
Components

Link

A SwiftUI Link component for displaying clickable links.

Expo UI Link matches the official SwiftUI Link API.

Usage

import { Host, Link } from '@expo/ui/swift-ui';

export default function BasicLinkExample() {
  return (
    <Host style={{ flex: 1 }}>
      <Link label="Visit Expo" destination="https://expo.dev" />
    </Host>
  );
}
A blue Visit Expo text link
A blue Visit Expo text link

Custom label content

You can pass custom components as children for more complex link label content.

import { Host, Link, VStack, Image, Text } from '@expo/ui/swift-ui';

export default function CustomContentExample() {
  return (
    <Host style={{ flex: 1 }}>
      <Link destination="https://expo.dev">
        <VStack spacing={4}>
          <Image systemName="link" />
          <Text>Expo</Text>
        </VStack>
      </Link>
    </Host>
  );
}
A link SF Symbol above the text Expo, both tinted blue
A link SF Symbol above the text Expo, both tinted blue

API

import { Link } from '@expo/ui/swift-ui';

Component

Type: React.Element<LinkProps>

Displays a native link component.

Example

import { Link } from '@expo/ui/swift-ui';
import { foregroundStyle, font } from '@expo/ui/swift-ui/modifiers';

<Link
  label="Open"
  destination="https://expo.dev"
  modifiers={[
    foregroundStyle('red'),
    font({ size: 24, weight: 'bold' })
  ]}
/>

LinkProps

children

Optional • Literal type: union

Custom content for the link label. Use this for custom label views. Only nested elements are supported, not plain strings.

Acceptable values are: ReactElement<unknown, string | JSXElementConstructor<any>> | ReactElement[]

destination

Type: string

The URL for the link.

label

Optional • Type: string

The text label for the Link. Use this for simple text links.

Inherited props

Modifiers

Use these modifiers in the modifiers prop of the SwiftUI version.

Expo UI lets you put any of the 89 modifiers for any view on Link, but not all of them do something here.

  • 70 change what you see on Link.
  • 6 have no visible effect on Link.
  • 13 work only in one place, such as a widget or a Grid.

Best modifiers for Link

These modifiers are made for Link, or they are the ones that you use most with it.

Also works on Link

Link takes these modifiers too, and each one works in the usual way.

No visible effect on Link

Link accepts these modifiers, but you see no change. They do not give an error.

ModifierWhy nothing happens
accessibilityElementIt joins the child views into one accessibility element, and Link takes no child views.
containerShapeIt sets the shape that the child views use for containerRelativeShape, and Link takes no child views.
geometryGroup iOS 17+It works on the child views that you give the component, and Link takes none.
layoutPriorityIt has an effect only when the view shares an axis with other views in a stack.
onTapGestureLink opens its URL itself. A tap gesture can stop the link.
zIndexIt changes the order of views that cover each other in the same parent, and Link does not stack its children.

Only in some places

These modifiers work only in a widget, in a Grid, in a Namespace or in a parent that asks for them.

ModifierWhere it works
activityBackgroundTintWorks only in a Live Activity. It has no effect in the app.
alignmentGuideHas an effect only when the parent, such as a VStack or ZStack, aligns its children by the same guide.
containerBackgroundWorks only in a widget, or in a navigation container when you use a navigation placement.
glassEffectIdWorks only on a view that also has glassEffect, in a GlassEffectContainer and a Namespace.
gridCellAnchor iOS 16+Works only on a cell of a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridCellColumnsWorks only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridCellUnsizedAxesWorks only on a view in a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridColumnAlignment iOS 16+Works only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
invalidatableContent iOS 17+Has an effect only when a parent view uses redacted with the invalidated reason.
matchedGeometryEffectWorks only in a Namespace. Give two views the same id and change between them with an animation.
privacySensitiveHas an effect only when a parent view uses redacted with the privacy reason.
unredactedHas an effect only in a parent view that uses redacted.
widgetURLWorks only in a widget. It has no effect in the app.

Sources

The original Expo docs for this page:

  • Link (SwiftUI) (source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/link.md)

On this page