What's New in SwiftUI for iOS 27: Reordering, Swipe Actions, Toolbars and More
iOS 27 is a "fill the gaps" release for SwiftUI. Where iOS 26 was all about the new Liquid Glass look, iOS 27 takes things you could only do in a List or with UIKit (drag to reorder, swipe actions, toolbar overflow, image caching) and makes them work anywhere. It also changes two fundamentals: how @State stores classes, and how result builders work.
Everything below is checked against Apple's SwiftUI updates and the iOS 27.1 SDK itself, and every example compiles against that SDK in Swift 6 mode. Except where noted, these APIs need iOS 27.
Two changes you get just by building with Xcode 27
@State is now a macro. Building with Xcode 27, @State uses the new State() macro. The practical effect: when the value is a class, such as an @Observable model, it's created and stored only once, instead of the initializer running again every time the parent view rebuilds. If you've ever seen an @Observable model's init run more often than expected, this is the fix.
One ContentBuilder for everything. SwiftUI now builds closures with a single, type-agnostic ContentBuilder, replacing the separate builders for views, toolbars, commands and more (ToolbarContentBuilder, CommandsBuilder, …). You don't change your code; new APIs, like the ones below, simply take @ContentBuilder closures.
Drag to reorder in any container
Reordering used to mean List with .onMove. In iOS 27, mark the ForEach reorderable() and put reorderContainer(for:) on the container. It works in ScrollViews, stacks, grids and custom layouts.
struct Chore: Identifiable {
let id = UUID()
var title: String
}
extension Array where Element: Identifiable {
/// Moves the dragged items to where they were dropped.
mutating func apply(_ difference: ReorderDifference<Element.ID, ReorderableSingleCollectionIdentifier>) {
let moving = filter { difference.sources.contains($0.id) }
removeAll { difference.sources.contains($0.id) }
switch difference.destination.position {
case .before(let id):
insert(contentsOf: moving, at: firstIndex { $0.id == id } ?? endIndex)
case .end:
append(contentsOf: moving)
}
}
}
struct ChoreBoard: View {
@State private var chores = [Chore(title: "Laundry"), Chore(title: "Dishes"), Chore(title: "Groceries")]
var body: some View {
ScrollView {
LazyVStack(spacing: 12) {
ForEach(chores) { chore in
Text(chore.title)
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(.background.secondary, in: .rect(cornerRadius: 16))
}
.reorderable()
}
.padding()
}
.reorderContainer(for: Chore.self) { difference in
chores.apply(difference)
}
}
}The move closure receives a ReorderDifference: the IDs of the dragged items (sources, plural, because people can drag several at once) and a destination that's either .before(id) or .end. SwiftUI doesn't touch your data, so the small apply extension above does the move. Variants of reorderContainer take an itemID key path and a collection ID, for dragging between several lists.
Swipe actions outside List
Swipe actions also escape List. Add them to a row with the new swipeActions(edge:allowsFullSwipe:content:onPresentationChanged:), and mark the scrolling container with swipeActionsContainer() so it coordinates them, closing one row's actions when another opens.
struct InboxView: View {
@State private var messages = ["Lunch tomorrow?", "Invoice #1042", "Your order shipped"]
@State private var openRows = 0
var body: some View {
ScrollView {
LazyVStack(spacing: 0) {
ForEach(messages, id: \.self) { message in
Text(message)
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(role: .destructive) {
messages.removeAll { $0 == message }
} label: {
Label("Delete", systemImage: "trash")
}
} onPresentationChanged: { isShown in
openRows += isShown ? 1 : -1
}
}
}
.swipeActionsContainer()
}
}
}onPresentationChanged tells you when a row's actions open or close, which is handy for pausing other gestures or hiding a floating button while they're shown.
Toolbars that degrade gracefully
On a small iPhone, a toolbar with five buttons has never had a good answer. iOS 27 gives you three tools:
visibilityPriority(_:): mark the actions that matter with.high; SwiftUI moves lower-priority items to the overflow menu first as space runs out.ToolbarOverflowMenu: put secondary actions (archive, delete) straight into the overflow menu..topBarPinnedTrailing: a placement that keeps an item, typically Done, fixed at the trailing edge while other items shift around it.
struct NoteEditor: View {
var body: some View {
NavigationStack {
Text("Note")
.toolbar {
ToolbarItem(placement: .topBarPinnedTrailing) {
Button("Done") {}
}
ToolbarItem {
Button("Share", systemImage: "square.and.arrow.up") {}
}
.visibilityPriority(.high)
ToolbarOverflowMenu {
Button("Archive", systemImage: "archivebox") {}
Button("Delete", systemImage: "trash", role: .destructive) {}
}
}
.toolbarMinimizationBehavior(.onScrollDown, for: .navigationBar)
}
}
}toolbarMinimizationBehavior(_:for:) controls how bars minimize as people scroll: .automatic, .onScrollDown or .onScrollUp, for the bars you name.
Alerts from an error or an item
Two long-standing papercuts are gone. alert(error:actions:) presents an alert straight from an optional Error binding, titled from the error (a LocalizedError controls that text), and a variant adds a message: closure. And alert and confirmationDialog take an item: binding, passing the unwrapped value to your actions.
enum SaveError: LocalizedError {
case offline
var errorDescription: String? { "You're offline" }
var recoverySuggestion: String? { "Your changes are saved on this device and will sync later." }
}
struct Photo: Identifiable {
let id = UUID()
var name: String
}
struct EditorView: View {
@State private var saveError: SaveError?
@State private var photoToDelete: Photo?
var body: some View {
Button("Save") { saveError = .offline }
.alert(error: $saveError) {
Button("OK") {}
}
.confirmationDialog("Delete photo?", item: $photoToDelete) { photo in
Button("Delete \(photo.name)", role: .destructive) {}
}
}
}Setting the binding to nil dismisses it, and SwiftUI sets it back to nil when the person taps a button.
AsyncImage with caching
AsyncImage finally has an answer to "why does it download the same avatar every time?". New initializers take a URLRequest, so you control the cache policy, and asyncImageURLSession(_:) sets the URLSession (and therefore the URLCache) for every AsyncImage below it.
struct Avatar: View {
let url: URL
var body: some View {
AsyncImage(request: URLRequest(url: url, cachePolicy: .returnCacheDataElseLoad)) { image in
image.resizable().scaledToFill()
} placeholder: {
Color.secondary.opacity(0.2)
}
.frame(width: 44, height: 44)
.clipShape(.circle)
}
}
enum ImageCache {
static let session: URLSession = {
let configuration = URLSessionConfiguration.default
configuration.urlCache = URLCache(memoryCapacity: 20_000_000, diskCapacity: 200_000_000)
return URLSession(configuration: configuration)
}()
}
struct FeedView: View {
let avatars: [URL]
var body: some View {
List(avatars, id: \.self) { Avatar(url: $0) }
.asyncImageURLSession(ImageCache.session)
}
}A prominent tab, and a cross-fading sheet
The .prominent tab role puts a tab in a separate, trailing position of the tab bar, a natural home for the app's main action, like "New post". And .navigationTransition(.crossFade) makes a sheet fade in over the content instead of sliding up.
struct RootView: View {
@State private var showCompose = false
var body: some View {
TabView {
Tab("Home", systemImage: "house") { Text("Home") }
Tab("Search", systemImage: "magnifyingglass", role: .search) { Text("Search") }
Tab("New", systemImage: "plus", role: .prominent) { Text("Compose") }
}
.sheet(isPresented: $showCompose) {
Text("Compose")
.navigationTransition(.crossFade)
}
}
}Confirm before a sheet is dismissed
dismissalConfirmationDialog(_:shouldPresent:actions:) asks before someone swipes away a sheet with unsaved work. It only intervenes while shouldPresent is true:
struct ComposeSheet: View {
@State private var draft = ""
var body: some View {
TextEditor(text: $draft)
.dismissalConfirmationDialog("Discard this draft?", shouldPresent: !draft.isEmpty) {
Button("Discard", role: .destructive) {}
}
}
}Document apps that work with files directly
Document-based apps get a new model built around file URLs. Conform an @Observable class to ReadableDocument to open files, or to Document (readable and writable) to edit them, and SwiftUI hands you the file's location and modification date through URLDocumentConfiguration instead of loading the whole file into memory. That makes large files and URL-based frameworks (databases, media, packages) practical. DocumentReader and DocumentWriter hold your reading and writing logic, FileWrapperDocumentReader and FileWrapperDocumentWriter cover simple cases, and fileExporter can export a WritableDocument.
The SDK marks FileDocument and ReferenceFileDocument as deprecated in a future release, with the message "Use Document protocol instead", so new document apps should start with the new protocols.
Also in iOS 27
- Gestures by input type:
TapGesture,DragGesture,LongPressGestureand others can be limited to particular input kinds (direct touch, indirect touch, Pencil or pointer) viaGestureInputKinds. - Picker as tabs: a
.tabspicker style.
iOS 27.1: layouts for new hardware
The September update (iOS 27.1) adds APIs aimed at new form factors:
ArrangementViewlays out a primary and a secondary view adaptively: side by side with the.splitstyle, layered with.overlay, or as the environment decides with.automatic. Split ratios and sizes are tuned withsplitArrangementLayoutRatioandsplitArrangementLayoutSize.- Reserved regions:
reservedRegions(kind:options:layoutDirectionBehavior:)tells you where hardware such as a camera or a hinge takes up part of the screen, so content can avoid it. - iPhone Duo:
onHingeChangereports the hinge's angle and state, andCameraCaptureAccessoryshows content on the outer display during a camera session. - Vertical toolbars:
toolbarVerticalEdge,toolbarVerticalBehavior(_:)andaxisBehavior(_:)control bars that the system can now place along the side of the screen.
@available(iOS 27.1, *)
struct ReaderLayout: View {
var body: some View {
ArrangementView {
Text("Article")
} secondary: {
Text("Notes")
}
.arrangementViewStyle(.split)
}
}Should you adopt it now?
Most apps support at least one older iOS version, so treat these as if #available(iOS 27, *) upgrades: keep List with .onMove as the fallback and use reorderContainer where available. The two build-time changes (@State and ContentBuilder) arrive with Xcode 27 whatever your deployment target, so they're worth a careful test pass on their own.
New APIs make apps work better; a design system makes them look better. If you build with an AI coding agent, give it a DESIGN.md, or start from one of Effect UI's design styles.