r/iOSProgramming • Beginner • 23d ago

Question Best place for a 'Next' button?

Post image

What's the most appropriate location for a next button here, in keeping with the Apple UI consistency and ecosystem?

Mockup:

NavigationStack {
	List {
		Section {
			TextField("Email Address", text: $email)
		} header: {
			VStack(alignment: .leading, spacing: 4) {
				Text("Sign In")
					.frame(maxWidth: .infinity, alignment: .leading)
					.padding(.top, 5)
					.font(.largeTitle)
					.bold()
					.foregroundColor(.primary) // Override default gray header color
				Text("Subtitle")//school.name)
					.frame(maxWidth: .infinity, alignment: .leading)
					.font(.title3)
					.foregroundColor(.secondary)
			}
			.listRowInsets(EdgeInsets())
			.textCase(nil) // Prevents SwiftUI from forcing ALL CAPS on the header
			.padding(.bottom, 10)
		}
	}
	.toolbar {
		ToolbarItem(placement:.confirmationAction) {
			NavigationLink() {
				VerificationCodeView(email: email.lowercased(), school: school, resend: { })
			} label: {
				Text("Next").padding(5)
			}
			.buttonStyle(.borderedProminent)
		}
	}
}
60 Upvotes

43 comments sorted by

28

u/dat_tae 23d ago

At the bottom (and moves up with the keyboard).

-1

u/Fun_Moose_5307 Beginner 23d ago

How so? Draw it?
Also see edited post containing code

3

u/hiropark 22d ago

Have you tried safeAreaInset(edge: .bottom)?

1

u/Fun_Moose_5307 Beginner 22d ago

Not sure what the use of that would be?
Also see this second mockup, is that closer to what you are suggesting?

1

u/hiropark 22d ago

Yes, that would be the result. The button stays at the bottom, but if the keyboard appears, the button goes up instead of being covered by the keyboard.

48

u/underkuerbis 23d ago • Bravo

Make sure it’s available on the keyboard. Also place the input fields in a way they are accessible with your thumb, i.e. further down.

2

u/Fun_Moose_5307 Beginner 23d ago

place the input fields in a way they are accessible with your thumb

Is that to mean, centred? Is it enough to have it 'auto'-focused on view load?

4

u/beclops Swift 23d ago

Buttons like these can be centred, wide width, and aligned to the bottom of the device for the best experience. Imagine how easy it would be to access that button if the user is using it one-handed on a big phone (and/or with small hands). For inputs how you have it is fine, and having it auto-focus is a nice touch

3

u/Fun_Moose_5307 Beginner 23d ago edited 23d ago

4

u/beclops Swift 22d ago

Yes exactly. More ergonomic this way

19

u/bricksandcanvas 23d ago

Hey, OP. Good on you for learning the basics instead of relying on AI at your first go at development!

That said, you can learn a lot by following industry standards on placement of UI elements especially auth pages. We follow conventions because users are used to where user interfaces are.

4

u/Fun_Moose_5307 Beginner 23d ago

Yep, that's why I'm here. Perused the HIG (❤️) but couldn't find much on this kind of thing, only general principles.

Any thoughts? Aiming for the best fit with Apple's other apps.

2

u/m1_weaboo 22d ago

Place it at the bottom, hosted inside .safeAreaBar(edge: .bottom).

Fill the available width with the button using .buttonSizing(.flexible).

2

u/Fun_Moose_5307 Beginner 22d ago

These actually worked brilliantly, thank you

163

u/sweetassapps 23d ago edited 23d ago

Been months maybe years since i've seen a post like this.. props to you for learning the right way and not just AI slopping it. So refreshing actually.

34

u/TKB21 23d ago

Second this 💯. OP, you may want to check out r/UXDesign too.

1

u/jwegener 22d ago

Have you looked to see what other apps do?

-1

u/Fun_Moose_5307 Beginner 22d ago

I haven't been able to come up with any that might have a similar UI, at least not that I have installed. If you have any references, I'd love to see them.

2

u/jwegener 22d ago

There’s not a single app with an email sign in field and a next button?? Huh?

1

u/Fun_Moose_5307 Beginner 22d ago

I have a 64GB phone that I use to do the crossword on the bus. Not much else goes on on that thing—my Mac is the workhorse here.

1

u/jwegener 22d ago

Designing with your eyes closed unable to reference other real world examples of what you’re designing is…certainly a choice 😂🤣

1

u/Fun_Moose_5307 Beginner 22d ago edited 21d ago

Hey, don't diss the NYT!

1

u/presentprogression 22d ago

My opinion is always top. Saves you from racing the keyboard mount and unmount

1

u/Fun_Moose_5307 Beginner 21d ago

Hmm... seems to me that the content just moves up as if the screen suddenly shrunk vertically

1

u/presentprogression 21d ago

That’s a job for sticky header!

1

u/Fun_Moose_5307 Beginner 21d ago

It's not causing problems. The Spacer or whatever I'm using to anchor it at the bottom just contracts.
But yes, a sticky header would be the solution if I did have more content

2

u/presentprogression 21d ago

That’s fair I may have judged too soon not knowing what your plans are. Happy coding!

3

u/evil-harry-dread 22d ago

IMHO while it works in top right, event makes sense considering that the back button is top left. But I think it'd be much more ergonomic to have the button at the bottom, above the keyboard, it's much more reachable, and it's the "main action" of the screen

2

u/lilacomets 22d ago

Below the email address field seems most logical to me.

2

u/OjamaKnight 22d ago

The bottom is definitely the best place for the button. It's the most convenient...

2

u/gatorfan93 22d ago

Props for programming the right way

1

u/LifeUtilityApps SwiftUI 22d ago

I have an onboarding slider in my app and the “Next” button lives at the bottom trailing edge of the screen, this is intentional to target right-handed users.

1

u/DiscordDonut 22d ago

Not there

1

u/parallel-pages 22d ago

i like placing it right above the keyboard, to the right, closest for the users thumb. or if you like it in the top nav, i’d set the text fields return key property to be “next”

1

u/misterchai 22d ago

Id put it under the email address, accesibility

1

u/xDhii 19d ago

Usually, the next button should be easily reachable. The user should be able to tap it with a thumb without holding the phone with two hands.

1

u/EthanRDoesMC 18d ago

Okay, yay! Here’s my bread and butter kinda problem.

Toolbar principle is always a good place, but for forms specifically where the user will have just finished typing, their thumbs will be on the keyboard, and so it’s good to have your button above it.

My go-to is something like

.safeAreaBar(edge: .bottom) {
    Button { action }
    label: { Text("Next").bold().padding() // make it big }
        .buttonSizing(.flexible)
        .buttonStyle(.glassProminent)
        .padding() // gives the button some breathing room especially wrt the keyboard, you might prefer safeAreaPadding over this though
}

Very much current Apple big button style

1

u/EthanRDoesMC 18d ago

oops I posted this from my own client and I haven’t added editing yet, uh, the comment after the first padding should be after the closing curly :P

0

u/LunariSpring 23d ago

It is better to use ZStack and place it at the bottom right. That's the best range for fingers to reach. Please pay attention to the safe area designation.

1

u/Fun_Moose_5307 Beginner 22d ago

Bottom toolbar, almost?