SwiftUI buttons and controls
Custom SwiftUI buttons with press depth, loading and success states, press-and-hold confirmation, plus a timer dial and a gesture-driven avatar stack.
About these pieces
One self-contained Swift file each, Apple frameworks only, from iOS 17.
A button is the one control people touch most, so it is where missing detail shows. Elastic Button is a ButtonStyle that squashes toward the touch point, rubber-bands when dragged and springs back. Commit Button runs an async action through one phase: a capsule collapses into a spinner, then blooms into a success check, or shakes into an error that doubles as retry. Hold to Confirm guards destructive actions with a fill that sweeps while held, milestone haptics and a rewind on early release.
Timer Dial is a countdown ring you set by dragging its knob, with a tick per step and a heavier detent every five seconds. Fan Stack spreads overlapping avatars apart and lets a drag scrub across them to pick one.
Learn the technique: SwiftUI motion guide, SwiftUI buttons guide, SwiftUI haptics guide.
Questions
How the pieces work, and how to build the same thing yourself. Every piece's page has its full notes.
How do I make a custom button style in SwiftUI?
Conform to ButtonStyle and read configuration.isPressed in makeBody to change scale, color or shadow while pressed, animated with a spring. Apply it with .buttonStyle(YourStyle()). Elastic Button is a ready-made ButtonStyle that adds touch-point squash and drag stretch.
How do I show a loading state in a SwiftUI button?
Model the action as a phase (idle, loading, success, error), disable the button while loading, and swap the label for a ProgressView. Commit Button does this with one animated shape and returns to idle on its own.
How do I add haptics to a SwiftUI button?
On iOS 17 and later use .sensoryFeedback(.impact, trigger: value) on the button, where the trigger changes on tap. Every control here already fires the right feedback at the right moment.
Keep browsing
Nearby collections, then every category in the library.
- Haptics33Pieces that tick, tap and confirm at the moment that matters.
- Inputs and forms17Tracks, steppers, rails and fields built for the thumb, down to addresses, map pins and signatures.
- Feedback5Reactions, ratings, status morphs, skeletons and outcomes.
- Text4Type that reveals, expands, holds pictures and renders as glass.
- Backgrounds2Quiet atmospheres: a Metal silk shader and a touch-reactive dot grid.
- Liquid Glass5Correct iOS 26 Liquid Glass with Material fallbacks.
- Cards5Cards with depth, motion, parallax and gesture-driven stacks.
- Lists7Rows, grids and carousels with swipe, drag-to-select, follow-the-latest and completion physics.
- Navigation7Floating docks, tracking tabs, stretchy headers and an A to Z index.
- Sheets5Toasts, confirmations, permission moments and guided tours.
- Motion1Gesture modifiers with real physics.
- Data and charts6Scrubbable charts, rings, streak heatmaps, live stats and odometers.
- AI6Streaming replies, thinking states, prompt chips and answer sources.
- Media8Photo viewing and cropping, story playback, attachments and link previews.
- Animations16Springs, gesture physics, transitions and morphs, across every category.
Ready to build something better?
85 pieces, one file each, yours to keep. Start with the library or see what the whole app looks like.