.shadow()

iOS 13+

Adds a shadow effect beneath a view with customizable color, radius, and offset.

Visual Effects
Official Apple Documentation →
iOS User Coverage
97.2%
coverage

97.2% of iOS users can use this modifier

Version Compatibility
iOS 18.7
30.3% Supported
iOS 18.6
29.8% Supported
iOS 26.1
10.7% Supported
iOS 18.5
6.0% Supported
iOS 16.7
2.3% Supported
iOS 26.2
2.0% Supported
iOS 18.3
1.8% Supported
iOS 15.8
1.8% Supported
iOS 17.6
1.7% Supported
iOS 26.0
1.3% Supported

iOS 13+ required

Variants
.shadow(color:radius:x:y:)

Applies shadow with full customization

Parameters:
  • color: Color
  • radius: CGFloat
  • x: CGFloat
  • y: CGFloat
.shadow(radius:)

Applies shadow with default black color

Parameters:
  • radius: CGFloat
Code Examples

Basic Shadow

Add a simple shadow with default settings

Text("Hello, World!")
    .padding()
    .background(.white)
    .shadow(radius: 5)

Custom Shadow

Create a colored shadow with offset

RoundedRectangle(cornerRadius: 10)
    .fill(.white)
    .frame(width: 200, height: 100)
    .shadow(color: .blue.opacity(0.3), radius: 10, x: 0, y: 5)

Elevated Card

Multiple shadows for depth effect

VStack {
    Text("Card")
}
.padding()
.background(.white)
.shadow(color: .black.opacity(0.1), radius: 2, x: 0, y: 1)
.shadow(color: .black.opacity(0.15), radius: 10, x: 0, y: 5)

Loading related modifiers...

Frequently Asked Questions

What iOS version is required for .shadow()?

The .shadow() modifier requires iOS 13 or later. This means 97.2% of current iOS users can use this modifier.

How do I use .shadow() in SwiftUI?

Apply the .shadow() modifier to any SwiftUI view. Check the code examples above for usage patterns.

Where can I learn more?

Visit the official Apple documentation for detailed information.

Explore More SwiftUI Modifiers