Buttons, Sliders, Steppers and Date Pickers

IOS Development 10 min min read Updated: Nov 16, 2026 Beginner
Buttons, Sliders, Steppers and Date Pickers
Beginner Topic 6 of 9

Button

swift Button("Tap me") { print("Tapped") } Button { print("Add") } label: { Label("Add item", systemImage: "plus") } Button("Delete", role: .destructive) { } // red by default
Button styleLook
.automaticDefault
.borderedLight tinted background
.borderedProminentFilled with accent color
.borderlessPlain text
.plainNo styling at all
swift Button("Continue") { } .buttonStyle(.borderedProminent) .controlSize(.large) .frame(maxWidth: .infinity)

Slider and Stepper

swift @State private var volume = 0.5 @State private var guests = 2 Slider(value: $volume, in: 0...1) { Text("Volume") } minimumValueLabel: { Image(systemName: "speaker") } maximumValueLabel: { Image(systemName: "speaker.wave.3") } Text("Volume: \(Int(volume * 100))%") Stepper("Guests: \(guests)", value: $guests, in: 1...10)

DatePicker and ColorPicker

swift @State private var date = Date.now @State private var color = Color.blue DatePicker("Pick a date", selection: $date, in: Date.now..., displayedComponents: [.date, .hourAndMinute]) .datePickerStyle(.compact) // .graphical, .wheel ColorPicker("Favorite color", selection: $color) Text(date, format: .dateTime.day().month().year())

Menu, Link and ShareLink

swift Menu("Options") { Button("Copy", systemImage: "doc.on.doc") { } Button("Share", systemImage: "square.and.arrow.up") { } Button("Delete", systemImage: "trash", role: .destructive) { } } Link("Open website", destination: URL(string: "https://www.apple.com")!) ShareLink(item: "Check out this iOS course!")

Mini Project: Booking Form

swift struct BookingView: View { @State private var guests = 2 @State private var date = Date.now @State private var notes = "" @State private var confirmed = false var body: some View { NavigationStack { Form { Stepper("Guests: \(guests)", value: $guests, in: 1...12) DatePicker("Date", selection: $date, in: .now...) TextField("Special requests", text: $notes, axis: .vertical) .lineLimit(3...5) Button("Book table") { confirmed = true } } .navigationTitle("Reserve") .alert("Booked!", isPresented: $confirmed) { Button("OK") { } } message: { Text("Table for \(guests) on \(date.formatted(date: .abbreviated, time: .shortened))") } } } }

Conclusion

These controls cover most input needs. Bind each to @State and pick a style that fits the screen.

Quick Summary: Button runs actions, Slider and Stepper change numbers, DatePicker picks dates and Menu groups actions.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators