Section in SwiftUI

Section is a container that organizes and groups views within a list or form. It provides a way to structure your layout with headers, footers, and dividers between items. Section is most commonly used in List and Form components, making it ideal for displaying grouped data or categorized settings. Basic Structure A basic Section consists … Read more

GroupBox in SwiftUI

GroupBox is a container view that visually groups related views together and applies a standard, styled box around its content. It is commonly used to provide a sectioned, boxed grouping for content like settings or other information. By default, it comes with a border and some padding, giving a clear visual distinction to the grouped … Read more

Group in SwiftUI

Group is a container that groups multiple views together. It allows you to include multiple child views inside parent views that only expect one view. Group itself doesn’t apply any layout or styling to the views it contains, but it can help you organize and manage your views efficiently. Key Features of Group Basic Structure … Read more

Form in SwiftUI

Form is a container that groups input elements like text fields, buttons, toggles, and pickers in a structured layout commonly used for data entry. It’s often used for settings pages, registration forms, or any situation where user input is required. Form automatically arranges and spaces out its child views, making it an ideal choice for … Read more

ScrollView in SwiftUI

ScrollView allows content to be scrollable when it exceeds the available space. You can scroll either vertically, horizontally, or both. ScrollView is particularly useful when displaying lists of items or large content areas that won’t fit on the screen all at once. Basic Structure The basic structure of a ScrollView is simple: You can specify … Read more

Grids in SwiftUI

Grids are used to create flexible, structured layouts where views are arranged in rows and columns. Starting with iOS 16, SwiftUI introduced a built-in Grid container, which is more efficient and easier to use than older workarounds for creating grid layouts. You can define the rows and columns explicitly or allow SwiftUI to manage them … Read more

GeometryReader in SwiftUI

GeometryReader is a powerful container view that allows you to access the size and position of its child views. It gives you the geometry of the parent view and allows you to dynamically adjust the layout based on available space. Basic Usage of GeometryReader GeometryReader provides a GeometryProxy object, which contains properties like size, safe … Read more

Divider in SwiftUI

Divider is a simple view used to visually separate content with a horizontal or vertical line. It’s commonly used in stacks (e.g., VStack, HStack) to divide sections of content, providing a clean and minimal separation between views. Basic Usage of Divider A Divider creates a thin line that spans across the parent view’s width or … Read more

Spacer in SwiftUI

In SwiftUI, Spacer is a flexible, invisible view that pushes other views around in the layout. It’s commonly used to create space between views or to align views within a container. Basic Usage of Spacer The Spacer view expands to fill any available space within a layout, either vertically or horizontally, depending on its parent … Read more

EmptyView in SwiftUI

In SwiftUI, EmptyView is a placeholder view that represents an empty, invisible view. It doesn’t render anything on the screen, and it’s often used when a view is conditionally required but you don’t want to display anything. Common Use Cases for EmptyView In this example, when the toggle is off, EmptyView replaces the Text view, … Read more