Link

With links, users can navigate seamlessly throughout a website. This component has a hyperlinked appearance for a user-friendly experience.
API Reference
Themed
Unstyled
Spec Doc
This is an illustration of a Themed Link component with default configuration.
<Link href="https://gluestack.io/">
<LinkText>gluestack</LinkText>
</Link>

API Reference

Import

To use this component in your project, include the following import statement in your file.
import { Link } from '@gluestack-ui/themed';

Anatomy

The structure provided below can help you identify and understand a Link component's various parts.
export default () => (
<Link>
<LinkText />
</Link>
)

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.
Contains all link related layout style props and actions. It inherits all the properties of React Native's Pressable component.
Prop
Type
Default
Description
href
string
-
URL that should be opened on Link press.
onPress
(event?: GestureResponderEvent) => any
-
Callback that will be invoked on Link press.
isExternal
boolean
false
If true, link will be opened in new tab on web. It uses _target property to achieve this.
isHovered
boolean
false
When true, the link displays a hover state.
isFocusVisible
boolean
false
To manually set focus visible state to the link.
Descendants Styling Props Props to style child components.
Sx Prop
Description
_text
Prop to style LinkText Component

LinkText

Contains all text related layout style props and actions. It inherits all the properties of React Native's Text component.

Accessibility

We have outlined the various features that ensure the Link component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards. Adheres to the WAI-ARIA design pattern.

Keyboard

  • Tab: Moves focus to the next focusable element.
  • Enter: Users should be able to open a link.

Screen Reader

  • VoiceOver: When a link receives focus, screen readers should announce a descriptive link name.

Themed

The themed version of the component is a pre-styled version of the component, which allows you to quickly integrate the component into your project. The component's design and functionality are fully defined, allowing you to focus on the more important aspects of your project. To know more about Themed Library please visit this link.

Props

Link component is created using Pressable component from react-native. It extends all the props supported by React Native Pressable, utility props and the props mentioned below.
Name
Value
Default
size
xs | sm | md | lg | xl | 2xl | 3xl | 4xl | 5xl | 6xl
md
Note: These props are exclusively applicable when utilizing the default configuration of gluestack-ui/config. If you are using a custom theme, these props may not be available.

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

Default

<HStack>
<Text size="lg">Design inspiration from </Text>
<Link href="https://gluestack.io/" isExternal>
<LinkText size="lg">pinterest.com</LinkText>
</Link>
</HStack>
<HStack>
<Text size="lg">Go to </Text>
<Link href="https://gluestack.io/" isExternal>
<HStack alignItems="center">
<LinkText size="lg">Pinterest</LinkText>
<Icon
as={ArrowUpRightIcon}
size="lg"
color="$info600"
mt="$0.5"
$dark-color="$info300"
/>
</HStack>
</Link>
</HStack>

Unstyled

All the components in gluestack-ui are unstyled by default. To customize your UI using the extendedTheme, please refer to this link. The import names of components serve as keys to customize each component.

Spec Doc

Explore the comprehensive details of the Link in this document, including its implementation details, checklist, and potential future additions. Dive into the thought process behind the component and gain insights into its development journey.
By default, Link component uses an anchor tag on web and pressable on native. If you want to use Next.js Link component on web, you have to create a new styled component for link and map it to Link component. You can also change the already present styled-component for link on the path ./components/core/link/styled-components in your project. For web specific styling, you can create a file with .web extension. For example, if you want to create a custom link component, you can create a file named Link.tsx and Linkweb.tsx in the same directory. The .web file will be used only on web and the Link.tsx file will be used on native.
import Link from 'next/link';
// Using the Next Link component
const StyledLink = styled(Link, styling, componentConfig, extendedBaseConfig);
// if some styling are direct props, you can pass them as props in the styling
props: {
w: 100,
h: 100,
borderRadius: '$full',
};
// you can also /style/docs/getting-started/styled to style the component
export default () => <StyledLink />;
Edit this page on GitHub