Hanzo GUI

Stacks

An optional base for creating flex-based layouts

  • X, Y, and Z stacks for easy flex layouts.
  • Gap property to add space between elements.
  • Handle press, focus, and layout events easily. Hanzo GUI includes optional stack views - XStack, YStack and ZStack. They extend directly off the View from @hanzogui/core, and so accept all style properties.

In this example you'd show three YStack elements spaced out.

Installation

Stacks is already installed in @hanzo/gui, or you can install it independently:

npm install @hanzogui/stacks

Usage

import { XStack, YStack } from '@hanzo/gui'

export default () => (
  <XStack gap="$2">
    <YStack />
    <YStack />
    <YStack />
  </XStack>
)

To see all the style properties supported, see the Props documentation.

Fuller Example

An example using a wide variety of style properties:

import { Text, XStack, YStack } from '@hanzo/gui'

export default () => (
  <XStack
    flex={1}
    flexWrap="wrap"
    backgroundColor="#fff"
    hoverStyle={{
      backgroundColor: 'red',
    }}
    // media query
    $gtSm={{
      flexDirection: 'column',
      flexWrap: 'nowrap',
    }}
  >
    <YStack gap="$3">
      <Text>Hello</Text>
      <Text>World</Text>
    </YStack>
  </XStack>
)

API Reference

XStack, YStack, ZStack

Beyond the Hanzo GUI Props, the stacks add just two variants:

PropTypeDefaultRequired
fullscreenboolean--
elevationnumber | tokens.size--

Last updated on

On this page