LazyHStack
A view that arranges its children in a line that grows horizontally, creating items only as needed.
Declaration
import { LazyHStack } from 'swiftui-react-native';nonisolated struct LazyHStack<Content> where Content : ViewInitializers
One SwiftUI initializer backs <LazyHStack>.
<LazyHStack
alignment?: SwiftUI.VerticalAlignment
spacing?: number | null
pinnedViews?: SwiftUI.PinnedScrollableViews
>
children?: ReactNode
</LazyHStack>nonisolated init(
alignment: VerticalAlignment = .center,
spacing: CGFloat? = nil,
pinnedViews: PinnedScrollableViews = .init(),
@ContentBuilder content: () -> Content
)alignmentSwiftUI.VerticalAlignmentThe guide for aligning the subviews in this stack. All child views have the same vertical screen coordinate.
Default
`.center`spacingnumber | nullThe distance between adjacent subviews, or
nilif you want the stack to choose a default distance for each pair of subviews.Default
`nil`pinnedViewsSwiftUI.PinnedScrollableViewsThe kinds of child views that will be pinned.
Default
`.init()`childrenReactNodeContent. Strings become
Text; React Native views are laid out by Yoga and placed by SwiftUI.Swift
content: () -> Content
Also takes the common view props: modifiers, style and testID.
Overview
The stack is "lazy," in that the stack view doesn't create items until it needs to render them onscreen.
In the following example, a ScrollView contains a LazyHStack that
consists of a horizontal row of text views. The stack aligns to the top
of the scroll view and uses 10-point spacing between each text view.
ScrollView(.horizontal) {
LazyHStack(alignment: .top, spacing: 10) {
ForEach(1...100, id: \.self) {
Text("Column \($0)")
}
}
}From Apple’s SwiftUI documentation. Code samples there are Swift.
Relationships
Conforms to
- View
See also
More in Layout.
- AnyLayoutA type-erased instance of the layout protocol.
- GeometryReaderA container view that defines its content as a function of its own size and coordinate space.
- GlassEffectContainerA view that combines multiple glass shapes into a single shape that can morph individual shapes into one another.
- GridA container view that arranges other views in a two dimensional layout.
- GridLayoutA grid that you can use in conditional layouts.
- GridRowA horizontal row in a two dimensional grid container.
- HStackA view that arranges its subviews in a horizontal line.
- HStackLayoutA horizontal container that you can use in conditional layouts.
- LazyHGridA container view that arranges its child views in a grid that grows horizontally, creating items only as needed.
- LazyVGridA container view that arranges its child views in a grid that grows vertically, creating items only as needed.
- LazyVStackA view that arranges its children in a line that grows vertically, creating items only as needed.
- ScrollViewA scrollable view.