Skip to content
Filter Sheet preview
Rendered from the SwiftUI source on this page.

Filter Sheet

From syxUI — written for both platforms, not translated between them.

A filter sheet with chips and Apply.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

FilterSheet.swift
// Filter Sheet · syxUI · https://syxui.dev/components/sheet-filter
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let shBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

func shCard<C: View>(_ w: CGFloat, radius: CGFloat = 18, @ViewBuilder _ c: () -> C) -> some View {
    c().frame(width: w).background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: radius, style: .continuous)).overlay(RoundedRectangle(cornerRadius: radius, style: .continuous).stroke(Color.primary.opacity(0.07), lineWidth: 1)).shadow(color: .black.opacity(0.05), radius: 12, y: 5)
}

// Filter sheet
struct FilterSheet: View {
    var body: some View {
        shCard(330, radius: 22) {
            VStack(alignment: .leading, spacing: 14) {
                Capsule().fill(Color.primary.opacity(0.2)).frame(width: 36, height: 5).frame(maxWidth: .infinity)
                Text("Filter").font(.system(size: 18, weight: .bold))
                HStack(spacing: 8) { ForEach(Array(["All", "New", "Sale", "Popular"].enumerated()), id: \.offset) { i, t in Text(t).font(.system(size: 13, weight: .medium)).foregroundStyle(i == 1 ? .white : .primary).padding(.horizontal, 14).padding(.vertical, 8).background(i == 1 ? shBlue : Color.primary.opacity(0.06), in: Capsule()) } }
                Text("Apply Filters").font(.system(size: 16, weight: .semibold)).foregroundStyle(.white).frame(maxWidth: .infinity).padding(.vertical, 13).background(shBlue, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
            }.padding(18)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17