@@ -101,6 +101,16 @@ struct Text<R: RootRegistry>: View {
101
101
102
102
@ObservedElement private var element : ElementNode
103
103
104
+ /// A string value to use as the text content.
105
+ ///
106
+ /// In most cases, you should provide the content as a child of the element.
107
+ ///
108
+ /// ```html
109
+ /// <Text>Hello, world!</Text>
110
+ /// ```
111
+ @_documentation ( visibility: public)
112
+ @Attribute ( " content " ) private var content : String ?
113
+
104
114
/// A string value to use as the text content without modification.
105
115
///
106
116
/// In some cases, whitespaces and newlines in the text content are trimmed.
@@ -201,6 +211,7 @@ struct Text<R: RootRegistry>: View {
201
211
202
212
init ( element: ElementNode , overrideStylesheet: ( any StylesheetProtocol ) ? ) {
203
213
self . _element = . init( element: element)
214
+ self . _content = . init( wrappedValue: nil , " content " , element: element)
204
215
self . _verbatim = . init( wrappedValue: nil , " verbatim " , element: element)
205
216
self . _date = . init(
206
217
wrappedValue: nil ,
@@ -253,7 +264,9 @@ struct Text<R: RootRegistry>: View {
253
264
}
254
265
255
266
private var text : SwiftUI . Text {
256
- if let verbatim {
267
+ if let content {
268
+ return SwiftUI . Text ( content)
269
+ } else if let verbatim {
257
270
return SwiftUI . Text ( verbatim: verbatim)
258
271
} else if let date {
259
272
return SwiftUI . Text ( date, style: dateStyle)
0 commit comments