prototype
MAmattpocock/skills337k近 7 天新增 4,978 个 star
Add a Dynamic Island-style notch UI to a macOS app. Use this skill whenever the user wants to create a notch overlay, notch extender, Dynamic Island for Mac, notch indicator, or any UI that extends from the MacBook notch area. Also trigger when the user mentions "notch shape", "notch window", "notch cutout", "notch panel", "recording indicator near the notch", "Dynamic Island style", or wants to show status/content that appears to emerge from the hardware notch. This covers the NSPanel setup, the NotchShape with concave Bezier ear curves, screen positioning math, spring animations, and show/hide choreography.
This skill creates a Dynamic Island-style overlay that extends from the MacBook's hardware notch. The overlay is a transparent floating panel positioned flush against the top of the screen, using a custom shape with concave "ear" curves that blend seamlessly with the physical notch cutout.
The implementation has 3 parts:
NotchWindow (NSPanel subclass) -- a borderless, transparent, click-through panel at CGShieldingWindowLevel that sits above everything, including the menu barNotchShape (SwiftUI Shape) -- draws the Dynamic Island silhouette with concave quadratic Bezier curves at the top corners and convex rounded corners at the bottomThe MacBook notch is a black rectangle at the top-center of the screen. By placing a black-filled NotchShape at that exact position at the highest window level, it visually extends the notch area. Content inside the shape appears to "emerge" from the hardware notch.
The key positioning math:
// Use full screen frame (not visibleFrame) to include the menu bar / notch area
let screen = NSScreen.main!
let x = screen.frame.origin.x + (screen.frame.width - totalWidth) / 2
let y = screen.frame.origin.y + screen.frame.height - totalHeight
Using screen.frame (not screen.visibleFrame) is critical -- visibleFrame excludes the menu bar area where the notch lives.
references/NotchWindow.swift -- Drop-in NSPanel subclass with show/hide and positioningreferences/NotchShape.swift -- The Dynamic Island shape with animatable corner radiiCopy references/NotchShape.swift. This is a SwiftUI Shape with two configurable corner radii:
topCornerRadius (default 10) -- the concave "ear" curves at the top that mimic the hardware notch's inverse cornersbottomCornerRadius (default 16) -- the standard convex rounded corners at the bottomBoth are animatable via animatableData, so SwiftUI can smoothly interpolate shape changes.
Build whatever you want to show inside the notch. The content should be clipped to NotchShape and filled with black background:
struct NotchContentView: View {
var isVisible: Bool
var body: some View {
HStack {
Image(systemName: "mic.fill")
.foregroundStyle(.red)
Text("Recording")
.font(.system(size: 13, weight: .medium))
.foregroundStyle(.white)
}
.frame(width: isVisible ? 200 : 0)
.frame(height: 32)
.background(NotchShape().fill(.black))
.clipShape(NotchShape())
.animation(.spring(response: 0.35, dampingFraction: 0.75), value: isVisible)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
}
Copy references/NotchWindow.swift. This is a generic NSPanel that:
CGShieldingWindowLevel (above everything)// Create once and reuse
let notchWindow = NotchWindow()
// Show with your content
let content = NotchContentView(isVisible: true)
notchWindow.showNotch(content: content)
// Hide with spring collapse animation
notchWindow.hideNotch()
The Dynamic Island effect comes from a specific animation sequence:
Show:
orderFront)isVisible toggles to true.spring(response: 0.35, dampingFraction: 0.75)This two-step approach (instant window, then animated content) is necessary because SwiftUI needs the view to be in the hierarchy before it can animate.
Hide (3-step choreography):
isVisible = false -- triggers the spring width collapse to 0orderOut)The delays are tuned so each animation completes before the next starts. This creates the smooth "shrink into the notch" effect.
// Step 1: collapse content
state.isExpanded = false
// Step 2: shrink width
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
state.isVisible = false
}
// Step 3: remove window
DispatchQueue.main.asyncAfter(deadline: .now() + 0.65) {
window.orderOut(nil)
}
| Property | Value | Why |
|---|---|---|
| Window level | CGShieldingWindowLevel() | Above everything including menu bar |
| Position origin | NSScreen.main.frame (not visibleFrame) | Must include the notch/menu bar area |
| Horizontal | Centered: (screen.width - totalWidth) / 2 | Aligned with the hardware notch |
| Vertical | Flush top: screen.height - totalHeight | Top edge touches the screen edge |
| Collection behavior | .stationary, .canJoinAllSpaces, .fullScreenAuxiliary, .ignoresCycle | Doesn't move with Spaces, survives fullscreen, hidden from Cmd+Tab |
Not all Macs have a notch (e.g., external displays, older MacBooks). You can detect this:
var hasNotch: Bool {
guard let screen = NSScreen.main else { return false }
// Notch Macs have a safe area inset at the top
return screen.safeAreaInsets.top > 0
}
For non-notch displays, fall back to a floating pill at the bottom of the screen using screen.visibleFrame and standard .floating window level.
MAmattpocock/skills337k近 7 天新增 4,978 个 star
AFaffaan-m/ECC315k近 7 天新增 4,381 个 star
FIfirecrawl/firecrawl215k近 7 天新增 5,595 个 star
ANanthropics/skills203k近 7 天新增 3,265 个 star
用 React、Tailwind 和 shadcn/ui 构建多组件页面。
ANanthropics/skills203k近 7 天新增 3,265 个 star