Key rules
chatty-linkkhai báo 2 attribute, 0 property không có attribute, 1 event, 1 slot, 1 part và 1 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/link.jslà definechatty-link; chunk chỉ import element nó dùng. Prototype chuẩn: trong guide. - Đổi tên attribute, event, slot, part hay CSS custom property là đổi API: diff của custom-elements.json phải có trong 1 MR.
On this page
Overview
An underlined inline link for answer content. Only http, https, mailto, tel, relative and fragment URLs render an href; other schemes render inert text. External links open a new tab. Class ChattyLink.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
href |
href |
string |
'' |
http, https, mailto, tel, relative or fragment URL; other schemes render inert text. |
target |
target |
'_blank' | '_self' | '' |
'' |
Empty: links to another origin open a new tab with noopener noreferrer. |
Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
Events
| Name | Detail type | Description |
|---|---|---|
click |
MouseEvent |
Native activation. |
Slots
| Name | Description |
|---|---|
| default | Link text (kept in light DOM so it stays indexable and translatable). |
Parts
| Name | Description |
|---|---|
base |
Native anchor. |
CSS custom properties
| Name | Default | Description |
|---|---|---|
- |
– | Text and underline colour. |
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/link.js';
<chatty-link href="https://example.com/delivery">Delivery policy</chatty-link>
<chatty-link href="mailto:help@example.com">Email us</chatty-link>
<chatty-link href="#orders">Your orders</chatty-link>
Live preview
Component thật dùng cùng story với trang component; dữ liệu mẫu nằm trong frame cục bộ.
Default: trạng thái mặc định và nội dung mẫu của element.
Show code
<chatty-link href="https://example.com/delivery">Delivery policy</chatty-link>
<chatty-link href="mailto:help@example.com">Email us</chatty-link>
<chatty-link href="#orders">Your orders</chatty-link>Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
Show code
<chatty-link href="https://example.com/faq" target="_self">FAQ in the same tab</chatty-link>
<chatty-link href="javascript:alert(1)">Unsafe scheme renders text</chatty-link>Anatomy
Số trong hình khớp bảng bên dưới. Phần chỉ hiện ở state khác được ghi Not shown; ví dụ không thêm phần tử giả.
Anatomy: một instance mặc định riêng, có khoảng trống quanh các phần được đánh số.
Show code
<chatty-link href="https://example.com/delivery">Delivery policy</chatty-link>
<chatty-link href="mailto:help@example.com">Email us</chatty-link>
<chatty-link href="#orders">Your orders</chatty-link>| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
Keyboard
| Key | Action |
|---|---|
| Enter | Follow the link. |
Source
- chatty-ui/custom-elements.json