liquid-glass by casper-studios/casper-marketplace
npx skills add https://github.com/casper-studios/casper-marketplace --skill liquid-glass使用苹果的液态玻璃设计和 HIG 构建原生 macOS/iOS 应用程序。
┌─────────────────────────────────────────┐
│ 玻璃层(导航/控件) │ ← 仅此处使用玻璃效果
├─────────────────────────────────────────┤
│ 内容层(您的应用) │ ← 内容本身绝不用玻璃效果
└─────────────────────────────────────────┘
玻璃效果仅用于悬浮在内容上方的导航。绝不可用于内容本身。
// 带材质的卡片
.padding(24)
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
// 材质选项(从最薄到最厚):
// .ultraThinMaterial, .thinMaterial, .regularMaterial (默认), .thickMaterial, .ultraThickMaterial
// 基础用法
Button("操作") { }.glassEffect()
// 变体
.glassEffect(.regular) // 标准 UI
.glassEffect(.clear) // 仅用于媒体背景
.glassEffect(.identity) // 禁用
// 交互式(添加弹跳/闪烁效果)
Button("点击") { }.glassEffect(.regular.interactive())
// 多个玻璃效果元素 - 必须包装在容器中
GlassEffectContainer(spacing: 30) {
HStack {
Button("A") { }.glassEffect()
Button("B") { }.glassEffect()
}
}
// 按钮样式
Button("取消") { }.buttonStyle(.glass) // 次要按钮
Button("保存") { }.buttonStyle(.glassProminent).tint(.blue) // 主要按钮
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
VStack(alignment: .leading, spacing: 12) {
HStack {
ZStack {
Circle().fill(color.opacity(0.15)).frame(width: 36, height: 36)
Image(systemName: icon).foregroundStyle(color)
}
Spacer()
}
Text(value).font(.system(size: 28, weight: .bold, design: .rounded))
Text(label).font(.caption).foregroundStyle(.secondary)
}
.padding(20)
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
HStack { content }
.padding(16)
.background(isHovering ? Color.primary.opacity(0.04) : .clear)
.background(.quaternary.opacity(0.5), in: RoundedRectangle(cornerRadius: 12, style: .continuous))
.onHover { withAnimation(.easeInOut(duration: 0.15)) { isHovering = $0 } }
HStack(spacing: 8) {
Circle().fill(isActive ? .green : .orange).frame(width: 8, height: 8)
Text(status).font(.caption).fontWeight(.medium)
}
.padding(.horizontal, 12).padding(.vertical, 8)
.background(.regularMaterial, in: Capsule())
ZStack {
Circle().fill(color.opacity(0.15)).frame(width: 32, height: 32)
Image(systemName: icon).font(.system(size: 14, weight: .semibold)).foregroundStyle(color)
}
// 始终使用 .continuous
RoundedRectangle(cornerRadius: 16, style: .continuous) // 卡片
RoundedRectangle(cornerRadius: 12, style: .continuous) // 行
RoundedRectangle(cornerRadius: 8, style: .continuous) // 小元素
Capsule() // 药丸状、徽章
Circle() // 图标
// 语义前景色
.foregroundStyle(.primary) // 主要内容
.foregroundStyle(.secondary) // 副标题
.foregroundStyle(.tertiary) // 时间戳
// 背景色
.background(.quaternary)
.background(.quaternary.opacity(0.5))
// 强调色含义
Color.blue // 主要操作、选中状态
Color.green // 成功、活跃状态
Color.orange // 警告、加载中
Color.red // 破坏性操作、错误
Color.purple // 高级功能、AI
Color.cyan // 安全
// 着色背景:始终使用 15% 不透明度
.fill(color.opacity(0.15))
.font(.largeTitle).fontWeight(.bold) // 页面标题
.font(.headline).fontWeight(.semibold) // 区块标题
.font(.subheadline).fontWeight(.medium) // 行标题
.font(.body) // 内容(默认 17pt)
.font(.caption) // 元数据
.font(.caption2) // 时间戳
.font(.system(size: 28, weight: .bold, design: .rounded)) // 统计数据
规则: 最小 11pt。避免使用 Ultralight/Thin/Light 字重。使用系统字体以支持动态类型。
// 标准值:4, 8, 12, 16, 20, 24, 32, 40, 48
.padding(24) // 卡片
.padding(16) // 行
.padding(.horizontal, 12).padding(.vertical, 8) // 徽章
// 规则:外部间距 ≥ 内部间距
VStack(spacing: 24) { CardView().padding(20) } // 正确示例
// 首选:层次渲染以增强深度感
Image(systemName: icon).symbolRenderingMode(.hierarchical).foregroundStyle(color)
// 字重与附近文本匹配
Image(systemName: "gear").font(.system(size: 14, weight: .semibold))
// 最小值:44pt × 44pt
Button { } label: { Image(systemName: "gear") }
.frame(minWidth: 44, minHeight: 44)
// 悬停
.onHover { withAnimation(.easeInOut(duration: 0.15)) { isHovering = $0 } }
// 弹簧动画
withAnimation(.spring(response: 0.3)) { }
withAnimation(.bouncy) { }
// 入场动画
.opacity(appeared ? 1 : 0).offset(y: appeared ? 0 : 10)
.onAppear { withAnimation(.spring(response: 0.5, dampingFraction: 0.8)) { appeared = true } }
应做:
.regularMaterial.continuousGlassEffectContainer 中.hierarchical 模式的 SF Symbols不应做:
系统自动处理:
如需手动覆盖:
@Environment(\.accessibilityReduceTransparency) var reduceTransparency
.glassEffect(reduceTransparency ? .identity : .regular)
有关详细模式和示例,请参阅:
每周安装量
97
代码仓库
GitHub 星标数
9
首次出现
14 天前
安全审计
安装于
opencode97
github-copilot97
codex97
kimi-cli97
amp97
cline97
Build native macOS/iOS applications with Apple's Liquid Glass design and HIG.
┌─────────────────────────────────────────┐
│ GLASS LAYER (Navigation/Controls) │ ← Glass here ONLY
├─────────────────────────────────────────┤
│ CONTENT LAYER (Your App) │ ← Never glass here
└─────────────────────────────────────────┘
Glass is ONLY for navigation floating above content. Never on content itself.
// Card with material
.padding(24)
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
// Material options (lightest → heaviest):
// .ultraThinMaterial, .thinMaterial, .regularMaterial (default), .thickMaterial, .ultraThickMaterial
// Basic
Button("Action") { }.glassEffect()
// Variants
.glassEffect(.regular) // Standard UI
.glassEffect(.clear) // Media backgrounds only
.glassEffect(.identity) // Disabled
// Interactive (adds bounce/shimmer)
Button("Tap") { }.glassEffect(.regular.interactive())
// Multiple glass elements - MUST wrap in container
GlassEffectContainer(spacing: 30) {
HStack {
Button("A") { }.glassEffect()
Button("B") { }.glassEffect()
}
}
// Button styles
Button("Cancel") { }.buttonStyle(.glass) // Secondary
Button("Save") { }.buttonStyle(.glassProminent).tint(.blue) // Primary
VStack(alignment: .leading, spacing: 12) {
HStack {
ZStack {
Circle().fill(color.opacity(0.15)).frame(width: 36, height: 36)
Image(systemName: icon).foregroundStyle(color)
}
Spacer()
}
Text(value).font(.system(size: 28, weight: .bold, design: .rounded))
Text(label).font(.caption).foregroundStyle(.secondary)
}
.padding(20)
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
HStack { content }
.padding(16)
.background(isHovering ? Color.primary.opacity(0.04) : .clear)
.background(.quaternary.opacity(0.5), in: RoundedRectangle(cornerRadius: 12, style: .continuous))
.onHover { withAnimation(.easeInOut(duration: 0.15)) { isHovering = $0 } }
HStack(spacing: 8) {
Circle().fill(isActive ? .green : .orange).frame(width: 8, height: 8)
Text(status).font(.caption).fontWeight(.medium)
}
.padding(.horizontal, 12).padding(.vertical, 8)
.background(.regularMaterial, in: Capsule())
ZStack {
Circle().fill(color.opacity(0.15)).frame(width: 32, height: 32)
Image(systemName: icon).font(.system(size: 14, weight: .semibold)).foregroundStyle(color)
}
// Always use .continuous
RoundedRectangle(cornerRadius: 16, style: .continuous) // Cards
RoundedRectangle(cornerRadius: 12, style: .continuous) // Rows
RoundedRectangle(cornerRadius: 8, style: .continuous) // Small elements
Capsule() // Pills, badges
Circle() // Icons
// Semantic foreground
.foregroundStyle(.primary) // Main content
.foregroundStyle(.secondary) // Subtitles
.foregroundStyle(.tertiary) // Timestamps
// Backgrounds
.background(.quaternary)
.background(.quaternary.opacity(0.5))
// Accent meanings
Color.blue // Primary actions, selection
Color.green // Success, active
Color.orange // Warning, loading
Color.red // Destructive, error
Color.purple // Premium, AI
Color.cyan // Security
// Tinted backgrounds: always 15% opacity
.fill(color.opacity(0.15))
.font(.largeTitle).fontWeight(.bold) // Page titles
.font(.headline).fontWeight(.semibold) // Section headers
.font(.subheadline).fontWeight(.medium) // Row titles
.font(.body) // Content (17pt default)
.font(.caption) // Metadata
.font(.caption2) // Timestamps
.font(.system(size: 28, weight: .bold, design: .rounded)) // Stats
Rules: Min 11pt. Avoid Ultralight/Thin/Light. Use system fonts for Dynamic Type.
// Standard values: 4, 8, 12, 16, 20, 24, 32, 40, 48
.padding(24) // Cards
.padding(16) // Rows
.padding(.horizontal, 12).padding(.vertical, 8) // Badges
// Rule: external spacing ≥ internal spacing
VStack(spacing: 24) { CardView().padding(20) } // Correct
// Preferred: hierarchical for depth
Image(systemName: icon).symbolRenderingMode(.hierarchical).foregroundStyle(color)
// Match weight to nearby text
Image(systemName: "gear").font(.system(size: 14, weight: .semibold))
// MINIMUM: 44pt × 44pt
Button { } label: { Image(systemName: "gear") }
.frame(minWidth: 44, minHeight: 44)
// Hover
.onHover { withAnimation(.easeInOut(duration: 0.15)) { isHovering = $0 } }
// Spring
withAnimation(.spring(response: 0.3)) { }
withAnimation(.bouncy) { }
// Entry
.opacity(appeared ? 1 : 0).offset(y: appeared ? 0 : 10)
.onAppear { withAnimation(.spring(response: 0.5, dampingFraction: 0.8)) { appeared = true } }
DO:
.regularMaterial for cards/toolbars.continuous on ALL rounded rectanglesGlassEffectContainer.hierarchicalDON'T:
System handles automatically:
Manual override if needed:
@Environment(\.accessibilityReduceTransparency) var reduceTransparency
.glassEffect(reduceTransparency ? .identity : .regular)
For detailed patterns and examples, see:
Weekly Installs
97
Repository
GitHub Stars
9
First Seen
14 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode97
github-copilot97
codex97
kimi-cli97
amp97
cline97
agentation - AI智能体可视化UI反馈工具,连接人眼与代码的桥梁
5,400 周安装