BeamBorder is a tiny Swift Package that adds an animated beam border to any SwiftUI view. The repository includes a reusable beamBorder view modifier plus a small iOS demo app with a live configurator.
Add BeamBorder with Swift Package Manager. In Xcode, choose File → Add Package Dependencies… and enter:
https://github.com/phillippbertram/BeamBorder.git
Or add it to your Package.swift:
dependencies: [
.package(url: "https://github.com/phillippbertram/BeamBorder.git", from: "1.0.0")
]Then add the library product to your app target and import it where needed:
import BeamBorder
import SwiftUIBeamBorder uses SwiftUI's KeyframeAnimator and therefore requires iOS 17, macOS 14, tvOS 17, watchOS 10, or visionOS 1 (and newer).
Text("Ask anything")
.padding(16)
.background(.gray.opacity(0.1), in: .rect(cornerRadius: 20))
.beamBorder()Customize the border with BeamBorderConfiguration:
let configuration = BeamBorderConfiguration(
border: .orange,
showsBaseBorder: true,
beamColors: [.yellow, .orange, .pink, .purple],
beamDirection: .inward,
beamBlur: 18,
cornerRadius: 20,
borderLineWidth: 0.6,
baseBorderLineWidth: 0.8,
animationDuration: 3
)
Text("Custom beam")
.padding(16)
.background(.gray.opacity(0.1), in: .rect(cornerRadius: 20))
.beamBorder(configuration)BeamBorderConfiguration lets you adjust:
border: the animated stroke color.showsBaseBorder: whether a subtle static fallback border is visible.beamColors: the glow colors used by the moving beam.beamDirection: whether the glow bleeds.inward(default),.outwardlike a halo, or to.bothsides of the border. The outward halo renders outside the view's bounds, so clipping ancestors (e.g.clipped()or scroll views) may cut it off.beamBlur: the softness of the glow.cornerRadius: the rounded rectangle radius.borderLineWidthandbaseBorderLineWidth: stroke widths.animationDuration: how long one full beam rotation takes.
.inward (default) |
.outward |
.both |
|---|---|---|
![]() |
![]() |
![]() |
The package also includes small presets:
.beamBorder(.default)
.beamBorder(.visibleBaseBorder)
.beamBorder(.outwardGlow)
.beamBorder(.sunrise)Open Examples/BeamBorderExample/BeamBorderExample.xcodeproj to run the included sample app. It imports the local package, shows a compact prompt card, send-state handling, and several SwiftUI previews for light, dark, large Dynamic Type, disabled beam, visible base border, and alternative palette states.
If you find BeamBorder useful, consider buying me a coffee:
BeamBorder is available under the MIT license. See LICENSE for details.


