連結是主要元件,用於建立導覽連結、自訂動作、切換標籤、開啟/關閉模態視窗等。
包含以下元件
連結
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
colors | 物件 | 帶有 Tailwind CSS 色彩類別的物件 | |
colors.navbarTextIos | 字串 | 'text-primary' | |
colors.navbarTextMaterial | 字串 | '' | |
colors.textIos | 字串 | 'text-primary' | |
colors.textMaterial | 字串 | 'text-md-light-primary dark:text-md-dark-primary' | |
component | 字串 | 'a' | 元件的 HTML 元素 |
iconOnly | 布林值 | false | 如果連結除了圖示外不包含任何內容,則啟用 |
linkProps | 任何 | 要傳遞給連結/按鈕的其他屬性 (attribute) 的物件 | |
navbar | 布林值 | false | 如果連結在導覽列中,則應啟用 |
tabbar | 布林值 | false | 如果連結在標籤列中,則應啟用 |
tabbarActive | 布林值 | false | 將標籤列連結標示為目前活動的連結 |
toolbar | 布林值 | false | 如果連結在工具列中,則應啟用 |
touchRipple | 布林值 | 未定義 | 在 Material 主題中啟用觸控波紋效果。如果未指定,如果連結為 |
onClick | 函式(e) | 點擊處理器 |
<Link href="/about">About</Link>
<Link href="https://google.com" target="_blank">
Google
</Link>
import { Link } from 'konsta/react';
import { Link as RouterLink } from 'react-router-dom';
// ...
<Link href="/about" component={RouterLink}>
About
</Link>
<Navbar
title="My App"
right={
<Link navbar onClick={openMenu}>Menu</Link>
}
/>
<Toolbar>
<Link toolbar onClick={action1}>Action 1</Link>
<Link toolbar onClick={action2}>Action 2</Link>
</Toolbar>