Link
A text link, inline in a sentence or on its own. With href it's a real <a> on the web, so people can open it in a new tab or copy its address, and it opens the browser on iOS and Android. For an action that isn't navigation, use a Button.
import { Link } from 'patine-ui';
<Box padding="lg" border radius="lg" gap="sm" style={{ maxWidth: 420 }}> <Text weight="semibold">Almost there</Text> <Text color="textSecondary"> By creating an account you agree to our <Link href="https://patine.dev/terms">Terms of Service</Link> and{' '} <Link href="https://patine.dev/privacy">Privacy Policy</Link>. </Text> <Link href="https://status.patine.dev" external size="sm"> System status </Link> </Box>
Try the props
underlinedesign<Link href="https://patine.dev">Read the docs</Link>
Example: a sign-in form's links
A sign-in card has three kinds of link: one that acts inside the app (Forgot password), one that goes to another page (Create an account), and one that leaves for another site, marked external.
<Box border radius="lg" padding="lg" gap="md" style={{ width: '100%', maxWidth: 380 }}> <Text size="lg" weight="semibold">Sign in to Ledger</Text> <TextField label="Email" defaultValue="[email protected]" autoCapitalize="none" /> <TextField label="Password" secureTextEntry /> <Link onPress={() => setReset(true)} size="sm"> Forgot password? </Link> {reset ? <Text size="sm" color="success">We sent a reset link to [email protected].</Text> : null} <Button>Sign in</Button> <HStack gap="xs" wrap justify="center"> <Text size="sm" color="textSecondary">New here?</Text> <Link href="/docs/components/link" size="sm"> Create an account </Link> </HStack> <Link href="https://status.example.com" external size="sm" style={{ alignSelf: 'center' }}> Service status </Link> </Box>
Routing it yourself
Give onPress to navigate inside the app. To keep href from opening (for example, to use your router but keep the address on the web), call event.preventDefault() in onPress.
Designs
iOS tints links without a line. Material underlines them. brand and the web underline on hover, as shadcn does. underline overrides it: 'always', 'hover' or 'none'.
Accessibility
- A
linkrole, named by its text. On the web it's an anchor, reached with Tab and opened with Enter. externaladds ↗ and opens a new tab withrel="noopener noreferrer".- Color isn't the only cue where it matters: use
underline="always"for links inside body text if your primary color is close to the text color.
Props
Also takes Text props: size, weight, numberOfLines…
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | The link text. |
href | string | — | A URL to open. |
onPress | (event) => void | — | Called on press; preventDefault() keeps href from opening. |
external | boolean | false | New tab on the web, and a ↗. |
underline | 'always' | 'hover' | 'none' | the design's | When to underline. |
disabled | boolean | false | Grays it and ignores presses. |
theme, design | As every component. |