You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Rounded corner-family, you can configure the radius of how much rounded corner you want. The default Neu shape is Punched.Rounded(radius = 12.dp).
The Punched shape would work with Cards, Buttons, etc.
You should use Modifier.clip() while using Pressed shape, because there's known issue of shadow placeents for Pressed shape. Check the sample app for more code snippets.
P.S: Even I'm yet to experiment it with all UI elements.
2. Shadows
The idea of Neumorphism UI is simple, just create two shadows light and dark and draw those around the UI component from top-left and bottom-right corners. Just make sure you are using the same colors for your Surface and for the UI elements.
You can configure the shadow insets, color and elevation
Params
Description
lightShadowColor
Default value - Color.White - Set the light shadow color you want
darkShadowColor
Default value - Color.Gray - Set the dark shadow color you want.
elevation
Default value - 6.dp - Set the elevation for the shadow.
neuInsets
Default values - NeuInsets(6.dp, 6.dp) - Insets = Horizontal, Vertical - Placements of your shadows i.e How do you want to place your
strokeWidth
Default value - 6.dp - Stroke width of the internal shadows. Stroke width is for only Pressed and Punched.
Add LightSource option and place the shadows accordingly (It is, by default, top-left right now)
Migrate from RenderScript
Fix clipping and shadow positioning with insets
Update sample app and code with Jetpack-Compose guidelines
FAQs
What's the idea? Is there any performance overhead?
Idea is simple - just draw the two shadows light and dark around the UI element. I'm using RenderScript to blur two GradientDrawables. I know it's going to be deprecated in the Android 12. I'll surely update the code to migrate from RenderScript. If Renderscript throws any exception / not able to blur the drawable, I'm using StackBlur algorithm from Mario Klingemann as a workaround.
Does this library work with all the Jetpack Compose UI elements?
I can't surely say. I'm already experimenting drawing shadow on UIs with Jetpack Compose and improving this library. I request you to try and please help to make it work.
When can I use this?
You can use this right now if you want to play with shiny Neumorphism UI. The library is in alpha and there are some known issues regarding shadow rendering and clipping. Please raise issue if you found any.
Contribution Guide
Please contribute! I'm just getting my hands dirty with Jetpack-Compose.
There is heavy chance that the code may/may not be correct/holding best practices. I request you to contribute/ raise issues/ send PRs so I can learn too.
You can use the Github Discussion to discuss and ask questions. Or you can reach out to me on Twitter @CuriousNikhil.