Inputs and forms · 9 free pieces

SwiftUI input fields and form controls

The inputs SwiftUI still leaves hard: a floating-label text field with validation, a password strength field, currency and token fields, a date range picker, and range sliders.

All components

About these pieces

One self-contained Swift file each, Apple frameworks only, from iOS 17.

Form Field is a text field whose label rests inside as a placeholder and glides up on focus, with a character limit, help text and validation that waits until you leave the field before it shows an error. Secure Entry adds a reveal toggle, a four-step strength bar and requirement chips. Amount Field formats currency live in the user's locale on a Decimal binding. Token Field turns entries into wrapping chips for tags and recipients, with paste of a whole list and inline suggestions.

For picking values: Range Slider is a dual-thumb slider whose thumbs never cross, Expanding Track is a thumbless slider that swells under the finger, Scrub Stepper steps by tap, hold or a sideways scrub, Date Range Picker selects a start and end date on a paged month grid, and Filter Rail is a scrolling row of filter chips.

Learn the technique: SwiftUI haptics guide.

Questions

How the pieces work, and how to build the same thing yourself. Every piece's page has its full notes.

Does SwiftUI have a range slider with two thumbs?

No. SwiftUI's Slider has one thumb. Range Slider adds a dual-thumb control with step snapping, a minimum gap, thumbs that never cross, and a haptic on every step.

How do I make a floating label text field in SwiftUI?

Overlay the label on the field and move and scale it up when the field is focused or has text, driven by @FocusState. Form Field does this and adds validation, a character counter and VoiceOver announcements.

How do I format currency input in SwiftUI?

Keep the value as a Decimal and format it with the user's locale as digits arrive, rather than binding a TextField to a formatted string. Amount Field handles grouping, the decimal separator, symbol position and pasted amounts.

Next

Ready to build something better?

55 pieces, one file each, yours to keep. Start with the library or see what the whole app looks like.