Components

链接

用于页面间导航的语义元素。

<Link href="#">Sign up</Link>

API 参考

¥API Reference

此组件基于 a 元素并支持 常用边距属性

¥This component is based on the a element and supports common margin props.

PropTypeDefault
asChild
boolean
No default value
size
Responsive<enum>
No default value
weight
Responsive<"light" | "regular" | "medium" | "bold">
No default value
trim
Responsive<"normal" | "start" | "end" | "both">
No default value
truncate
boolean
No default value
wrap
Responsive<"wrap" | "nowrap" | "pretty" | "balance">
No default value
underline
"auto" | "always" | "hover" | "none"
"auto"
color
enum
No default value
highContrast
boolean
No default value

示例

¥Examples

尺寸

¥Size

使用 size 属性控制链接的大小。该属性还提供正确的行高和校正的字母间距 - 随着文本大小的增加,相对行高和字母间距会减小。

¥Use the size prop to control the size of the link. The prop also provides correct line height and corrective letter spacing—as text size increases, the relative line height and letter spacing decrease.

<Flex direction="column" gap="3">
<Link href="#" size="1">
Sign up
</Link>
<Link href="#" size="2">
Sign up
</Link>
<Link href="#" size="3">
Sign up
</Link>
<Link href="#" size="4">
Sign up
</Link>
<Link href="#" size="5">
Sign up
</Link>
<Link href="#" size="6">
Sign up
</Link>
<Link href="#" size="7">
Sign up
</Link>
<Link href="#" size="8">
Sign up
</Link>
<Link href="#" size="9">
Sign up
</Link>
</Flex>

重量

¥Weight

使用 weight 属性设置文本粗细。

¥Use the weight prop to set the text weight.

<Flex direction="column">
<Link href="#" weight="regular">
Sign up
</Link>
<Link href="#" weight="medium">
Sign up
</Link>
<Link href="#" weight="bold">
Sign up
</Link>
</Flex>

截断

¥Truncate

当文本溢出容器时,使用 truncate 属性用省略号截断文本。

¥Use the truncate prop to truncate text with an ellipsis when it overflows its container.

<Flex maxWidth="150px">
<Link href="#" truncate>
Sign up to the newsletter
</Link>
</Flex>

颜色

¥Color

使用 color 属性指定特定的 color

¥Use the color prop to assign a specific color.

<Flex direction="column">
<Link href="#" color="indigo">
Sign up
</Link>
<Link href="#" color="cyan">
Sign up
</Link>
<Link href="#" color="orange">
Sign up
</Link>
<Link href="#" color="crimson">
Sign up
</Link>
</Flex>

高对比度

¥High-contrast

使用 highContrast 属性增加与背景的颜色对比度。

¥Use the highContrast prop to increase color contrast with the background.

<Flex direction="column">
<Link href="#" color="gray">
Sign up
</Link>
<Link href="#" color="gray" highContrast>
Sign up
</Link>
</Flex>

下划线

¥Underline

使用 underline 属性管理下划线功能可见性。

¥Use the underline prop to manage the visibility of the underline affordance.

<Flex direction="column">
<Link href="#" underline="hover">
Sign up
</Link>
<Link href="#" underline="always">
Sign up
</Link>
</Flex>
PreviousKbd
Next引用