Link
The Link component is designed to provide a consistent and accessible way to handle both internal and external links in your application.
Usage
First of all, you need to import the Link
component from the kitchn
package.
import { Link } from "kitchn"
Default
Code Editor
Code Editor
<Link href={"/"}>{"Return to menu"}</Link>
Using onClick
Code Editor
Code Editor
<Link onClick={() => router.push("/")}>{"Return to menu"}</Link>
Disabled
Code Editor
Code Editor
<Container gap={"small"}> <Link disabled>{"Disabled link"}</Link> <Link href={undefined} onClick={undefined}> {"Disabled link (no href or onClick)"} </Link> <Link href={"#"} disabled> {"Disabled link (href=#)"} </Link> </Container>
Non Text
Code Editor
Code Editor
<Link href={"/"}> <Badge>{"This entire badge is wrapped in a link"}</Badge> </Link>
Variants
Highlight
Code Editor
Code Editor
<Link href={"#"} variant={"highlight"}> {"Highlight variant"} </Link>
Primary
Code Editor
Code Editor
<Link href={"#"} variant={"primary"}> {"Primary variant"} </Link>
Secondary
Code Editor
Code Editor
<Link href={"#"} variant={"secondary"}> {"Secondary variant"} </Link>
Blend
Blend variant works well with themed components.
Code Editor
Code Editor
<Note type={"danger"} label={false}> <Link href={"#"} variant={"blend"}> {"Blend variant"} </Link>{" "} {"works well with themed components."} </Note>
Fragment Link (Anchor)
Code Editor
Code Editor
<FragmentLink id={"fragment-link-example"}> {"Click on this to jump to this section of the page"} </FragmentLink>
Internal Href
Code Editor
Code Editor
<Link href={"/"}>{"Click on this to jump back to the menu"}</Link>
External Href
Code Editor
Code Editor
<Link href={"https://tonightpass.com/"}> {"Click on this to go to our website"} </Link>
Props
Name | Type | Default | Required | Description |
---|---|---|---|---|
href | string | UrlObject | undefined | No | The URL to navigate to when the link is clicked. |
onClick | (_event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void | undefined | No | Function to handle click events. |
disabled | boolean | false | No | Disables the link, preventing navigation and modifying its styling. |
variant | "highlight" | "primary" | "secondary" | "blend" | undefined | No | Specifies the visual style of the link. |
FragmentLink Props
Name | Type | Default | Required | Description |
---|---|---|---|---|
id | string | undefined | Yes | The ID of the element to link to within the page. |
Last updated on