Links are accessible elements used primarily for navigation. This component is styled to resemble a hyperlink.
import { Link } from 'native-base';
const Example = () => {
return <Link mt={4} href="https://nativebase.io">
Default Link
</Link>;
};
const Example = () => {
return <Link _text={{
color: "blue.700"
}} href="https://nativebase.io" isExternal mt={4}>
NativeBase
</Link>;
};
const Example = () => {
return (
<Link mt={4} fontSize="xl" href="https://nativebase.io" isUnderlined>
Default Link
</Link>
);
};
const Example = () => {
const [state, setState] = React.useState(false);
const toggleState = () => {
setState(!state);
};
return <>
<Link onPress={toggleState} mt={4}>
Click here to toggle the color of box.
</Link>
<Box h="100" w="100" mt={4} bg={state ? "orange.300" : "blue.300"} />
</>;
};
const Example = () => {
return <Link href="https://nativebase.io" _hover={{
bg: "primary.100"
}} justifyContent="center" alignItems="center" isExternal mt={4} mx={4} flexWrap="wrap">
<Box p={4} bg="seagreen">
<Text color="white" fontSize={16}>
Box
</Text>
</Box>
<Text px={2} my={1} _light={{
color: "blue.700"
}} _dark={{
color: "blue.500"
}}>
Clicking anywhere will trigger the link
</Text>
<Box p={4} bg="emerald.700">
<Text color="white" fontSize={16}>
Box
</Text>
</Box>
</Link>;
};
Link implements
,
,
,
,
,
,
,
,
,
,
,
,
URL that should be opened on Link press
Size of the link
Type: number | "2xl" | "xl" | "lg" | "md" | "sm" | "xsm"
Whether Link text should be underlined
Callback that will be invoked on Link press
If true, link will be opened in new tab on web. It uses _target property to achieve this
Hover props. Accepts all styled system props.
Ref to be attached to the Link wrapper
NativeBase ships with a default theme for each component. Check out the default theme of the link
.
Info:
We can easily extend the link component theme using extendTheme function as described in the documentation .