diff --git a/learn/react-native/auto-layout.md b/learn/react-native/auto-layout.md new file mode 100644 index 000000000..8112e094e --- /dev/null +++ b/learn/react-native/auto-layout.md @@ -0,0 +1,211 @@ +--- +title: "Auto Layout" +id: "auto-layout" +sidebar_label: "Auto Layout" +--- +--- + +import autolayoutProps from '/learn/assets/autolayout/common/autolayout-props.png'; +import alignmentDefaultRow from '/learn/assets/autolayout/common/alignment-default-row.png'; +import alignmentDefaultColumn from '/learn/assets/autolayout/common/alignment-default-column.png'; +import alignmentAutoRow from '/learn/assets/autolayout/common/alignment-auto-row.png'; +import alignmentAutoColumn from '/learn/assets/autolayout/common/alignment-auto-column.png'; + +import addingAutolayoutToWidgetsOne from '/learn/assets/autolayout/web/adding-autolayout-to-widgets-one.mp4'; +import addingAutolayoutToWidgetsTwo from '/learn/assets/autolayout/web/adding-autolayout-to-widgets-two.mp4'; +import addingWidgetToAutolayout from '/learn/assets/autolayout/web/adding-widgets-to-autolayout.mp4'; +import autolayoutDirection from '/learn/assets/autolayout/web/autolayout-direction.mp4'; +import autolayoutWrap from '/learn/assets/autolayout/web/autolayout-wrap.mp4'; +import alignment from '/learn/assets/autolayout/web/alignment.mp4'; +import width from '/learn/assets/autolayout/web/width.mp4'; +import gap from '/learn/assets/autolayout/web/gap.mp4'; +import rowGap from '/learn/assets/autolayout/web/row-gap.mp4'; +import padding from '/learn/assets/autolayout/web/padding.mp4'; + +Auto Layout is a smart layout system that manages the positioning, sizing, and spacing of widgets for you. Inspired by CSS Flexbox, it allows you to build responsive interfaces by simply configuring direction, alignment and spacing in Studio, rather than writing complex CSS or managing deep hierarchies. +At its core, Auto Layout groups sibling widgets into a Container widget that arranges them along a horizontal or vertical axis. This approach leads to: +- Flatter structures with fewer nested elements leading to cleaner widget trees. +- Built-in responsiveness, reducing manual layout adjustments. + +## A Content-First Approach + +Auto Layout enables a content-first way of building layouts. Instead of starting with empty structural containers, you can begin with your actual content, the widgets themselves. To structure them in a layout, simply select the sibling widgets you want to group and add Auto Layout to them. They will be wrapped in a Container that will act as the parent frame for the layout and manage direction, alignment and spacing for the children. Creating the necessary layout structure around your content instantly. + +This approach makes it faster to design, develop, and maintain complex interfaces while keeping your structure intuitive and clutter-free. + +## Using Auto Layout + +### Content First + +To apply Auto Layout using the content-first approach, start by selecting multiple sibling widgets on the canvas (hold **Shift** and click to multi-select). Once selected, you can either: + +1. Right-click the selection and choose **Add Auto Layout** from the context menu. + +