Expo UI and Router for iOSExpo SDK 57 and later, iOS only
Components

Group

A SwiftUI Group component for grouping views without affecting layout.

Expo UI Group matches the official SwiftUI Group API and groups views together without introducing additional layout structure.

Usage

Basic group

Groups are useful for applying modifiers to multiple views at once or organizing views without affecting layout.

import { Group, Host, Text, VStack } from '@expo/ui/swift-ui';
import { foregroundStyle } from '@expo/ui/swift-ui/modifiers';

export default function BasicGroupExample() {
  return (
    <Host matchContents style={{ alignSelf: 'center' }}>
      <VStack spacing={8}>
        <Group modifiers={[foregroundStyle('blue')]}>
          <Text>First item</Text>
          <Text>Second item</Text>
          <Text>Third item</Text>
        </Group>
      </VStack>
    </Host>
  );
}
Three lines of blue text stacked vertically: First item, Second item, and Third item.
Three lines of blue text stacked vertically: First item, Second item, and Third item.

API

import { Group } from '@expo/ui/swift-ui';

Component

Group

Type: React.Element<GroupProps>

GroupProps

children

Type: ReactNode

Inherited props

Modifiers

Use these modifiers in the modifiers prop of the SwiftUI version.

Expo UI lets you put any of the 89 modifiers for any view on Group, but not all of them do something here.

  • 74 change what you see on Group.
  • 1 work, but not in the way that you may expect.
  • 2 have no visible effect on Group.
  • 13 work only in one place, such as a widget or a Grid.

Where the modifiers go

SwiftUI applies the modifiers on a Group to each child, not to the group as one view. For example, padding adds padding around each child.

Best modifiers for Group

These modifiers are the ones that you use most with Group.

Also works on Group

Group takes these modifiers too, and each one works in the usual way.

Needs care on Group

These modifiers work on Group, but not in the way that you may expect.

ModifierWhat to know
paddingSwiftUI gives the padding to each child of the Group, not to the group as one view.

No visible effect on Group

Group accepts these modifiers, but you see no change. They do not give an error.

ModifierWhy nothing happens
layoutPriorityIt has an effect only when the view shares an axis with other views in a stack.
zIndexIt changes the order of views that cover each other in the same parent, and Group does not stack its children.

Only in some places

These modifiers work only in a widget, in a Grid, in a Namespace or in a parent that asks for them.

ModifierWhere it works
activityBackgroundTintWorks only in a Live Activity. It has no effect in the app.
alignmentGuideHas an effect only when the parent, such as a VStack or ZStack, aligns its children by the same guide.
containerBackgroundWorks only in a widget, or in a navigation container when you use a navigation placement.
glassEffectIdWorks only on a view that also has glassEffect, in a GlassEffectContainer and a Namespace.
gridCellAnchor iOS 16+Works only on a cell of a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridCellColumnsWorks only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridCellUnsizedAxesWorks only on a view in a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
gridColumnAlignment iOS 16+Works only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page.
invalidatableContent iOS 17+Has an effect only when a parent view uses redacted with the invalidated reason.
matchedGeometryEffectWorks only in a Namespace. Give two views the same id and change between them with an animation.
privacySensitiveHas an effect only when a parent view uses redacted with the privacy reason.
unredactedHas an effect only in a parent view that uses redacted.
widgetURLWorks only in a widget. It has no effect in the app.

Sources

The original Expo docs for this page:

  • Group (SwiftUI) (source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/group.md)

On this page