Section

A container view that you can use to add hierarchy within certain views.

ComponentiOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+Section in SwiftUI

Declaration

React
import { Section } from 'swiftui-react-native';
Swift
struct Section<Parent, Content, Footer>

Initializers

7 SwiftUI initializers back <Section>. The props you pass pick one.

React
<Section>
  children?: ReactNode
</Section>
Swift
@export(implementation) init(@ContentBuilder content: () -> Content)
  • childrenReactNode

    Content. Strings become Text; React Native views are laid out by Yoga and placed by SwiftUI.

    Swift content: () -> Content

Also takes the common view props: modifiers, style and testID.

Overview

Use Section instances in views like List, Picker, and Form to organize content into separate sections. Each section has custom content that you provide on a per-instance basis. You can also provide headers and footers for each section.

Collapsible sections

Create sections that expand and collapse by using an initializer that accepts an isExpanded binding. A collapsible section in a List that uses the ListStyle.sidebar style shows a disclosure indicator next to the section's header. Tapping on the disclosure indicator toggles the appearance of the section's content.

From Apple’s SwiftUI documentation. Code samples there are Swift.

Relationships

Conforms to

  • Swift.Copyable
  • Swift.Escapable
  • TableRowContent
  • View

See also

More in Lists and collections.