Skip to content

jaikeerthick/jetpack-compose-waves

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A lightweight, customizable, animated wavy background composable for Jetpack Compose. Perfect for headers, footers, sections, onboarding screens, and aesthetic UI elements.

πŸŽ₯ Live Preview

🌊 Features

  • βœ… Crest-touching waves (top or bottom)
  • βœ… Smooth infinite horizontal wave motion
  • βœ… Optional breathing vertical animation
  • βœ… Auto-scales for any height (even 1.dp)
  • βœ… Zero clipping / zero cut-outs
  • βœ… Easy presets (WaveStyle)
  • βœ… Highly customizable
  • βœ… No dependencies
  • βœ… MIT license

πŸš€ Quick Start

Just copy these files into your project:

waves/
└── com/jaikeerthick/waves/
    β”œβ”€β”€ WavyBackground.kt
    β”œβ”€β”€ WaveDirection.kt
    β”œβ”€β”€ WaveStyle.kt
    └── WavePreviews.kt

No setup required. No Gradle configuration. No library installation.

πŸͺ„ Usage

1. Basic Example

WavyBackground(
    modifier = Modifier
        .fillMaxWidth()
        .height(180.dp),
    color = Color(0xFF4FC3F7)
)

2. Wave at Top ⬆

WavyBackground(
    modifier = Modifier
        .fillMaxWidth()
        .height(150.dp),
    waveDirection = WaveDirection.Top,
    color = Color(0xFF80DEEA)
)

3. Wave at Bottom ⬇

WavyBackground(
    modifier = Modifier
        .fillMaxWidth()
        .height(150.dp),
    waveDirection = WaveDirection.Bottom,
    color = Color(0xFF26C6DA)
)

Wave Style Presets

WavyBackground(
    style = WaveStyle.Calm
)

Available Presets

Style Description
Calm Slow, soft, minimal movement
Gentle Balanced, default preset
Energetic Fast-moving, deeper waves

βš™ Advanced Customization

WavyBackground(
    waveCount = 7,
    waveAmplitude = 24.dp,
    waveSpeed = 900f,
    verticalOscillationSpeed = 1400f,
    reverseDirection = true,
    animateWaveShape = true
)

Parameters

Name Description
waveDirection Top or Bottom
waveCount Number of waves across the width
waveAmplitude Height of the wave crests/troughs
waveSpeed Duration (ms) for a full horizontal loop
verticalOscillationSpeed Speed of breathing animation
reverseDirection Reverse horizontal motion
animateWaveShape Enable/disable breathing effect

πŸ§ͺ Previews

To preview waves in Android Studio:

@Preview
@Composable
fun PreviewWaves() {
    WavyBackground(
        modifier = Modifier
            .fillMaxWidth()
            .height(180.dp),
        style = WaveStyle.Gentle
    )
}

🧩 How It Works

  • Uses a Canvas & trigonometric BΓ©zier-like curve drawing
  • Ensures the crest touches the edge cleanly
  • Auto-scales based on the composable height
  • Smooth per-frame animation using withFrameMillis
  • Fully optimized β€” no allocations per frame

❀️ Contribute

Pull requests are welcome! Here are great ways to contribute:

  • New wave presets
  • Additional wave shapes (multi-layer waves?)
  • Theming support
  • Performance improvements
  • Documentation improvements

⭐ Support the Project

If this helped you, consider giving the repo a star ⭐ β€” it motivates continued updates!

πŸ“„ License

This project is licensed under the terms of the MIT License.
See the full license here: LICENSE

MIT License
Copyright (c) 2025

About

Add beautiful, fluid, animated waves to your Jetpack Compose app with just one composable πŸͺ„. No library install β€” just copy the files and start using animated waves in seconds πŸ”₯.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages