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 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.
- HapticsPieces that tick, tap and confirm at the moment that matters.19
- Inputs and formsTracks, steppers, rails and fields built for the thumb.9
- FeedbackReactions, ratings, status morphs, skeletons and outcomes.5
- TextType that reveals, expands and renders as glass.3
- BackgroundsQuiet atmospheres: a Metal silk shader and a touch-reactive dot grid.2
- Liquid GlassCorrect iOS 26 Liquid Glass with Material fallbacks.3
- CardsCards with depth, motion, parallax and gesture-driven stacks.4
- ListsRows and carousels with swipe, depth and completion physics.5
- NavigationFloating docks, tracking tabs and stretchy headers.3
- SheetsToasts, confirmations and permission moments.3
- MotionGesture modifiers with real physics.1
- Data and chartsScrubbable charts, rings, live stats and odometers.4
- AIStreaming replies, thinking states, prompt chips and code.6
- MediaPhoto viewing and story playback.2
- AnimationsSprings, gesture physics, transitions and morphs, across every category.16
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.