DEV Community

38 Reusable SwiftUI Components You Can Copy-Paste Into Your Project

Building iOS apps from scratch takes forever. You spend hours creating the same buttons, cards, and form fields for every project.

I put together a collection of 38 reusable SwiftUI components that you can literally copy-paste into any project.

What's Inside

Buttons (5 components)

// Primary button with loading state
PrimaryButton(title: "Continue", action: {
    // your action
}, isLoading: isLoading)

// Gradient button
GradientButton(title: "Get Started", action: {}, colors: [.purple, .blue])

// Floating Action Button
FloatingActionButton(icon: "plus", action: {}, color: .blue)
Enter fullscreen mode Exit fullscreen mode

Cards (5 components)

// Stats card with trend indicator
StatsCard(
    title: "Revenue",
    value: "$12,450",
    icon: "dollarsign.circle.fill",
    trend: "+12%",
    trendUp: true
)

// Profile card
ProfileCard(
    name: "John Doe",
    subtitle: "iOS Developer",
    avatarIcon: "person.circle.fill",
    action: { /* navigate */ }
)
Enter fullscreen mode Exit fullscreen mode

Forms (6 components)

// Styled text field with icon
StyledTextField(
    placeholder: "Email",
    text: $email,
    icon: "envelope"
)

// Secure field with visibility toggle
StyledSecureField(
    placeholder: "Password",
    text: $password
)

// Search bar
SearchBar(text: $searchText, onSubmit: { performSearch() })
Enter fullscreen mode Exit fullscreen mode

Lists (5 components)

// Settings-style row
SettingRow(
    icon: "wifi",
    title: "Wi-Fi",
    value: "Connected",
    iconColor: .blue
)

// Notification row with badge
NotificationRow(
    icon: "heart.fill",
    title: "New Like",
    message: "Someone liked your post",
    time: "5m ago",
    isUnread: true
)
Enter fullscreen mode Exit fullscreen mode

Navigation (5 components)

  • Custom NavigationBar
  • TabBar with badges
  • Segmented Control
  • Page Indicator
  • Breadcrumb

Modals (4 components)

// Bottom sheet
BottomSheet(isPresented: $showSheet) {
    YourContent()
}

// Toast notifications
Toast(message: "Saved!", type: .success)
Toast(message: "Error occurred", type: .error)
Enter fullscreen mode Exit fullscreen mode

Loaders (8 components)

// Spinning loader
SpinningLoader(color: .blue, size: 40)

// Circular progress
CircularProgress(progress: $progress)

// Skeleton loading
SkeletonCard()

// Full-screen loading overlay
LoadingOverlay(message: "Loading...", isLoading: isLoading)
Enter fullscreen mode Exit fullscreen mode

Requirements

  • iOS 15+
  • Swift 5.9+
  • Xcode 14+

Get the Components

All 38 components are available as a single package. Just copy the files you need into your project.

Get SwiftUI UI Components Pack


Follow me for more SwiftUI content:

Top comments (0)