RotatableStack
A SwiftUI view that embeds in a VStack when in portrait orientation and HStack in landscape orientation. It wraps your content in a GeometryReader to determine if the device is in landscape or portrait rotation (or on larger devices, if it's generally wider or narrower). If portrait, it wraps the content in a VStack, else it wraps in an HStack for landscape.
Install / Use
/learn @reuschj/RotatableStackREADME
RotatableStack
A SwiftUI view that embeds in a VStack when in portrait orientation and HStack in landscape orientation. It wraps your content in a GeometryReader to determine if the device is in landscape or portrait rotation (or on larger devices, if it's generally wider or narrower). If portrait, it wraps the content in a VStack, else it wraps in an HStack for landscape.
Basic Usage
Use RotatableStack in place of a VStack or HStack where you want the layout to change based on the geometry of your device:
struct MyView: View {
var body: some View {
RotatableStack {
Spacer()
Text("Hello, World!")
}
}
}
Alignment and Spacing
You can also pass parameters down to the underlying VStack or HStack, including alignment and spacing.
struct MyView: View {
var body: some View {
RotatableStack(
horizontalAlignment: .leading,
verticalAlignment: .top,
spacing: 16
) {
Spacer()
Text("Hello, World!")
}
}
}
Parameter | Type | Default | Notes
---- | ---- | ---- | ----
horizontalAlignment | HorizontalAlignment | .center | Horizontal alignment passed to underlying VStack when alignment is portrait.
verticalAlignment | VerticalAlignment | .center | Vertical alignment passed to underlying HStack when alignment is landscape.
spacing | CGFloat? | nil | Spacing to pass to the underlying VStack or HStack.
You pass both alignment types since one will be used for portrait and the other for landscape.
If you want to make this a bit easier, this package provides a FlexAlignment enum that works almost exactly the same as HorizontalAlignment, but will work in both orientations. In landscape, the top is "leading" and the bottom is "trailing". This is just a shortcut if you want to keep alignment consistent in either orientation.
struct MyView: View {
var body: some View {
RotatableStack(
alignment: .leading,
spacing: 16
) {
Spacer()
Text("Hello, World!")
}
}
}
Parameter | Type | Default | Notes
---- | ---- | ---- | ----
alignment | FlexAlignment | NA | A universal alignment that is translated/passed to underlying VStack when alignment is portrait or HStack when alignment is landscape.
spacing | CGFloat? | nil | Spacing to pass to the underlying VStack or HStack.
Thanks to kcochibili for suggesting the addition of alignment and spacing!
Related Skills
qqbot-channel
349.0kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
docs-writer
100.3k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
349.0kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
Design
Campus Second-Hand Trading Platform \- General Design Document (v5.0 \- React Architecture \- Complete Final Version)1\. System Overall Design 1.1. Project Overview This project aims t
