--- title: Stack description: >- The `Stack` component organizes elements horizontally or vertically along the block or inline axis. Use it to structure layouts, group related components, or control spacing between elements with flexible alignment options. The component simplifies layout creation by automatically managing spacing between child elements through gap properties, eliminating the need for manual margin management. It supports both horizontal and vertical arrangements, flexible alignment options, and wrapping behavior, making it the foundation for building consistent, responsive layouts throughout POS extensions. `Stack` components support responsive gap values that automatically adjust spacing based on screen size, ensuring layouts remain visually balanced and maintain proper element separation across different devices. api_version: 2025-07 api_name: pos-ui-extensions source_url: html: >- https://shopify.dev/docs/api/pos-ui-extensions/2025-07/ui-components/layout-and-structure/stack md: >- https://shopify.dev/docs/api/pos-ui-extensions/2025-07/ui-components/layout-and-structure/stack.md --- # Stack The `Stack` component organizes elements horizontally or vertically along the block or inline axis. Use it to structure layouts, group related components, or control spacing between elements with flexible alignment options. The component simplifies layout creation by automatically managing spacing between child elements through gap properties, eliminating the need for manual margin management. It supports both horizontal and vertical arrangements, flexible alignment options, and wrapping behavior, making it the foundation for building consistent, responsive layouts throughout POS extensions. `Stack` components support responsive gap values that automatically adjust spacing based on screen size, ensuring layouts remain visually balanced and maintain proper element separation across different devices. Support Targets (16) ### Supported targets * [pos.​cart.​line-item-details.​action.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/cart-details#cart-details-action-modal-) * [pos.​customer-details.​action.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/customer-details#customer-details-action-modal-) * [pos.​customer-details.​block.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/customer-details#customer-details-block-) * [pos.​draft-order-details.​action.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/draft-order-details#draft-order-details-action-modal-) * [pos.​draft-order-details.​block.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/draft-order-details#draft-order-details-block-) * [pos.​exchange.​post.​action.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/post-exchange#post-exchange-action-modal-) * [pos.​exchange.​post.​block.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/post-exchange#post-exchange-block-) * [pos.​home.​modal.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/home-screen#home-screen-action-modal-) * [pos.​order-details.​action.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/order-details#order-details-action-modal-) * [pos.​order-details.​block.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/order-details#order-details-block-) * [pos.​product-details.​action.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/product-details#product-details-action-modal-) * [pos.​product-details.​block.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/product-details#product-details-block-) * [pos.​purchase.​post.​action.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/post-purchase#post-purchase-action-modal-) * [pos.​purchase.​post.​block.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/post-purchase#post-purchase-block-) * [pos.​return.​post.​action.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/post-return#post-return-action-modal-) * [pos.​return.​post.​block.​render](https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/post-return#post-return-block-) #### Use cases * **Organized layouts:** Arrange form elements, buttons, or content in organized layouts. * **Responsive design:** Create responsive layouts that adapt to different screen sizes. * **Consistent spacing:** Control spacing between elements for visual hierarchy. * **Precise alignment:** Align content precisely using justify and align properties. ## Examples ### Layout elements horizontally or vertically Organize UI elements horizontally or vertically with automatic spacing management. This example shows a Stack with default values, demonstrating how to structure layouts and control element spacing through gap properties without manual margin management. ## Layout elements horizontally or vertically ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/stack-default.png) ### Arrange elements vertically Stack elements vertically by setting `direction="block"`. This creates a vertical layout with automatic gap spacing between elements, ideal for forms, lists, or any vertically-stacked content. ## Arrange elements vertically ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/extension-stack-block.png) ### Center content on both axes Center elements both horizontally and vertically using `justifyContent="center"`, `alignContent="center"`, and `alignItems="center"` with custom `blockSize="50%"` and `inlineSize="100%"`. All three alignment properties work together to create perfectly centered content on both axes. ## Center content on both axes ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/extension-stack-block-center-all.png) ### Center elements horizontally Center elements horizontally using `justifyContent="center"` with `flexChildren={false}` (default). This positions children in the center while keeping them at their minimum required size, ideal for centered button groups without stretching. ## Center elements horizontally ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/extension-stack-inline-centered.png) ### Center elements vertically Center children along the vertical axis using `alignItems="center"`. This example shows an inline stack with two children of different heights (a nested block stack and a button)—since the block stack has greater intrinsic height, `alignItems="center"` centers both children along the cross-axis. ## Center elements vertically ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/extension-stack-inline-align-items-center.png) ### Create complex layouts with nested stacks Nest multiple stacks to build sophisticated layouts. This example creates a tappable row using an inline parent stack with `justifyContent="space-between"` and `inlineSize="100%"` containing two child stacks: a block stack (left) with gap 100 for labels, and an inline stack (right) with gap 600 for text and icon. The entire structure is wrapped in a Selectable component for tap interaction with visual highlight. ## Create complex layouts with nested stacks ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/extension-stack-nested.png) ### Expand children to fill available space Make child components expand to fill available space in an inline stack using `flexChildren={true}`. This stretches the two buttons to occupy maximum space within the inline container, distributing space evenly across children for full-width layouts. ## Expand children to fill available space ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/extension-stack-inline-flexChildren.png) ### Space elements apart vertically Distribute children vertically using `justifyContent="space-between"` with `blockSize="50%"` for custom height. This example removes the ScrollView wrapper and adds `inlinePadding="450"` to mimic screen header padding, spreading children across the available height with maximum spacing. ## Space elements apart vertically ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/extension-stack-block-space-between.png) ### Stretch elements to fill width Stretch child elements to fill container width using `alignContent="stretch"`. This makes all children expand horizontally to fill available space regardless of content, ensuring consistent full-width elements in vertical layouts. ## Stretch elements to fill width ![](https://shopify.dev/images/templated-apis-screenshots/pos-ui-extensions/2025-07/extension-stack-block-align-content-stretch.png) ### Examples * #### Layout elements horizontally or vertically ##### Description Organize UI elements horizontally or vertically with automatic spacing management. This example shows a Stack with default values, demonstrating how to structure layouts and control element spacing through gap properties without manual margin management. ##### React ```tsx import { reactExtension, Button, Stack, Screen, } from '@shopify/ui-extensions-react/point-of-sale'; import React from 'react'; export default reactExtension('pos.home.modal.render', () => (