Swiftpack.co - Package - costachung/neumorphic

Neumorphic SwiftUI : Neumorphism Soft UI

Neumorphic is a SwiftUI utility to build Neumorphism Soft UI easily using custom view modifier and custom button style. It supports all shapes.

Hi, I’m Costa. It is simple to create outer shadow in SwiftUI by writing two lines of code. However, we can’t easily create inner shadow in SwiftUI. That’s the reason why I build this tool to make it simple and reusable.

Image of Neumorphic SwiftUI


Requirements .iOS(.v13),.macOS(.v10_15)

Swift Package Manager

  1. In Xcode, open your project and navigate to File → Swift Packages → Add Package Dependency.
  2. Paste the repository URL (https://github.com/costachung/neumorphic/) and click Next.
  3. For Rules, select version.
  4. Click Finish.

Swift Package

.package(url: "https://github.com/costachung/neumorphic/", .upToNextMajor(from: "1.0.0"))


Import Neumorphic package to your view.

import Neumorphic

Simply use .softOuterShadow and .softInnerShadow methods to create outer shadow and inner shadow respectively.

Create Rounded Rectangle with Outer Shadow

Neumorphic SwiftUI Outer Shadow

RoundedRectangle(cornerRadius: 20).fill(Neumorphic.shared.mainColor()).softOuterShadow()

Create Rounded Rectangle with Inner Shadow

Neumorphic SwiftUI Inner Shadow

RoundedRectangle(cornerRadius: 20).fill(Neumorphic.shared.mainColor()).softInnerShadow(RoundedRectangle(cornerRadius: 20))

Create Circles

Neumorphic SwiftUI Circles

  HStack {

Create Soft Button

Neumorphic SwiftUI Button

Button(action: {}) {
    Text("Soft Button").fontWeight(.bold)
.softButtonStyle(RoundedRectangle(cornerRadius: 20))

Create Soft Button with custom style

Neumorphic SwiftUI Button

HStack {
    Button(action: {}) {
        Image(systemName: "heart.fill")

    Button(action: {}) {
        Image(systemName: "heart.fill")
    }.softButtonStyle(Circle(), mainColor: Color.red, textColor: Color.white, darkShadowColor: Color(rgb: 0x993333, alpha: 1), lightShadowColor:Color("redButtonLightShadow"))



You can change the color, spread of the shadow, and the shadow radius of the inner shadow.

softInnerShadow<S : Shape>(_ content: S, darkShadow: Color, lightShadow: Color, spread: CGFloat, radius: CGFloat)


You can change the color, offset of the shadow, and the shadow radius of the outer shadow.

softOuterShadow(darkShadow: Color, lightShadow: Color, offset: CGFloat, radius:CGFloat)

For example, Neumorphic SwiftUI Search bar

            ZStack {
                RoundedRectangle(cornerRadius: 30).fill(mainColor)
                            .softInnerShadow(RoundedRectangle(cornerRadius: 30), darkShadow: darkShadow, lightShadow: lightShadow, spread: 0.05, radius: 2)
                    Image(systemName: "magnifyingglass").foregroundColor(secondaryColor).font(Font.body.weight(.bold))
                    Text("Search ...").foregroundColor(secondaryColor).fontWeight(.bold)
            }.frame(width: 300, height:50)

Or, something like this:

Neumorphic SwiftUI bar chart

ZStack(alignment: .bottom){
                RoundedRectangle(cornerRadius: 20).fill(mainColor)
                .softInnerShadow(RoundedRectangle(cornerRadius: 20), darkShadow: darkShadow, lightShadow: lightShadow, spread: 0.3, radius: 2)
                .frame(width: 30, height:150)
                RoundedRectangle(cornerRadius: 20).fill(barColor)
                    .frame(width: 30, height:100)

Example Project

Check out the neumorphic-ios-example XCode project to see how to build neumorphic UI and buttons. If you use the default shadow colors of Neumorphic, you can also get dark mode support for free.




Neumorphic Package is released under the MIT license. See the LICENSE file for more info.


Stars: 23


Used By

Total: 0


Initial Release - 2020-03-23 14:41:12

Initial Release

Changes - 2020-03-23 10:48:39

Remove default button style