Skip to content
Language Select preview
Rendered from the SwiftUI source on this page.

Language Select

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

A language-picker menu.

Navigation · SwiftUI · iOS 17

  • navigation
  • swiftui

The actual source

MenuLanguage.swift
// Language Select · syxUI · https://syxui.dev/components/menu-language
// 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 MenuLanguage: View { var body: some View { menuCard(240) { VStack(spacing: 0) { ForEach(Array([("English", "US", true), ("Español", "ES", false), ("Français", "FR", false)].enumerated()), id: \.offset) { i, l in HStack(spacing: 10) { Text(l.1).font(.system(size: 11, weight: .bold)).foregroundStyle(.white).frame(width: 26, height: 18).background(Color.primary.opacity(0.5), in: RoundedRectangle(cornerRadius: 4)); Text(l.0).font(.system(size: 15)); Spacer(); if l.2 { Image(systemName: "checkmark").font(.system(size: 13, weight: .semibold)).foregroundStyle(mnBlue) } }.padding(.horizontal, 14).padding(.vertical, 10); if i < 2 { Divider() } } } } } }
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17