• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Stack
2
3The **\<Stack>** component provides a stack container where child components are successively stacked and the latter one overwrites the previous one.
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
9
10## Child Components
11
12Supported
13
14
15## APIs
16
17Stack(value?: { alignContent?: Alignment })
18
19Since API version 9, this API is supported in ArkTS widgets.
20
21**Parameters**
22
23| Name      | Type                                   | Mandatory| Description                                                   |
24| ------------ | ------------------------------------------- | ---- | ----------------------------------------------------------- |
25| alignContent | [Alignment](ts-appendix-enums.md#alignment) | No  | Alignment of child components in the container.<br>Default value: **Alignment.Center**|
26
27
28## Example
29
30```ts
31// xxx.ets
32@Entry
33@Component
34struct StackExample {
35  build() {
36    Stack({ alignContent: Alignment.Bottom }) {
37      Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top)
38      Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top)
39    }.width('100%').height(150).margin({ top: 5 })
40  }
41}
42```
43
44![en-us_image_0000001219982699](figures/en-us_image_0000001219982699.PNG)
45