
Poll Message
From syxUI — written for both platforms, not translated between them.
An in-chat poll with options and live result bars.
Chat · SwiftUI · iOS 17
- chat
- swiftui
The actual source
ChatPoll.swift
// Poll Message · syxUI · https://syxui.dev/components/chat-poll
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
// Poll message
struct ChatPoll: View {
let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
let opts = [("Friday night", 0.6), ("Saturday brunch", 0.3), ("Sunday hike", 0.1)]
var body: some View {
HStack {
VStack(alignment: .leading, spacing: 10) {
Text("When should we meet?").font(.system(size: 15, weight: .semibold))
ForEach(Array(opts.enumerated()), id: \.offset) { _, o in
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(o.0).font(.system(size: 14))
Spacer()
Text("\(Int(o.1 * 100))%").font(.system(size: 13, weight: .medium)).foregroundStyle(.secondary)
}
GeometryReader { g in
ZStack(alignment: .leading) {
Capsule().fill(Color.primary.opacity(0.08)).frame(height: 6)
Capsule().fill(blue).frame(width: g.size.width * o.1, height: 6)
}
}.frame(height: 6)
}
}
}
.padding(14).frame(width: 250)
.background(Color(.systemGray6), in: RoundedRectangle(cornerRadius: 18, style: .continuous))
Spacer(minLength: 20)
}
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


