Skip to main content
Brand and assets
Build
Monitor and contribute
/
Front-end platform
  • Overview
  • Technical architecture
  • Core framework
  • Application
  • global-shell
  • modular-arch
  • Product shells
  • Modules & apps
  • Module directory
  • Apps
  • Bundles
  • Bundle explorer
  • Guides
  • Install Murray
  • Universal components
  • Build a universal component
  • Responsive styles
  • RTL support
  • Translations & i18n
  • When to use Form
  • Positioning elements
  • Add a new icon
  • Utilities
  • Overview
  • Layouts
  • Positioning elements

Positioning elements, good practices

Use alignItems with HStack​

Don't use negative margin or negative position top, to align elements.

Use alignItems with HStack to align elements vertically.

<HStack sx={{ alignItems: "center" }}>
<Icon visual="Check" />
<Text>Text</Text>
</HStack>

Use gap with VStack​

Don't use <Spacer />, padding or margin to separate elements.

Use gap with VStack to separate elements vertically even for paragraph.

<VStack gap="$px12">
<Paragraph>{/* paragraph content */}</Paragraph>
<Paragraph>{/* paragraph content */}</Paragraph>
<Box>{/* box content */}</Box>
</VStack>

Use flex to set the width of an element​

Don't use width to set the width of an element.

Use flex/flex-grow to set the width of an element.

For example, you want to make a box fill the remaining space of a container, you can do:

<HStack>
<Box sx={{ flex: 1 }} />
</HStack>
Edit this page
Previous
When to use Form
Next
Add a new icon
  • Use alignItems with HStack
  • Use gap with VStack
  • Use flex to set the width of an element