On this page

chatty-link

API chuẩn của element chatty-link, sinh từ custom-elements.json của prototype trong guide.

Copy page as MarkdownRead Markdown ↗

Key rules

  • chatty-link khai 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.js là define chatty-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
--chatty-link-color – 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ộ.

Standard
LightDarkDesktopMobile

Default: trạng thái mặc định và nội dung mẫu của element.

Show code
chatty-link.element.jsWrap code linesCopy
<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>
Standard
LightDarkDesktopMobile

Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.

Show code
chatty-link.element.jsWrap code linesCopy
<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ả.

Standard
LightDarkDesktopMobile

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.element.jsWrap code linesCopy
<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-ui/custom-elements.json

Keyboard

Key Action
Enter Follow the link.

Source

  • chatty-ui/custom-elements.json