[SUI] Formularios (Form)

Published: (January 30, 2026 at 04:42 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Form

Form es un contenedor para agrupar controles, principalmente usados para la configuración de alguna funcionalidad.
Presenta los controles en un List con estilo grouped, con relleno alrededor.
Al igual que el componente List, Form también puede separar el contenido por secciones usando Section.

Ejemplo

enum NotifyMeAboutType {
    case directMessages, mentions, anything
}

enum ProfileImageSize {
    case large, medium, small
}

struct ContentView: View {
    @State private var notifyMeAbout: NotifyMeAboutType = .anything
    @State private var playNotificationSounds = false
    @State private var sendReadReceipts = false
    @State private var profileImageSize: ProfileImageSize = .small

    var body: some View {
        NavigationView {
            Form {
                Section(header: Text("Notifications"),
                        footer: Text("¿Qué quieres que te notifique?")) {
                    Picker("Notify Me About", selection: $notifyMeAbout) {
                        Text("Direct Messages").tag(NotifyMeAboutType.directMessages)
                        Text("Mentions").tag(NotifyMeAboutType.mentions)
                        Text("Anything").tag(NotifyMeAboutType.anything)
                    }
                    Toggle("Play notification sounds", isOn: $playNotificationSounds)
                    Toggle("Send read receipts", isOn: $sendReadReceipts)
                }
                Section(header: Text("User Profiles")) {
                    Picker("Profile Image Size", selection: $profileImageSize) {
                        Text("Large").tag(ProfileImageSize.large)
                        Text("Medium").tag(ProfileImageSize.medium)
                        Text("Small").tag(ProfileImageSize.small)
                    }
                    Button("Clear Image Cache") {}
                }
            }
        }
    }
}
Back to Blog

Related posts

Read more »

[SUI] LabeledContent

LabeledContenthttps://developer.apple.com/documentation/swiftui/labeledcontent es un contenedor que adjunta una etiqueta a un control. Uso básico swift struct C...

[SUI] Barra de búsqueda

Barra de búsqueda en NavigationStack Un NavigationStack puede incluir una barra de búsqueda mediante el modificador searchable. Su firma es: swift searchable t...