A highly customizable SwiftUI button component with audio level visualization and various visual effects including pulse rings, ripple waves, shimmer effects, and more.
SoundPulseButton provides multiple customizable visual effects that activate during different states:
- Inner Pulse Rings - Animated circles that scale from the center, responding to audio levels with staggered delays
- Ripple Waves - Expanding wave effects that emanate from the button's current radius during listening state
- Icon Shimmer - Radial gradient shimmer overlay that sweeps across the icon with configurable timing
- Loading Animation - Rotating ring indicator that appears around the button during loading state
- Background Rotation - Smooth rotation of the gradient background when in listening mode
- Real-time Scaling - Button and icon dynamically scale based on audio level input (0.0 to 1.0)
- Progressive Opacity - Shimmer effect intensity increases with audio level
- Staggered Animations - Multiple pulse rings animate with calculated delays for smooth wave effect
- Audio Level Visualization: Real-time scaling based on audio level input
- Pulse Rings: Animated inner circles that scale with audio level
- Ripple Waves: Expanding wave effects that start from the current button radius
- Shimmer Effect: Radial gradient shimmer overlay on the icon
- Loading State: Rotating loading indicator
- Press Effects: Scale and opacity changes with haptic feedback
- Background Gradient: Customizable multicolor gradient with rotation
- RTL Support: Works with right-to-left layouts
- Fully Configurable: Every aspect can be customized through configuration
Add the following to your Package.swift file:
dependencies: [
.package(url: "https://github.com/mikhailkogan17/SoundPulseButton", from: "0.1.0")
]Or add it through Xcode:
- File → Add Package Dependencies
- Enter the repository URL
- Select version and add to target
Try it in seconds: Example project is located in Example/SoundPulseButtonExample.xcodeproj.
import SoundPulseButton
SoundPulseButton(
isListening: viewModel.isListening,
isLoading: viewModel.isLoading,
audioBufferProvider: audioProvider,
onTap: handleMicrophoneTap
)// Small button
SoundPulseButton(...)
.withConfiguration(.small())
// Large button
SoundPulseButton(...)
.withConfiguration(.large())
// Custom size
SoundPulseButton(...)
.withSize(60)// Static Colors
SoundPulseButton(...)
.withBackground(
idle: .color(.accentColor),
listening: .color(.red)
)
// Mesh Gradient
SoundPulseButton(...)
.withBackground(
idle: .mesh([.purple, .indigo, .cyan]),
listening: .mesh([.purple, .indigo, .cyan])
)SoundPulseButton(...)
.withIcon(Image(systemName: "mic.fill"))The package includes an interactive example showcasing all available effects:
- Background Rotation - Rotates gradient background during listening
- Icon Shimmer - Adds shimmer effect to the icon
- Inner Circles - Shows pulsing inner circles
- Ripples - Creates expanding ripple waves
- Haptic Feedback - Enables tactile feedback on interactions
- Shadow Effects - Customizable drop shadows
// Configure inner pulse rings
SoundPulseButton(...)
.withInnerCircles(count: 3)
// Configure ripple waves
SoundPulseButton(...)
.withRipples(count: 3)
// Configure background rotation
SoundPulseButton(...)
.withBackgroundRotation(idle: false, listening: true)
// Configure haptic feedback
SoundPulseButton(...)
.withHaptic(enabled: true)
// Configure shimmer effect
SoundPulseButton(...)
.withIconShimmering()
// Configure shadow
SoundPulseButton(...)
.withShadow()The main configuration structure with three main sections:
gradientColors: Array of colors for the background gradientgradientPositions: Positions for gradient color stopspulse: Color for pulse rings and ripplesicon: Icon colorshadow: Shadow colorloader: Loading indicator color
icon: The image to displaybaseRadius: Base radius of the buttoniconSize: Size of the iconframeMultiplierWidth/Height: Frame size multipliersbackgroundFrameSize: Background gradient frame size
Contains sub-configurations for:
- InnerPulse: Circle count, spacing, opacity, animation delays
- Ripples: Count, max offset, opacity, line width, timing
- Loader: Appearance, rotation, styling
- Shimmer: Timing, radius, visibility, blur
- Button: Scale effects, press animations, rotation
- Shadow: Opacity, radius, offsets for different states
- Button and icon scale based on
audioLevel(0.0 to 1.0) - Inner pulse rings scale with staggered delays
- Shimmer effect opacity increases with audio level
When isListening is true:
- Inner pulse rings appear
- Background gradient starts rotating
- Ripple waves begin expanding from button radius
- Shimmer effect starts after configured delay
When isLoading is true:
- Loading ring appears around the button
- Button becomes non-interactive
- Press effects are disabled
- Each wave captures the button radius at the moment it starts
- Waves expand independently from their captured start radius
- Multiple waves can be active simultaneously with staggered timing
- iOS 17.0+ / macOS 13.0+
- Swift 6.1+
- Xcode 16.0+
- ColorfulX - For multicolor gradient backgrounds
This project is available under the MIT license. See the LICENSE file for more info.
Created by Mikhail Kogan (mikhailkogan17@gmail.com)
Contributions are welcome! Please feel free to submit a Pull Request.
