• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Hyperlink
2
3The **\<Hyperlink>** component implements a link from a location in the component to another location.
4
5>  **NOTE**
6>
7>  - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8>  - This component must be used with the system browser.
9
10## Required Permissions
11
12If Internet access is required, you need to apply for the **ohos.permission.INTERNET** permission. For details about how to apply for a permission, see [Declaring Permissions](../../security/accesstoken-guidelines.md).
13
14## Child Components
15
16This component can contain the **\<Image>** child component.
17
18
19## APIs
20
21Hyperlink(address: string | Resource, content?: string | Resource)
22
23**Parameters**
24
25| Name| Type| Mandatory| Description|
26| -------- | -------- | -------- | -------- |
27| address | string \| [Resource](ts-types.md#resource) | Yes| Web page to which the hyperlink is redirected.|
28| content | string \| [Resource](ts-types.md#resource) | No| Text displayed in the hyperlink.<br>**NOTE**<br>If this component has child components, the hyperlink text is not displayed.|
29
30## Attributes
31
32In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
33
34| Name| Type| Description|
35| -------- | -------- | -------- |
36| color | [ResourceColor](ts-types.md#resourcecolor) | Color of the hyperlink text.|
37
38## Example
39
40```ts
41@Entry
42@Component
43struct HyperlinkExample {
44  build() {
45    Column() {
46      Column() {
47        Hyperlink('https://example.com/') {
48          Image($r('app.media.bg'))
49            .width(200)
50            .height(100)
51        }
52      }
53
54      Column() {
55        Hyperlink('https://example.com/', 'Go to the developer website') {
56        }
57        .color(Color.Blue)
58      }
59    }.width('100%').height('100%').justifyContent(FlexAlign.Center)
60  }
61}
62```
63
64![hyperlink](figures/hyperlink.PNG)
65