1e41f4b71Sopenharmony_ci# DownloadFileButton
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci**DownloadFileButton** is a download button that, when clicked, allows you to obtain the storage location of the current application in the public **Download** directory.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci> **NOTE**
7e41f4b71Sopenharmony_ci>
8e41f4b71Sopenharmony_ci> This component is supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci##  Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```
13e41f4b71Sopenharmony_ciimport { DownloadFileButton } from '@kit.ArkUI'
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## Child Components
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciNot supported
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci## Attributes
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ciThe [universal attributes](ts-universal-attributes-size.md) are supported.
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci## DownloadFileButton
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ciDownloadbutton(contentOptions?:DownloadContentOptions, styleOptions?:DownloadStyleOptions)
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ciCreates a download file button, which by default displays both an icon and text.
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci**Decorator**: @Component
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci**Parameters**
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci| Name          | Type                                                        | Mandatory| Decorator| Description                            |
39e41f4b71Sopenharmony_ci| -------------- | ------------------------------------------------------------ | ---- | ---------- | -------------------------------- |
40e41f4b71Sopenharmony_ci| contentOptions | [DownloadContentOptions](#downloadcontentoptions) | No  | @State     | Content options for creating the download file button.|
41e41f4b71Sopenharmony_ci| styleOptions   | [DownloadStyleOptions](#downloadstyleoptions) | No  | @State     | Style options for creating the download file button.|
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci## DownloadContentOptions
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ciDefines the content displayed in the download file button.
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                                                        |
52e41f4b71Sopenharmony_ci| ---- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
53e41f4b71Sopenharmony_ci| icon | [DownloadIconStyle](#downloadiconstyle) | No  | Icon style of the download file button.<br>If this parameter is not specified, no icon is contained. Either **icon** or **text**, or both, must be set.|
54e41f4b71Sopenharmony_ci| text | [DownloadDescription](#downloaddescription) | No  | Text on the download file button.<br>If this parameter is not specified, no text is contained. Either **icon** or **text**, or both, must be set.|
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci## DownloadStyleOptions
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ciDefines the style of the icon and text in the download file button.
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci| Name           | Type                                                        | Mandatory| Description                                                        |
65e41f4b71Sopenharmony_ci| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
66e41f4b71Sopenharmony_ci| iconSize        | Dimension                                                    | No  | Icon size of the download file button.<br>Default value: **16vp**                     |
67e41f4b71Sopenharmony_ci| layoutDirection | [DownloadLayoutDirection](#downloadlayoutdirection) | No  | Direction of the icon and text on the download file button.<br>Default value: **DownloadLayoutDirection.HORIZONTAL**|
68e41f4b71Sopenharmony_ci| fontSize        | Dimension                                                    | No  | Font size of the download file button.<br>Default value: **16fp**                     |
69e41f4b71Sopenharmony_ci| fontStyle       | FontStyle                                                    | No  | Font style of the download file button.<br>Default value: **FontStyle.Normal**         |
70e41f4b71Sopenharmony_ci| fontWeight      | number \| FontWeight \| string                               | No  | Font weight of the download file button.<br>Default value: **FontWeight.Medium**          |
71e41f4b71Sopenharmony_ci| fontFamily      | string \| Resource                                           | No  | Font family of the download file button.<br>Default font: **'HarmonyOS Sans'**       |
72e41f4b71Sopenharmony_ci| fontColor       | ResourceColor                                                | No  | Font color of the download file button.<br>Default value: **#ffffffff**                |
73e41f4b71Sopenharmony_ci| iconColor       | ResourceColor                                                | No  | Icon color of the download file button.<br>Default value: **#ffffffff**                |
74e41f4b71Sopenharmony_ci| textIconSpace   | Dimension                                                    | No  | Space between the icon and text on the download file button.<br>Default value: **4vp**                |
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci## DownloadIconStyle
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ciDefines the icon style of the download file button.
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci| Name       | Value  | Description                      |
85e41f4b71Sopenharmony_ci| ----------- | ---- | -------------------------- |
86e41f4b71Sopenharmony_ci| FULL_FILLED | 1    | Filled style icon.|
87e41f4b71Sopenharmony_ci| LINES       | 2    | Line style icon.|
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci## DownloadDescription
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ciDefines the text on the download file button.
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci| Name               | Value  | Description                            |
100e41f4b71Sopenharmony_ci| ------------------- | ---- | -------------------------------- |
101e41f4b71Sopenharmony_ci| DOWNLOAD            | 1    | The text on the download file button is **Download**.    |
102e41f4b71Sopenharmony_ci| DOWNLOAD_FILE       | 2    | The text on the download file button is **Download File**.|
103e41f4b71Sopenharmony_ci| SAVE                | 3    | The text on the download file button is **Save**.    |
104e41f4b71Sopenharmony_ci| SAVE_IMAGE          | 4    | The text on the download file button is **Save Image**.|
105e41f4b71Sopenharmony_ci| SAVE_FILE           | 5    | The text on the download file button is **Save File**.|
106e41f4b71Sopenharmony_ci| DOWNLOAD_AND_SHARE  | 6    | The text on the download file button is **Download and Share**.|
107e41f4b71Sopenharmony_ci| RECEIVE             | 7    | The text on the download file button is **Receive**.    |
108e41f4b71Sopenharmony_ci| CONTINUE_TO_RECEIVE | 8    | The text on the download file button is **Continue**.|
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci## DownloadLayoutDirection
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ciDefines the direction of the icon and text in the download file button.
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci| Name      | Value  | Description                                      |
121e41f4b71Sopenharmony_ci| ---------- | ---- | ------------------------------------------ |
122e41f4b71Sopenharmony_ci| HORIZONTAL | 0    | The icon and text on the download file button are horizontally arranged.|
123e41f4b71Sopenharmony_ci| VERTICAL   | 1    | The icon and text on the download file button are vertically arranged.|
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci## Events
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ciThe [universal events](ts-universal-events-click.md) are supported.
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci##  Example
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci```
132e41f4b71Sopenharmony_ciimport { picker } from '@kit.CoreFileKit';
133e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
134e41f4b71Sopenharmony_ciimport { DownloadFileButton, DownloadLayoutDirection } from '@kit.ArkUI';
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci@Entry
137e41f4b71Sopenharmony_ci@Component
138e41f4b71Sopenharmony_cistruct Index {
139e41f4b71Sopenharmony_ci  build() {
140e41f4b71Sopenharmony_ci    Column() {
141e41f4b71Sopenharmony_ci      DownloadFileButton({
142e41f4b71Sopenharmony_ci        contentOptions: {
143e41f4b71Sopenharmony_ci          // icon: DownloadIconStyle.FULL_FILLED,
144e41f4b71Sopenharmony_ci          // text: DownloadDescription.DOWNLOAD
145e41f4b71Sopenharmony_ci        },
146e41f4b71Sopenharmony_ci        styleOptions: {
147e41f4b71Sopenharmony_ci          iconSize: '16vp',
148e41f4b71Sopenharmony_ci          layoutDirection: DownloadLayoutDirection.HORIZONTAL,
149e41f4b71Sopenharmony_ci          fontSize: '16vp',
150e41f4b71Sopenharmony_ci          fontStyle: FontStyle.Normal,
151e41f4b71Sopenharmony_ci          fontWeight: FontWeight.Medium,
152e41f4b71Sopenharmony_ci          fontFamily: 'HarmonyOS Sans',
153e41f4b71Sopenharmony_ci          fontColor: '#ffffffff',
154e41f4b71Sopenharmony_ci          iconColor: '#ffffffff',
155e41f4b71Sopenharmony_ci          textIconSpace: '4vp'
156e41f4b71Sopenharmony_ci        }
157e41f4b71Sopenharmony_ci      })
158e41f4b71Sopenharmony_ci        .backgroundColor('#007dff')
159e41f4b71Sopenharmony_ci        .borderStyle(BorderStyle.Dotted)
160e41f4b71Sopenharmony_ci        .borderWidth(0)
161e41f4b71Sopenharmony_ci        .borderColor('')
162e41f4b71Sopenharmony_ci        .borderRadius('24vp')
163e41f4b71Sopenharmony_ci        .position({ x: 0, y: 0 })
164e41f4b71Sopenharmony_ci        .markAnchor({ x: 0, y: 0 })
165e41f4b71Sopenharmony_ci        .offset({ x: 0, y: 0 })
166e41f4b71Sopenharmony_ci        .constraintSize({})
167e41f4b71Sopenharmony_ci        .padding({
168e41f4b71Sopenharmony_ci          top: '12vp',
169e41f4b71Sopenharmony_ci          bottom: '12vp',
170e41f4b71Sopenharmony_ci          left: '24vp',
171e41f4b71Sopenharmony_ci          right: '24vp'
172e41f4b71Sopenharmony_ci        })
173e41f4b71Sopenharmony_ci        .onClick(() => {
174e41f4b71Sopenharmony_ci          this.downloadAction();
175e41f4b71Sopenharmony_ci        })
176e41f4b71Sopenharmony_ci    }
177e41f4b71Sopenharmony_ci  }
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci  downloadAction() {
180e41f4b71Sopenharmony_ci    try {
181e41f4b71Sopenharmony_ci      const document = new picker.DocumentSaveOptions();
182e41f4b71Sopenharmony_ci      document.pickerMode = picker.DocumentPickerMode.DOWNLOAD;
183e41f4b71Sopenharmony_ci      new picker.DocumentViewPicker().save(document, (err: BusinessError, result: Array<string>) => {
184e41f4b71Sopenharmony_ci        if (err) {
185e41f4b71Sopenharmony_ci          return;
186e41f4b71Sopenharmony_ci        }
187e41f4b71Sopenharmony_ci        console.info(`downloadAction result:  ${JSON.stringify(result)}`);
188e41f4b71Sopenharmony_ci      });
189e41f4b71Sopenharmony_ci    } catch (e) {
190e41f4b71Sopenharmony_ci    }
191e41f4b71Sopenharmony_ci  }
192e41f4b71Sopenharmony_ci}
193e41f4b71Sopenharmony_ci```
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci![en-us_image_0000001643320073](figures/en-us_image_0000001643320073.png)
196