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

Divider

A SwiftUI Divider component for creating visual separators.

Expo UI Divider matches the official SwiftUI Divider API and creates a visual separator between content.

Usage

Basic divider

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

export default function BasicDividerExample() {
  // A divider spans the width it is given, so `matchContents` collapses it.
  return (
    <Host style={{ flex: 1 }}>
      <VStack>
        <Text>First section</Text>
        <Divider />
        <Text>Second section</Text>
      </VStack>
    </Host>
  );
}
A horizontal rule separating the text First section from Second section
A horizontal rule separating the text First section from Second section

Divider in a list

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

export default function DividerInListExample() {
  return (
    <Host style={{ flex: 1 }}>
      <VStack spacing={8}>
        <Text>Item 1</Text>
        <Divider />
        <Text>Item 2</Text>
        <Divider />
        <Text>Item 3</Text>
        <Divider />
        <Text>Item 4</Text>
      </VStack>
    </Host>
  );
}
Item 1 through Item 4 stacked with a horizontal rule between each pair
Item 1 through Item 4 stacked with a horizontal rule between each pair

Divider in a context menu

Dividers are commonly used to separate groups of actions in context menus.

import {
  Host,
  ContextMenu,
  Button,
  Text,
  Divider,
} from '@expo/ui/swift-ui';

export default function DividerInContextMenuExample() {
  return (
    <Host style={{ flex: 1 }}>
      <ContextMenu>
        <ContextMenu.Items>
          <Button
            label="Edit"
            onPress={() => console.log('Edit')}
          />
          <Button
            label="Duplicate"
            onPress={() => console.log('Duplicate')}
          />
          <Divider />
          <Button
            label="Delete"
            role="destructive"
            onPress={() => console.log('Delete')}
          />
        </ContextMenu.Items>
        <ContextMenu.Trigger>
          <Text>Long press me</Text>
        </ContextMenu.Trigger>
      </ContextMenu>
    </Host>
  );
}
A context menu with a rule separating Edit and Duplicate from a red Delete
A context menu with a rule separating Edit and Duplicate from a red Delete

API

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

Component

Divider

Type: React.Element<DividerProps>

Divider component uses the native Divider component. A visual element that can be used to separate other content.

DividerProps

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 Divider, but not all of them do something here.

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

Best modifiers for Divider

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

Also works on Divider

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

Needs care on Divider

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

ModifierWhat to know
frameSet the height for a horizontal divider, or the width for a vertical one. The other side fills the parent.

No visible effect on Divider

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

ModifierWhy nothing happens
accessibilityElementIt joins the child views into one accessibility element, and Divider takes no child views.
allowsTighteningIt changes only text, and Divider shows no text.
boldIt changes only text and SF Symbols, and Divider shows neither.
containerShapeIt sets the shape that the child views use for containerRelativeShape, and Divider takes no child views.
contentShapeIt changes the area that gets touches, and Divider gets no touches of its own.
contentTransition iOS 16+It changes how text and SF Symbols animate when their content changes, and Divider shows neither.
disabledIt turns off the controls in the view, and Divider has none.
dynamicTypeSizeIt changes only text and SF Symbols, and Divider shows neither.
fontIt changes only text and SF Symbols, and Divider shows neither.
foregroundColorDivider ignores this. Use overlay with a colour to change the colour of the line.
foregroundStyleDivider ignores this. Use overlay with a colour to change the colour of the line.
geometryGroup iOS 17+It works on the child views that you give the component, and Divider takes none.
imageScaleIt changes only SF Symbols, and Divider shows none.
italicIt changes only text, and Divider shows no text.
kerningIt changes only text, and Divider shows no text.
layoutPriorityIt has an effect only when the view shares an axis with other views in a stack.
lineHeight iOS 26+It changes only text, and Divider shows no text.
lineLimitIt changes only text, and Divider shows no text.
lineSpacingIt changes only text, and Divider shows no text.
minimumScaleFactorIt changes only text, and Divider shows no text.
monospacedDigitIt changes only text, and Divider shows no text.
multilineTextAlignmentIt changes only text, and Divider shows no text.
onAppearIn SDK 57, Divider does not send modifier events to JavaScript, so the handler does not run.
onDisappearIn SDK 57, Divider does not send modifier events to JavaScript, so the handler does not run.
onGeometryChangeIn SDK 57, Divider does not send modifier events to JavaScript, so the handler does not run.
onLongPressGestureIn SDK 57, Divider does not send modifier events to JavaScript, so the handler does not run.
onTapGestureIn SDK 57, Divider does not send modifier events to JavaScript, so the handler does not run.
strikethroughIt changes only text, and Divider shows no text.
textCaseIt changes only text, and Divider shows no text.
tintDivider does not use the tint colour.
truncationModeIt changes only text, and Divider shows no text.
underlineIt changes only text, and Divider shows no text.
zIndexIt changes the order of views that cover each other in the same parent, and Divider 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:

On this page