Skip to content
Dropdown Open preview
Rendered from the SwiftUI source on this page.

Dropdown Open

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

An open dropdown with options.

Navigation · SwiftUI · iOS 17

  • navigation
  • swiftui

The actual source

DropdownOpen.swift
// Dropdown Open · syxUI · https://syxui.dev/components/menu-dropdown-open
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

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

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

struct DropdownOpen: View { var body: some View { VStack(spacing: 6) { HStack { Text("Medium").font(.system(size: 16)); Spacer(); Image(systemName: "chevron.up").font(.system(size: 13)).foregroundStyle(mnBlue) }.padding(.horizontal, 14).padding(.vertical, 12).overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(mnBlue, lineWidth: 1.5)); menuCard(300) { VStack(spacing: 0) { ForEach(Array(["Small", "Medium", "Large", "X-Large"].enumerated()), id: \.offset) { i, o in HStack { Text(o).font(.system(size: 15)).foregroundStyle(i == 1 ? mnBlue : .primary); Spacer(); if i == 1 { Image(systemName: "checkmark").font(.system(size: 13, weight: .semibold)).foregroundStyle(mnBlue) } }.padding(.horizontal, 14).padding(.vertical, 11); if i < 3 { Divider() } } } } }.frame(width: 300) } }
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17