SwiftUI inspired Stack and Spacer components.
yarn add react-native-stacks
import React from "react";
import { Text, Button } from "react-native";
import { VStack, HStack, Spacer } from "react-native-stacks";
function Example() {
return (
<VStack aligmment="leading" spacing={20}>
<Text>Orders</Text>
<Spacer />
<HStack>
<Button onPress={add} title="Add" />
<Spacer />
<Button onPress={remove} title="Remove" />
</HStack>
</VStack>
);
}
vs. SwiftUI...
struct Example: View {
var body: some View {
VStack(alignment: .leading, spacing: 20) {
Text("Orders")
Spacer()
HStack() {
Button(action: add) {
Text("Add")
}
Spacer()
Button(action: remove) {
Text("Remove")
}
}
}
}
}
<VStack />A vertical stack.
spacingThe amount of space between each item in the stack.
required: no
type:
numberdefault:
0
alignmentThe horizontal alignment for the stack items.
required: no
type:
VStackAlignmentdefault:
'center'
type VStackAlignment = "leading" | "center" | "trailing";
<HStack />A horizontal stack.
spacingThe amount of space between each item in the stack.
required: no
type:
numberdefault:
0
alignmentThe vertical alignment for the stack items.
required: no
type:
HStackAlignmentdefault:
'center'
type HStackAlignment = "top" | "center" | "bottom";
<ZStack />An overlay stack.
alignmentThe horizontal and vertical alignment for the stack items. Since a ZStack overlays items on top of one another, we are able to align them both vertically and horizontally.
required: no
type:
ZStackAlignmentdefault:
'center'
type ZStackAlignment =
| "top"
| "center"
| "bottom"
| "leading"
| "trailing"
| "topLeading"
| "topTrailing"
| "bottomLeading"
| "bottomTrailing";
<Spacer />A component to provide space between stack items. Spacers will fill the available space between components.
$ claude mcp add react-native-stacks \
-- python -m otcore.mcp_server <graph>