<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p3248828131212"><aname="p3248828131212"></a><aname="p3248828131212"></a>Content used to generate the QR code</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p2248182810126"><aname="p2248182810126"></a><aname="p2248182810126"></a>QR code type. Available values are as follows:</p>
<aname="ul19772143474918"></a><aname="ul19772143474918"></a><ulid="ul19772143474918"><li><strongid="b1932091716183"><aname="b1932091716183"></a><aname="b1932091716183"></a>rect</strong>: rectangular QR code</li><li><strongid="b13684142218183"><aname="b13684142218183"></a><aname="b13684142218183"></a>circle</strong>: round QR code</li></ul>
</td>
</tr>
</tbody>
</table>
## Styles<a name="section439317598552"></a>
In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported.
>- If the values of **width** and **height** are different, the smaller value is used as the length of the QR code. The generated QR code is center displayed.
>- If either **width** or **height** is set, the value is used as the length of the QR code. If neither of them is set, the default length is 200 px.
## Events<a name="section1948820711216"></a>
Events in [Universal Events](js-components-common-events.md) are supported.
## Methods<a name="section2279124532420"></a>
Methods in [Universal Methods](js-components-common-methods.md) are supported.
## Example<a name="section81001951259"></a>
```
## Attributes
In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported.
| Name | Type | Default Value | Mandatory | Description |
| color | <color> | \#000000 | No | Color of the QR code. |
| background-color | <color> | \#ffffff | No | Background color of the QR code.|
> **NOTE**
> - If the values of **width** and **height** are different, the smaller value is used as the length of the QR code. The generated QR code is centered.
>
>
> - If either **width** or **height** is set, the value is used as the length of the QR code. If neither of them is set, the default length 200 px is used.
>
## Events
The [universal events](../arkui-js/js-components-common-events.md) are supported.
## Methods
The [universal methods](../arkui-js/js-components-common-methods.md) are supported.
The atomic layout implements adaptive layout for screens of different sizes and types. Designers can use the atomic layout to define adaptive rules for elements on UIs of different forms. Developers can use the atomic layout to implement the adaptive UI features matching the design effect for a variety of screens.
The atomic layout implements adaptive layout for screens of different sizes and types. Designers can use the atomic layout to define adaptive rules for elements on UIs of different forms. Developers can use the atomic layout to implement the adaptive UI features matching the design effect for a variety of screens.
> This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version.
## Hiding Components
You can set priority flags for a flex layout that does not support cross-row display to define the display priorities for elements in the horizontal or vertical direction. The elements are hidden based on available space of the container.
You can set priority flags for a flex layout that does not support cross-row display to define the display priorities for elements in the horizontal or vertical direction. The elements are hidden based on available space of the container.
| display-index | number | Display index of a child component. Child components are hidden according to the ascending order of their **display-index** values when the space on the flex main axis of the container is insufficient to display all content. Child components with the same display-index value are hidden at the same time.<br>Default value: **0** (means not to hide the child component)|
<tdclass="cellrowborder"valign="top"width="59.5%"headers="mcps1.1.5.1.4 "><pid="p75481189562"><aname="p75481189562"></a><aname="p75481189562"></a>Hide child components according to the ascending order of their <strongid="b9988192710556"><aname="b9988192710556"></a><aname="b9988192710556"></a>display-index</strong> values when the space on the flex main axis of the container is insufficient to display all content.</p>
<pid="p11989182765511"><aname="p11989182765511"></a><aname="p11989182765511"></a>Child components with the same <strongid="b189887271559"><aname="b189887271559"></a><aname="b189887271559"></a>display-index</strong> value are hidden at the same time.</p>
<pid="p1363375318"><aname="p1363375318"></a><aname="p1363375318"></a>You can use the default value (<strongid="b1163178316"><aname="b1163178316"></a><aname="b1163178316"></a>0</strong>) for a child component, which means that it will be hidden.</p>
<pid="p3505181129"><aname="p3505181129"></a><aname="p3505181129"></a>This style is applicable only to child components in a container that supports the flex layout, such as <strongid="b16943743133013"><aname="b16943743133013"></a><aname="b16943743133013"></a><div></strong>.</p>
</td>
</tr>
</tbody>
</table>
## Proportion<a name="section13725752194418"></a>
In a flex layout that does not support cross-row display, child components with the proportion style configured are always arranged with the set proportions in the container.
In a flex layout that does not support cross-row display, elements with the proportion style configured are always arranged with the set proportions in the container.
| Name | Type| Description|
| -------- | -------- | -------- |
| flex-weight | number | Size weight of a child component on the flex main axis. If this style is set for all child components in the container: Child component size = Container main axis size x flex-weight / Sum of size weights of all child components. If this style is set for only some child components in the container, the container first lays out the child components for which this style is not set and then allocates the remaining space to the set child components. Size of the set child component = Remaining space x flex-weight / Sum of size weights of all child components.|
<tdclass="cellrowborder"valign="top"width="59.5%"headers="mcps1.1.5.1.4 "><pid="p234101512916"><aname="p234101512916"></a><aname="p234101512916"></a>Size weight of an element on the flex main axis. </p>
<pid="p5749319913"><aname="p5749319913"></a><aname="p5749319913"></a>Element size = Container main axis size x <strongid="b37418311916"><aname="b37418311916"></a><aname="b37418311916"></a>flex-weight</strong> / Sum of all element size weights. </p>
<pid="p337111112521"><aname="p337111112521"></a><aname="p337111112521"></a>This style takes effect only when it is set for all elements in the container.</p>
</td>
</tr>
</tbody>
</table>
## Fixed Ratio<a name="section922215811557"></a>
## Fixed Ratio
A component with fixed ratio can be scaled up and down while retaining its aspect ratio.
A component with fixed ratio can be scaled up and down while retaining its aspect ratio.
| aspect-ratio | number | Aspect ratio of the component. The value is a floating-point value greater than 0.<br>The value is subjective to the upper and lower limits of the component size.<br>In a flex layout, the main axis size is adjusted first, based on which the cross axis size is adjusted.|
<tdclass="cellrowborder"valign="top"width="59.5%"headers="mcps1.1.5.1.4 "><pid="p12776121918313"><aname="p12776121918313"></a><aname="p12776121918313"></a>Aspect ratio of the component. The value is a floating-point value greater than 0.</p>
<pid="p3793145491117"><aname="p3793145491117"></a><aname="p3793145491117"></a>The value is subjective to the upper and lower limits of the component size.</p>
<pid="p15216164731415"><aname="p15216164731415"></a><aname="p15216164731415"></a>In a flex layout, the main axis size is adjusted first, based on which the cross axis size is adjusted.</p>
# Custom Font Styles<a name="EN-US_TOPIC_0000001173324599"></a>
# Custom Font Styles
**font-face** is used to define the font style. You can define **font-face** in **style** to specify a font name and resource for your application and then reference this font from **font-family**.
The custom font can be loaded from the font file in a project. The font file must be in .ttf or .otf format.
The custom font can be loaded from the font file in a project. The font file must be in .ttf or .otf format.
> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
## Defining @font-face
```
```
@font-face {
@font-face {
...
@@ -19,29 +22,31 @@ Customize a font.
...
@@ -19,29 +22,31 @@ Customize a font.
**src**
**src**
Supported sources of customized fonts:
Supported sources of custom fonts:
- Font file in the project: Specify the absolute path of the font file in the project through **url**. For details, see [File Access Rules](../../ui/js-framework-file.md).
- Font file in the project: Specify the path of the font file in the project through **url**. \(You can use absolute paths only. For details, see [Resources and File Access Rules](../../ui/js-framework-file.md#section6620355202117).\)
-You can set only one **src** attribute.
- You can set only one **src** attribute.
## Using font-face<a name="section713052011710"></a>
## Using font-face
You can set **font-face** in **style** and specify the name of the **font-face** using **font-family**.
You can set **font-face** in **style** and specify the name of the **font-face** using**font-family**.
**Example**
**Example**
Page layout:
Page layout:
```html
```
<!-- xxx.hml -->
<div>
<div>
<text class="demo-text">Test the customized font.</text>
<textclass="demo-text">Test the custom font.</text>
| flex-direction | string | row | No | Main axis direction of the flex container, which defines how items are placed in the container. Available values are as follows:<br>- **column**: Items are placed vertically from top to bottom.<br>- **row**: Items are placed horizontally from left to right.|
| flex-direction | string | row | No | Main axis direction of the flex container, which defines how items are placed in the container. Available values are as follows:<br>- **column**: Items are placed vertically from top to bottom.<br>- **row**: Items are placed horizontally from left to right.|
| flex-wrap | string | nowrap | No | Whether items in the flex container are displayed in a single line or multiple lines. The value cannot be dynamically updated. Available values are as follows:<br>- **nowrap**: Items are displayed on a single axis.<br>- **wrap**: Items are displayed on multiple axes.|
| flex-wrap | string | nowrap | No | Whether items in the flex container are displayed in a single line or multiple lines. The value cannot be dynamically updated. Available values are as follows:<br>- **nowrap**: Flex items are displayed in a single line.<br>- **wrap**: Flex items are displayed in multiple lines.|
| justify-content | string | flex-start | No | How items are aligned along the main axis of the flex container. Available values are as follows:<br>- **flex-start**: Items are packed towards the start row.<br>- **flex-end**: Items are packed towards the end row.<br>- **center**: Items are centered along the row.<br>- **space-between**: Items are positioned with space between the rows.<br>- **space-around**: Items are positioned with space before, between, and after the rows.<br>- **space-evenly**<sup>5+</sup>: Items are arranged with even space between each two.|
| justify-content | string | flex-start | No | How items are aligned along the main axis of the flex container. Available values are as follows:<br>- **flex-start**: Items are packed toward the start edge of the container along the main axis.<br>- **flex-end**: Items are packed toward the end edge of the container along the main axis.<br>- **center**: Items are packed toward the center of the container along the main axis.<br>- **space-between**: Items are positioned with space between the rows.<br>- **space-around**: Items are positioned with space before, between, and after the rows.<br>- **space-evenly**<sup>5+</sup>: Items are distributed within the container along the main axis, with even space between each two.|
| align-items | string | stretch<br>| No | How items are aligned along the cross axis of the flex container. Available values are as follows:<br>- **stretch**: Items are stretched to the same height or width as the container in the cross axis direction.<br>- **flex-start**: Items are aligned to the start of the cross axis.<br>- **flex-end**: Items are aligned to the end of the cross axis.<br>- **center**: Items are aligned in the center of the cross axis.|
| align-items | string | stretch<br>| No | How items are aligned along the cross axis of the flex container. Available values are as follows:<br>- **stretch**: Items are stretched to the same height or width as the container along the cross axis.<br>- **flex-start**: Items are packed toward the start edge of the cross axis.<br>- **flex-end**: Items are packed toward the end edge of the cross axis.<br>- **center**: Items are packed toward the center of the cross axis.<br>- **baseline**: In a vertical layout, items are aligned to the start of the cross axis, which means that this value is equivalent of **flex-start**. In a horizontal layout, items are aligned with the text baseline if there is text involved, and aligned to the bottom otherwise.|
| align-content | string | flex-start | No | Multi-row alignment mode when there is extra space in the cross axis. Available values are as follows:<br>- **flex-start**: All rows are packed towards the start of the cross axis. The start edge of the cross axis of the first row is aligned with the start edge of the cross axis of the container. All subsequent rows are aligned with the previous row.<br>- **flex-end**: All rows are packed towards the end of the cross axis. The end of the cross axis of the last row is aligned with the end of the cross axis of the container. All subsequent rows are aligned with the previous row.<br>- **center**: All rows are packed towards the center of the container. Rows are close to each other and aligned with the center of the container. The spacing between the start edge of the container's cross axis and the first row is equal to the spacing between the end edge of the container's cross axis and the last row.<br>- **space-between**: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The start and end edges of the container's cross axis are aligned with the edges of the first and last rows, respectively.<br>- **space-around**: All rows are evenly distributed in the container, and the spacing between two adjacent lines is the same. The spacing between the start edge of the container's cross axis and the first row and that between the end edge and the last row are half of the spacing between two adjacent rows.|
| align-content | string | flex-start | No | Multi-row alignment mode when there is extra space in the cross axis. Available values are as follows:<br>- **flex-start**: All rows are packed toward the start edge of the cross axis. The start edge of the cross axis of the first row is aligned with the start edge of the cross axis of the container. All subsequent rows are aligned with the previous row.<br>- **flex-end**: All rows are packed toward the end edge of the cross axis. The end of the cross axis of the last row is aligned with the end of the cross axis of the container. All subsequent rows are aligned with the previous row.<br>- **center**: All rows are packed toward the center of the cross axis. Rows are close to each other and aligned with the center of the container. The spacing between the start edge of the container's cross axis and the first row is equal to the spacing between the end edge of the container's cross axis and the last row.<br>- **space-between**: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The start and end edges of the container's cross axis are aligned with the edges of the first and last rows, respectively.<br>- **space-around**: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The spacing between the start edge of the container's cross axis and the first row and that between the end edge and the last row are half of the spacing between two adjacent rows.|
| display | string | flex | No | Type of the view box of the item. The value cannot be dynamically updated. Available values are as follows:<br>- **flex**: flexible layout.<br>- **grid**: grid layout.<br>- **none**: The box is disabled.<br>- **inline-flex**<sup>9+</sup>: layout with the **flex** and **inline-block** effects.|
| display | string | flex | No | Type of the view box of the item. The value cannot be dynamically updated. Available values are as follows:<br>- **flex**: flexible layout<br>- **grid**: grid layout<br>- **none**: not rendered<br>- **inline-flex**<sup>9+</sup>: layout with the **flex** and **inline-block** effects.|
| grid-template-[columns\|rows] | string | 1 row, 1 column | No | Number of rows and columns in the current grid layout. If this attribute is not set, one row and one column are displayed by default. This attribute is valid only when **display** is set to **grid**.<br>Below are some example values of **grid-template-columns**:<br>- **50px 100px 60px**: There are three columns. The first column is 50 px, the second column is 100 px, and the third column is 60 px.<br>- **1fr 1fr 2fr**: There are three columns, and the width allowed by the parent component is divided into four equal shares. The first column occupies one share, the second column occupies one share, and the third column occupies two shares.<br>- **30% 20% 50%**: There are three columns. The first column occupies 30% of the total width allowed by the parent component, the second column occupies 20%, and the third column occupies 50%.<br>- **repeat (2,100px)**: There are two columns. The first column is 100 px, and the second column is 100 px.<br>- **repeat(auto-fill,100px)**<sup>5+</sup>: Each column is 100 px and repeats to fill the cross axis. The number of columns is calculated based on the column size and the cross axis size.<br>- **auto 1fr 1fr**: There are three columns. The first column is adaptive to the width required by its child components. The remaining space is divided into two equal shares, one share occupied by each of the rest two columns.|
| grid-template-[columns\|rows] | string | 1 row, 1 column | No | Number of rows and columns in the current grid layout. If this attribute is not set, one row and one column are displayed by default. This attribute is valid only when **display** is set to **grid**.<br>Below are some example values of **grid-template-columns**:<br>- **50px 100px 60px**: There are three columns. The first column is 50 px, the second column is 100 px, and the third column is 60 px.<br>- **1fr 1fr 2fr**: There are three columns, and the width allowed by the parent component is divided into four equal shares. The first column occupies one share, the second column occupies one share, and the third column occupies two shares.<br>- **30% 20% 50%**: There are three columns. The first column occupies 30% of the total width allowed by the parent component, the second column occupies 20%, and the third column occupies 50%.<br>- **repeat (2,100px)**: There are two columns. The first column is 100 px, and the second column is 100 px.<br>- **repeat(auto-fill,100px)**<sup>5+</sup>: Each column is 100 px and repeats to fill the cross axis. The number of columns is calculated based on the column size and the cross axis size.<br>- **auto 1fr 1fr**: There are three columns. The first column is adaptive to the width required by its child components. The remaining space is divided into two equal shares, one share occupied by each of the rest two columns.|
| grid-[columns\|rows]-gap | \<length> | 0 | No | Size of the gap between two consecutive rows or columns in a grid layout. You can also use **grid-gap** to set the same size of the gap between rows and columns. This attribute is valid only when **display** is set to **grid**.|
| grid-[columns\|rows]-gap | <length> | 0 | No | Size of the gap between two consecutive rows or columns in a grid layout. You can also use **grid-gap** to set the same size of the gap between rows and columns. This attribute is valid only when **display** is set to **grid**.|
| grid-row-[start\|end] | number | - | No | Start and end row numbers of the current item in the grid layout. This attribute is valid only when the item's parent component is a **\<div>** container whose **display** style is set to **grid**.|
| grid-row-[start\|end] | number | - | No | Start and end row numbers of the current item in the grid layout. This attribute is valid only when the item's parent component is a **\<div>** container whose **display** style is set to **grid**.|
| grid-column-[start\|end] | number | - | No | Start and end column numbers of the current item in the grid layout. This attribute is valid only when the item's parent component is a **\<div>** container whose **display** style is set to **grid**.|
| grid-column-[start\|end] | number | - | No | Start and end column numbers of the current item in the grid layout. This attribute is valid only when the item's parent component is a **\<div>** container whose **display** style is set to **grid**.|
| grid-auto-flow<sup>5+</sup> | string | - | No | How grid items are laid out automatically. Available values are as follows:<br>- **row**: Elements are filled row by row. When there is no horizontal space in a row, a new row is added.<br>- **column**: Elements are filled column by column. When there is no vertical space in a column, a new column is added.|
| grid-auto-flow<sup>5+</sup> | string | - | No | How grid items are laid out automatically. Available values are as follows:<br>- **row**: Elements are filled row by row. When there is no horizontal space in a row, a new row is added.<br>- **column**: Elements are filled column by column. When there is no vertical space in a column, a new column is added.|
| overflow<sup>6+</sup> | string | visible | No | Display mode when the content exceeds the container size. Available values are as follows:<br>- **visible**: Displays the extra content outside the container.<br>- **hidden**: Truncates the excess content.<br>- **scroll**: Scrolls the content vertically, with a scrollbar provided.<br>**scroll** works for elements whose size is fixed. By default, the scrolling direction is the same as the container direction.|
| overflow<sup>6+</sup> | string | visible | No | Display mode when the content exceeds the container size. Available values are as follows:<br>- **visible**: Displays the excess content outside the container.<br>- **hidden**: Truncates the excess content.<br>- **scroll**: Scrolls the content vertically, with a scrollbar provided.<br>**scroll** works for elements whose size is fixed. By default, the scrolling direction is the same as the container direction.|
| align-items<sup>6+</sup> | string | - | No | How items are aligned along the cross axis in a flex container. Available values are as follows:<br>- **stretch**: Items are stretched to the same height or width as the container in the cross axis direction.<br>- **flex-start**: Items are aligned to the start of the cross axis.<br>- **flex-end**: Items are aligned to the end of the cross axis.<br>- **center**: Items are aligned in the center of the cross axis.<br>- **baseline**: In a vertical layout, items are aligned to the start of the cross axis, which means that this value is equivalent of **flex-start**. In a horizontal layout, items are aligned with the text baseline if there is text involved, and aligned to the bottom otherwise.|
| align-items<sup>6+</sup> | string | - | No | How items are aligned along the cross axis in a flex container. Available values are as follows:<br>- **stretch**: Items are stretched to the same height or width as the flex container along the cross axis.<br>- **flex-start**: Items are aligned to the start of the cross axis.<br>- **flex-end**: Items are aligned to the end of the cross axis.<br>- **center**: Items are aligned in the center of the cross axis.<br>- **baseline**: In a vertical layout, items are aligned to the start of the cross axis, which means that this value is equivalent of **flex-start**. In a horizontal layout, items are aligned with the text baseline if there is text involved, and aligned to the bottom otherwise.|
| scrollbar-color<sup>6+</sup> | \<color> | - | No | Color of the scrollbar. |
| scrollbar-color<sup>6+</sup> | <color> | - | No | Color of the scrollbar. |
| scrollbar-width<sup>6+</sup> | \<length> | - | No | Width of the scrollbar. |
| scrollbar-width<sup>6+</sup> | <length> | - | No | Width of the scrollbar. |
| overscroll-effect<sup>6+</sup> | string | - | No | How the scrollbar behaves when it reaches the edge of the scrolling area. Available values are as follows:<br>- **spring**: Similar to the physical dynamic effect of a spring. After scrolling to the edge, you can continue to scroll for a distance based on the initial speed or by touching the knob of the scrollbar. After you release your hand, the knob is rebounded.<br>- **fade**: Similar to the physical dynamic effect of fade. When you scroll to the edge, a wave shape fades. The fade changes according to the speed and scrolling distance.<br>- **none**: No effect after the scroll bar is moved to the edge.|
| overscroll-effect<sup>6+</sup> | string | - | No | How the scrollbar behaves when it reaches the edge of the scrolling area. Available values are as follows:<br>- **spring**: Similar to the physical dynamic effect of a spring. When the scrollbar reaches the edge, it can continue to scroll for a distance based on the initial speed or a touch event. It rebounds after being released.<br>- **fade**: Similar to the physical dynamic effect of fade. When the scrollbar reaches the edge, a wave shape fades. The fade changes according to the speed and scrolling distance.<br>- **none**: No effect when the scrollbar reaches the edge.|
## Events
## Events
...
@@ -59,7 +61,7 @@ In addition to the [universal events](../arkui-js/js-components-common-events.md
...
@@ -59,7 +61,7 @@ In addition to the [universal events](../arkui-js/js-components-common-events.md
In addition to the [universal methods](js-components-common-methods.md), the following methods are supported.
In addition to the [universal methods](js-components-common-methods.md), the following methods are supported.
| getScrollOffset<sup>6+</sup> | - | ScrollOffset | Obtains the scrolling offset of the element content.<br>To use this method, **overflow** must be set to **scroll**.|
| getScrollOffset<sup>6+</sup> | - | ScrollOffset | Obtains the scrolling offset of the element content.<br>To use this method, **overflow** must be set to **scroll**.|
| scrollBy<sup>6+</sup> | ScrollParam | - | Sets the scrolling offset of the element content.<br>To use this method, **overflow** must be set to **scroll**.|
| scrollBy<sup>6+</sup> | ScrollParam | - | Sets the scrolling offset of the element content.<br>To use this method, **overflow** must be set to **scroll**.|
**<tab-content\>** is a child component of [<tabs\>](js-components-container-tabs.md) and is used to provide the area for displaying the tab content. By default, its height is such that all the remaining space of the **<tabs\>** component is filled. The child components are arranged horizontally. When **<tab-content\>** is used as a child element in a container, the length on the main axis direction must be specified. Otherwise, the child element cannot be displayed.
**<tab-content\>**is a child component of **[<tabs\>](js-components-container-tabs.md)** and is used to provide the area for displaying the tab content. By default, its height is such that all the remaining space of the **<tabs\>** component is filled. The child components are arranged horizontally. When **<tab-content\>** is used as a child element in a container, its length along the main axis must be specified. Otherwise, it cannot be displayed.
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p1062618163010"><aname="p1062618163010"></a><aname="p1062618163010"></a>Whether the tabs can be switched by swiping left or right. The default value is <strongid="b84843195512"><aname="b84843195512"></a><aname="b84843195512"></a>true</strong>. If this attribute is set to <strongid="b1775133913552"><aname="b1775133913552"></a><aname="b1775133913552"></a>false</strong>, tab switching is implemented only through the association with <strongid="b6395111416560"><aname="b6395111416560"></a><aname="b6395111416560"></a>tab-bar</strong>.</p>
</td>
</tr>
</tbody>
</table>
## Styles<a name="section15751323144115"></a>
Styles in [Universal Styles](js-components-common-styles.md) are supported.
Events in [Universal Events](js-components-common-events.md) are supported.
## Example<a name="section11929165914411"></a>
For details, see the [tabs example code](js-components-container-tabs.md#section14993155318710).
## Attributes
In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported.
| Name | Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| scrollable | boolean | No| Whether the tabs can be switched by swiping left or right. The default value is **true**. If this attribute is set to **false**, tab switching is implemented only through the association with **tab-bar**.|
## Styles
The [universal styles](../arkui-js/js-components-common-styles.md) are supported.
## Events
The [universal events](../arkui-js/js-components-common-events.md) are supported.
## Example
For details, see **Example** in [tabs](../arkui-js/js-components-container-tabs.md#example).
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="a1a1731af05554f119fa365748f276bb2"><aname="a1a1731af05554f119fa365748f276bb2"></a><aname="a1a1731af05554f119fa365748f276bb2"></a>Unique ID of the component.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p62121758111517"><aname="p62121758111517"></a><aname="p62121758111517"></a>X-coordinate of the circle center. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p125961416161611"><aname="p125961416161611"></a><aname="p125961416161611"></a>Y-coordinate of the circle center. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p78950185420"><aname="p78950185420"></a><aname="p78950185420"></a>Radius of the circle. Attribute animations are supported.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section360556124815"></a>
```
## Child Components
The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported.
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="a1a1731af05554f119fa365748f276bb2"><aname="a1a1731af05554f119fa365748f276bb2"></a><aname="a1a1731af05554f119fa365748f276bb2"></a>Unique ID of the component.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p62121758111517"><aname="p62121758111517"></a><aname="p62121758111517"></a>X-coordinate of the oval shape. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p125961416161611"><aname="p125961416161611"></a><aname="p125961416161611"></a>Y-coordinate of the oval shape. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p78950185420"><aname="p78950185420"></a><aname="p78950185420"></a>Radius of the oval shape on the x-axis. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p107241750205414"><aname="p107241750205414"></a><aname="p107241750205414"></a>Radius of the oval shape on the y-axis. Attribute animations are supported.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section360556124815"></a>
```
## Child Components
The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported.
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="a1a1731af05554f119fa365748f276bb2"><aname="a1a1731af05554f119fa365748f276bb2"></a><aname="a1a1731af05554f119fa365748f276bb2"></a>Unique ID of the component.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p62121758111517"><aname="p62121758111517"></a><aname="p62121758111517"></a>X-coordinate of the start point of the line. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p125961416161611"><aname="p125961416161611"></a><aname="p125961416161611"></a>Y-coordinate of the start point of the line. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p78950185420"><aname="p78950185420"></a><aname="p78950185420"></a>X-coordinate of the end point of the line. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p107241750205414"><aname="p107241750205414"></a><aname="p107241750205414"></a>Y-coordinate of the end point of the line. Attribute animations are supported.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section360556124815"></a>
```
## Child Components
The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported.
// square: At the end of each path the stroke is extended by a half circle, with the width being equal to half of the stroke width, and the height being equal to the stroke width.
**animate**, **animateMotion**, and **animateTransform** are supported.
## Attributes<a name="section2907183951110"></a>
The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. The configured universal attributes are passed to the child components.
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="a1a1731af05554f119fa365748f276bb2"><aname="a1a1731af05554f119fa365748f276bb2"></a><aname="a1a1731af05554f119fa365748f276bb2"></a>Unique ID of the component.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="adbe7ecbee96b4f938b04a4b8d62791bf"><aname="adbe7ecbee96b4f938b04a4b8d62791bf"></a><aname="adbe7ecbee96b4f938b04a4b8d62791bf"></a>Shape of the path. The value contains a group of character instructions. Uppercase letters are absolute paths, and lowercase letters are relative paths.</p>
<pid="p46751932620"><aname="p46751932620"></a><aname="p46751932620"></a>The meanings of the letters are as follows:</p>
The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. The configured universal attributes are passed to the child components.
| id | string | - | No| Unique ID of the component.|
| d | string | - | No| Shape of the path. The value contains a group of character instructions. Uppercase letters are absolute paths, and lowercase letters are relative paths.<br>The meanings of the letters are as follows:<br>- M/m = moveto<br>- L/l = lineto<br>- H/h = horizontal lineto<br>- V/v = vertical lineto<br>- C/c = curveto<br>- S/s = smooth curveto<br>- Q/q = quadratic Belzier curve<br>- T/t = smooth quadratic Belzier curveto<br>- A/a = elliptical Arc<br>- Z/z = closepath |
## Example
```html
<!-- xxx.hml -->
<!-- xxx.hml -->
<divclass="container">
<divclass="container">
<svgwidth="400"height="400">
<svgwidth="400"height="400">
...
@@ -70,5 +39,5 @@ The [universal attributes](js-components-svg-common-attributes.md) and the att
...
@@ -70,5 +39,5 @@ The [universal attributes](js-components-svg-common-attributes.md) and the att
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="a1a1731af05554f119fa365748f276bb2"><aname="a1a1731af05554f119fa365748f276bb2"></a><aname="a1a1731af05554f119fa365748f276bb2"></a>Unique ID of the component.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="adbe7ecbee96b4f938b04a4b8d62791bf"><aname="adbe7ecbee96b4f938b04a4b8d62791bf"></a><aname="adbe7ecbee96b4f938b04a4b8d62791bf"></a>Multiple coordinates of the polygon.</p>
<pid="p158933814449"><aname="p158933814449"></a><aname="p158933814449"></a>The format is [x1,y1 x2,y2 x3,y3].</p>
<pid="p78913383449"><aname="p78913383449"></a><aname="p78913383449"></a>Attribute animations are supported. If the number of coordinates of the animation change value set in the attribute animation is different from the format of the original points, the attribute animation is invalid.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section360556124815"></a>
```
## Child Components
The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported.
| id | string | - | No| Unique ID of the component.|
| points | string | - | No| Multiple coordinates of the polygon.<br>The format is [x1,y1 x2,y2 x3,y3].<br>Attribute animations are supported. If the number of coordinates of the animation change value set in the attribute animation is different from the format of the original points, the attribute animation is invalid.|
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="a1a1731af05554f119fa365748f276bb2"><aname="a1a1731af05554f119fa365748f276bb2"></a><aname="a1a1731af05554f119fa365748f276bb2"></a>Unique ID of the component.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="adbe7ecbee96b4f938b04a4b8d62791bf"><aname="adbe7ecbee96b4f938b04a4b8d62791bf"></a><aname="adbe7ecbee96b4f938b04a4b8d62791bf"></a>Multiple coordinates of the polyline.</p>
<pid="p14934164010422"><aname="p14934164010422"></a><aname="p14934164010422"></a>The format is [x1,y1 x2,y2 x3,y3].</p>
<pid="p8934164015424"><aname="p8934164015424"></a><aname="p8934164015424"></a>Attribute animations are supported. If the number of coordinates of the animation change value set in the attribute animation is different from the format of the original points, the attribute animation is invalid.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section360556124815"></a>
```
## Child Components
The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported.
| id | string | - | No| Unique ID of the component.|
| points | string | - | No| Multiple coordinates of the polyline.<br>The format is [x1,y1 x2,y2 x3,y3].<br>Attribute animations are supported. If the number of coordinates of the animation change value set in the attribute animation is different from the format of the original points, the attribute animation is invalid.|
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="a1a1731af05554f119fa365748f276bb2"><aname="a1a1731af05554f119fa365748f276bb2"></a><aname="a1a1731af05554f119fa365748f276bb2"></a>Unique ID of the component.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="adbe7ecbee96b4f938b04a4b8d62791bf"><aname="adbe7ecbee96b4f938b04a4b8d62791bf"></a><aname="adbe7ecbee96b4f938b04a4b8d62791bf"></a>Width of a rectangle. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p64638784216"><aname="p64638784216"></a><aname="p64638784216"></a>Height of a rectangle. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p62121758111517"><aname="p62121758111517"></a><aname="p62121758111517"></a>X-coordinate of the upper left corner of the rectangle. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p125961416161611"><aname="p125961416161611"></a><aname="p125961416161611"></a>Y-coordinate of the upper left corner of the rectangle. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p78950185420"><aname="p78950185420"></a><aname="p78950185420"></a>Radius of the rectangle rounded corner in the x-axis direction. Attribute animations are supported.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p107241750205414"><aname="p107241750205414"></a><aname="p107241750205414"></a>Radius of the rectangle rounded corner in the y-axis direction. Attribute animations are supported.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section360556124815"></a>
```
## Child Components
The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported.
| id | string | - | No| Unique ID of the component.|
| width | <length>\|<percentage> | 0 | No| Width of the rectangle. Attribute animations are supported.|
| height | <length>\|<percentage> | 0 | No| Height of the rectangle. Attribute animations are supported.|
| x | <length>\|<percentage> | 0 | No| X-coordinate of the upper left corner of the rectangle. Attribute animations are supported.|
| y | <length>\|<percentage> | 0 | No| Y-coordinate of the upper left corner of the rectangle. Attribute animations are supported.|
| rx | <length>\|<percentage> | 0 | No| Radius of the rectangle rounded corner in the x-axis direction. Attribute animations are supported.|
| ry | <length>\|<percentage> | 0 | No| Radius of the rectangle rounded corner in the y-axis direction. Attribute animations are supported.|
## Example
```html
<!-- xxx.hml -->
<!-- xxx.hml -->
<divclass="container">
<divclass="container">
<svgfill="white"width="400"height="400">
<svgfill="white"width="400"height="400">
...
@@ -125,5 +47,5 @@ The [universal attributes](js-components-svg-common-attributes.md) and the att
...
@@ -125,5 +47,5 @@ The [universal attributes](js-components-svg-common-attributes.md) and the att
@@ -4,6 +4,7 @@ The **\<text>** component is used to display a piece of textual information.
...
@@ -4,6 +4,7 @@ The **\<text>** component is used to display a piece of textual information.
> **NOTE**
> **NOTE**
>
> - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
> - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
>
>
> - The text content must be written in the content area. The **tspan** sub-element label can be nested to segment the text content. The **textPath** sub-element label can be nested to draw the text content based on the specified path.
> - The text content must be written in the content area. The **tspan** sub-element label can be nested to segment the text content. The **textPath** sub-element label can be nested to draw the text content based on the specified path.
...
@@ -19,7 +20,7 @@ None
...
@@ -19,7 +20,7 @@ None
## Child Components
## Child Components
The **\<tspan>**, **\<textPath>**, **\<animate>**, and **\<animateTransform>** child components are supported.
The following are supported: [\<tspan>](js-components-svg-tspan.md), [\<textpath>](js-components-svg-textpath.md), [\<animate>](js-components-svg-animate.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
## Attributes
...
@@ -29,16 +30,16 @@ The attributes in the following table are supported.
...
@@ -29,16 +30,16 @@ The attributes in the following table are supported.
| Name | Type | Default Value | Mandatory | Description |
| Name | Type | Default Value | Mandatory | Description |
| id | string | - | No | Unique ID of the component. |
| id | string | - | No | Unique ID of the component. |
| x | <length>\|<percentage> | 0 | No | X-coordinate of the upper left corner of the component. |
| x | <length>\|<percentage> | 0 | No | X-coordinate of the upper left corner of the component. |
| y | <length>\|<percentage> | 0 | No | Y-coordinate of the upper left corner of the component. |
| y | <length>\|<percentage> | 0 | No | Y-coordinate of the upper left corner of the component. |
| dx | <length>\|<percentage> | 0 | No | Offset of the text on the x-axis. |
| dx | <length>\|<percentage> | 0 | No | Offset of the text on the x-axis. |
| dy | <length>\|<percentage> | 0 | No | Offset of the text on the y-axis. |
| dy | <length>\|<percentage> | 0 | No | Offset of the text on the y-axis. |
| rotate | number | 0 | No | Rotation of the text around its lower left corner. A positive number indicates clockwise rotation, and a negative number indicates counterclockwise rotation. |
| rotate | number | 0 | No | Rotation of the text around its lower left corner. A positive number indicates clockwise rotation, and a negative number indicates counterclockwise rotation. |
| font-size | <length> | 30px | No | Font size. |
| font-size | <length> | 30px | No | Font size. |
| fill | <color> | black | No | Fill color of the text. |
| fill | <color> | black | No | Fill color of the text. |
| fill-opacity | number | 1.0 | No | Fill opacity of the text. |
| fill-opacity | number | 1.0 | No | Fill opacity of the text. |
| opacity | number | 1 | No | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. Attribute animations are supported.|
| opacity | number | 1 | No | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. Attribute animations are supported.|
| stroke | <color> | black | No | Stroke and stroke color. |
| stroke | <color> | black | No | Stroke color. |
| stroke-width | number | 1px | No | Stroke width. |
| stroke-width | number | 1px | No | Stroke width. |
| stroke-opacity | number | 1.0 | No | Stroke opacity. |
| stroke-opacity | number | 1.0 | No | Stroke opacity. |
The **<svg\>** component is a basic container. It can be used as the root node of an SVG document or be used to nest an SVG fragment into an SVG document.
The **\<svg>** component is a basic container. It can be used as the root node of an SVG document or be used to nest an SVG fragment into an SVG document.
**svg**, **rect**, **circle**, **ellipse**, **path**, **line**, **polygon**, **polyline**, **text**, **animate**, and **animateTransform** are supported.
## Attributes<a name="section2907183951110"></a>
The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. The configured universal attributes are passed to the child components.
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="a1a1731af05554f119fa365748f276bb2"><aname="a1a1731af05554f119fa365748f276bb2"></a><aname="a1a1731af05554f119fa365748f276bb2"></a>Unique ID of the component.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p62121758111517"><aname="p62121758111517"></a><aname="p62121758111517"></a>X-coordinate of the current <strongid="b2724124631610"><aname="b2724124631610"></a><aname="b2724124631610"></a><svg></strong> component. The settings do not work for the root <strongid="b172085410165"><aname="b172085410165"></a><aname="b172085410165"></a><svg></strong> node.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p125961416161611"><aname="p125961416161611"></a><aname="p125961416161611"></a>Y-coordinate of the current <strongid="b122841519181716"><aname="b122841519181716"></a><aname="b122841519181716"></a><svg></strong> component. The settings do not work for the root <strongid="b4285131991713"><aname="b4285131991713"></a><aname="b4285131991713"></a><svg></strong> node.</p>
<tdclass="cellrowborder"valign="top"width="35.76%"headers="mcps1.1.6.1.5 "><pid="p740434541717"><aname="p740434541717"></a><aname="p740434541717"></a>View box of the current <strongid="b1055718459177"><aname="b1055718459177"></a><aname="b1055718459177"></a><svg></strong> component. The supported format is <strongid="b166865102189"><aname="b166865102189"></a><aname="b166865102189"></a><number number number number></strong>. The four parameters indicate the <strongid="b2507112919184"><aname="b2507112919184"></a><aname="b2507112919184"></a>min-x</strong>, <strongid="b11665531141816"><aname="b11665531141816"></a><aname="b11665531141816"></a>min-y</strong>, <strongid="b6237133461814"><aname="b6237133461814"></a><aname="b6237133461814"></a>width</strong>, and <strongid="b1424418412185"><aname="b1424418412185"></a><aname="b1424418412185"></a>height</strong>. The width and height of the view box are different from those of the <strongid="b53631556121813"><aname="b53631556121813"></a><aname="b53631556121813"></a><svg></strong> component. The view box is scaled in center-aligned mode.</p>
</td>
</tr>
</tbody>
</table>
## Example<a name="section360556124815"></a>
```
## Child Components
The following are supported: [\<svg>](js-components-svg.md), [\<rect>](js-components-svg-rect.md), [\<circle>](js-components-svg-circle.md), [\<ellipse>](../arkui-js/js-components-svg-ellipse.md), [\<path>](js-components-svg-path.md), [\<line](../arkui-js/js-components-svg-line.md), [\<polygon>](../arkui-js/js-components-svg-polygon.md), [\<polyline>](js-components-svg-polyline.md), [\<text>](js-components-svg-text.md), [\<animate>](js-components-svg-animate.md), and [\<animateTransform>](js-components-svg-animateTransform.md).
## Attributes
The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported. The configured universal attributes are passed to the child components.
| x | <length>\|<percentage> | - | No| X-coordinate of the current **\<svg>** component. The settings do not work for the root **\<svg>** node. |
| y | <length>\|<percentage> | | No| Y-coordinate of the current **\<svg>** component. The settings do not work for the root **\<svg>** node. |
| viewBox | string | - | No| View box of the current **\<svg>** component. The supported format is \<number number number number>. The four parameters indicate **min-x**, **min-y**, **width**, and **height**, respectively. The width and height of the view box are different from those of the **\<svg>** component. The view box is scaled in center-aligned mode. |
## Example
```html
<!-- xxx.hml -->
<!-- xxx.hml -->
<divclass="container">
<divclass="container">
<svgwidth="400"height="400">
<svgwidth="400"height="400">
...
@@ -119,5 +52,5 @@ The [universal attributes](js-components-svg-common-attributes.md) and the att
...
@@ -119,5 +52,5 @@ The [universal attributes](js-components-svg-common-attributes.md) and the att
You can use **@Preview** to decorate a custom component so that it can be previewed in real time in DevEco Studio. This component is created and displayed when the page where it is located is loaded. Dynamic pictures and dynamic preview are not yet supported.
You can use @Preview to decorate a custom component so that it can be previewed in DevEco Studio. This component is created and displayed when the page where it is located is loaded.
> **NOTE**
> **NOTE**
>
>
> In a source file, at most one custom component can be decorated by @Preview.
> In a source file, at most 10 custom components can be decorated by **@Preview**. For details, see [@Preview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-previewing-app-service-0000001218760596#section146052489820).
The lifecycle callbacks of a custom component are used to notify users of the lifecycle of the component. These callbacks are private and are invoked by the development framework at a specified time at runtime. They cannot be manually invoked from applications.
The lifecycle callbacks of a custom component are used to notify users of the lifecycle of the component. These callbacks are private and are invoked by the development framework at a specified time at runtime. They cannot be manually invoked from applications.
| aboutToAppear | Invoked after a new instance of the custom component is created and before its build function is executed. You can change state variables in the **aboutToAppear** function. The change will take effect when you execute the **build** function next time. |
| aboutToAppear | Invoked after a new instance of the custom component is created and before its **build** function is executed. You can change state variables in the **aboutToAppear** function. The change will take effect when you execute the **build** function next time.|
| aboutToDisappear | Invoked before the destructor of the custom component is consumed. Do not change state variables in the **aboutToDisappear** function as doing this can cause unexpected errors. For example, the modification of the **@Link** decorated variable may cause unstable application running.|
| aboutToDisappear | Invoked before the destructor of the custom component is consumed. Do not change state variables in the **aboutToDisappear** function as doing this can cause unexpected errors. For example, the modification of the **@Link** decorated variable may cause unstable application running.|
| onPageShow | Invoked when a page is displayed. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by **@Entry** take effect. |
| onPageShow | Invoked when a page is displayed. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by **@Entry** take effect.|
| onPageHide | Invoked when a page is hidden. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by **@Entry** take effect. |
| onPageHide | Invoked when a page is hidden. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by **@Entry** take effect.|
| onBackPress | Invoked when a user clicks the back button. Only the custom components decorated by **@Entry** take effect.<br/>- The value **true** is returned if the page processes the return logic instead of performing page routing.<br/>- The value **false** is returned if the default return logic is used.<br/>- If no value is returned, the default return logic is used. |
| onBackPress | Invoked when a user clicks the back button. Only the custom components decorated by **@Entry** take effect.<br>The value **true** is returned if the page processes the return logic instead of performing page routing.<br>The value **false** is returned if the default return logic is used.<br>If no value is returned, the default return logic is used.|
The example above shows that lifecycle functions are critical for CountDownTimerComponent to manage its timer resources. Similar functions include loading resources asynchronously from the network.
The example above shows that lifecycle functions are critical for **CountDownTimerComponent** to manage its timer resources. Similar functions include loading resources asynchronously from the network.
> **NOTE**
> **NOTE**
>
> - Promise and asynchronous callback functions can be used in lifecycle functions, for example, network resource getters and timer setters.
> - Promise and asynchronous callback functions can be used in lifecycle functions, for example, network resource getters and timer setters.
>
>
> - Do not use **async await** in lifecycle functions.
> - Do not use **async await** in lifecycle functions.
@@ -8,7 +8,7 @@ As a tool to provide layout auxiliary lines, the grid system is handy in graphic
...
@@ -8,7 +8,7 @@ As a tool to provide layout auxiliary lines, the grid system is handy in graphic
2. Provides a unified positioning method for the system to ensure layout consistency among modules on different devices.
2. Provides a unified positioning method for the system to ensure layout consistency among modules on different devices.
3. Provides a flexible spacing adjustment method for applications to keep up with layout in special scenarios.
3. Provides a flexible spacing adjustment method for applications to keep up with layout in special scenarios.
To implement grid layout, the declarative paradigm provides the [GridContainer](../reference/arkui-ts/ts-container-gridcontainer.md) grid container component, which works with the common attribute useSizeType of its subcomponents to implement grid layout.
To implement grid layout, the declarative paradigm provides the [\<GridContainer>](../reference/arkui-ts/ts-container-gridcontainer.md) component, which works with the **useSizeType** attribute of its child components to implement grid layout.
## Grid System
## Grid System
...
@@ -19,10 +19,15 @@ The grid system works in terms of gutter, margin, and column.
...
@@ -19,10 +19,15 @@ The grid system works in terms of gutter, margin, and column.
1. Gutter:
1. Gutter:
Spacing between elements. You can define different clutter values for different device sizes as part of the overall grid layout specifications. For better results, make sure the gutter is not greater than the margin.
Spacing between elements. You can define different clutter values for different device sizes as part of the overall grid layout specifications. For better results, make sure the gutter is not greater than the margin.
2. Margin:
2. Margin:
Spacing around an item in the grid container. You can define different margin values for different device sizes as part of the overall grid layout specifications.
Spacing around an item in the grid container. You can define different margin values for different device sizes as part of the overall grid layout specifications.
3. Column:
3. Column:
Main tool for positioning items in the grid layout. The grid container is divided into various numbers of columns based on the device size. The width per column is calculated based on the total number of columns while respecting the margin and clutter specifications.
Main tool for positioning items in the grid layout. The grid container is divided into various numbers of columns based on the device size. The width per column is calculated based on the total number of columns while respecting the margin and clutter specifications.
...
@@ -30,7 +35,7 @@ The grid system works in terms of gutter, margin, and column.
...
@@ -30,7 +35,7 @@ The grid system works in terms of gutter, margin, and column.
Breakpoints in the grid system are set in terms of the device's screen pixel density. The grid system defines a set of breakpoint rules based on the mapping between the numbers of columns and device screen widths.
Breakpoints in the grid system are set in terms of the device's screen pixel density. The grid system defines a set of breakpoint rules based on the mapping between the numbers of columns and device screen widths.
Depending on the screen width, devices are classified into different width types. The table below provides the mappings of the grid breakpoint ranges, device width types, default total number of columns, margins, and gutters.
Depending on the screen width, devices are classified into different width types. The table below provides the mappings of the grid breakpoint ranges, device width types, default total number of columns, margin, and gutter.
@@ -48,13 +53,15 @@ Create a grid container, define the grid layout, and set the number of columns f
...
@@ -48,13 +53,15 @@ Create a grid container, define the grid layout, and set the number of columns f
Use the `GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeType, gutter?: Length, margin?: Length})` API to create a grid container. All child components in the grid container follow the grid layout.
Use the `GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeType, gutter?: Length, margin?: Length})` API to create a grid container. All child components in the grid container follow the grid layout.
- Use the **columns**, **gutter**, and **margin** parameters to define your grid layout. In the sample below, the grid container is divided into six columns, with the gutter (spacing between columns) of 10 vp and the margin (spacing around a column) of 20 vp.
- Use the **columns**, **gutter**, and **margin** parameters to define your grid layout.
In the example below, the grid container is divided into six columns, with the gutter (spacing between columns) of 10 vp and the margin (spacing around a column) of 20 vp.
```ts
```ts
GridContainer({columns:6,gutter:10,margin:20}){}
GridContainer({columns:6,gutter:10,margin:20}){}
```
```
In the sample below, the grid container does not have any parameter set. In this case, it follows the default layout, as in the case when sizeType is set to SizeType.Auto.
In the example below, the grid container does not have any parameter set. In this case, it follows the default layout, as in the case when **sizeType** is set to **SizeType.Auto**.
```ts
```ts
GridContainer(){}
GridContainer(){}
...
@@ -62,7 +69,7 @@ Use the `GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeTyp
...
@@ -62,7 +69,7 @@ Use the `GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeTyp
On a small-sized device (**SizeType.SM**), the grid container is divided into four columns by default, with the gutter of 24 vp and the margin of 24 vp. On a medium-sized device (**SizeType.MD**), the grid container is divided into eight columns by default, with the gutter of 24 vp and the margin of 32 vp.
On a small-sized device (**SizeType.SM**), the grid container is divided into four columns by default, with the gutter of 24 vp and the margin of 24 vp. On a medium-sized device (**SizeType.MD**), the grid container is divided into eight columns by default, with the gutter of 24 vp and the margin of 32 vp.
- You can also use **sizeType** to configure child components in the grid container to follow the grid settings for a specific device width type, as shown below:
- You can also use **sizeType** to configure child components in the grid container to follow the grid settings of a specific device width type, as shown below:
```ts
```ts
GridContainer({sizeType:SizeType.SM}){
GridContainer({sizeType:SizeType.SM}){
...
@@ -70,7 +77,7 @@ Use the `GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeTyp
...
@@ -70,7 +77,7 @@ Use the `GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeTyp
Text('1')
Text('1')
.useSizeType({
.useSizeType({
xs:{span:2,offset:0},
xs:{span:2,offset:0},
sm:{span:2,offset:0},
sm:{span:3,offset:0},
md:{span:6,offset:2},
md:{span:6,offset:2},
lg:{span:8,offset:2},
lg:{span:8,offset:2},
})
})
...
@@ -78,11 +85,11 @@ Use the `GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeTyp
...
@@ -78,11 +85,11 @@ Use the `GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeTyp
}
}
```
```
In the preceding example, the **\<Text>** component uses the grid setting of the **SizeType.SM** type regardless of the actual width type of the device. That is, the **\<Text>** component occupies three columns and is placed in the first column.
In the preceding example, the **\<Text>** component uses the grid settings of the **SizeType.SM** type regardless of the actual device width type. That is, the **\<Text>** component takes up three columns and is placed in the first column.
### Grid Settings of Child Components in the Grid Container
### Grid Settings of Child Components in the Grid Container
Use the universal attribute **useSizeType** to configure the positioning of child components in the grid container. **span** indicates the number of columns occupied by the child component.**offset** indicates the column offset, that is, the column where the component is located. The sample code is as follows:
Use the universal attribute **useSizeType** to configure how child components are positioned in the grid container. **useSizeType** comes with the **span** and **offset** sub-attributes. **span** indicates the number of columns occupied by the child component;**offset** indicates the column offset, that is, the column where the component is located. The sample code is as follows:
```ts
```ts
GridContainer(){
GridContainer(){
...
@@ -90,16 +97,16 @@ GridContainer() {
...
@@ -90,16 +97,16 @@ GridContainer() {
Text('1')
Text('1')
.useSizeType({
.useSizeType({
xs:{span:2,offset:0},
xs:{span:2,offset:0},
sm:{span:0,offset:0},
sm:{span:2,offset:0},
md:{span:6,offset:2},
md:{span:6,offset:2},
lg:{span:8,offset:2},
lg:{span:8,offset:2},
})
})
}
}
}
}
```
```
In the preceding example, `sm: { span: 2, offset: 0 }` indicates that on a medium-sized device, the **\<Text>** component occupies two columns and is placed in the first column of the grid container.
In the preceding example, `sm: { span: 2, offset: 0 }` indicates that on a medium-sized device, the **\<Text>** component takes up two columns and is placed in the first column of the grid container.