Marker
Native marker composition, package imports, and editable Swift source.
Preview


Use it
Import SwiftCN to use CNMarker directly. This complete example also runs in the native component gallery.
import SwiftUI
import SwiftCN
struct MarkerExample: View {
var body: some View {
VStack(alignment: .leading, spacing: 12) {
VStack(alignment: .leading) {
CNMarker(variant: .inline) { CNMarkerIcon { Image(systemName: "checkmark") }; Text("Changes saved") }
CNMarker("Today", variant: .separator)
}
}
}
}Native behavior
Conversation status rows support inline, bordered, and labeled separator variants. Icons can be decorative. Wrap the content in a native Button or Link for interactive markers.
Style and compose
Visual recipes use .tw classes. Append classes: to override a recipe locally, or change the recipe in TWGlobalRules.named for your subtree. Native layout and interaction modifiers remain SwiftUI APIs. For control colors, append cn-tint-[primary], another theme token, or an interpolated Color.
Motion recipes are editable too: control-motion uses a 150 ms smooth response, disclosure-motion uses a 250 ms spring, and feedback-motion uses a 200 ms smooth response. Set a recipe to animate-none in your global rules to turn it off. Presets respect Reduce Motion. Static components stay still; native scrolling, drag tracking, and platform presentation keep their own gestures.
Action groups and card, dialog, and questionnaire footers stack when their content does not fit. The native layout preserves the same child controls during this change.
View builders preserve native child content. Native Button roles, labels, keyboard shortcuts, submit actions, and presentation modifiers still work. A string recipe does not replace a native control API or a typed chart mark.
Own the source
Copy the complete file below into your app alongside import SwiftCN. The file contains related composable parts from the same family. Its dependencies use public package APIs, so copied and imported components can coexist.
To own the styling engine too, download the complete source bundle. It contains every component, the .tw engine, its recipes, and the MIT license. Keep those files in one module and remove import SwiftCN from the usage example.
import SwiftUI
import SwiftCN
public enum CNMarkerVariant: Sendable { case inline, bordered, separator }
/// A conversation status or labeled separator. Wrap in a native Link or Button for actions.
public struct CNMarker<Content: View>: View {
private let variant: CNMarkerVariant
private let classes: TWClasses
private let content: Content
public init(variant: CNMarkerVariant = .inline, classes: TWClasses = "", @ViewBuilder content: () -> Content) {
self.variant = variant; self.classes = classes; self.content = content()
}
public init(_ title: LocalizedStringKey, variant: CNMarkerVariant = .inline, classes: TWClasses = "") where Content == Text {
self.init(variant: variant, classes: classes) { Text(title) }
}
public var body: some View {
VStack(spacing: 4) {
HStack(spacing: 8) {
if variant == .separator { CNSeparator() }
content
if variant == .separator { CNSeparator() }
}
if variant == .bordered { CNSeparator() }
}.tw(cn("marker", classes))
}
}
public struct CNMarkerIcon<Content: View>: View {
private let content: Content
public init(@ViewBuilder content: () -> Content) { self.content = content() }
public var body: some View { content.accessibilityHidden(true) }
}