<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Text/init(_:style:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4TextV_5styleAC10Foundation4DateV_AC0F5StyleVtcfc"
  },
  "title" : "init(_:style:)"
}
-->

# init(_:style:)

Creates an instance that displays localized dates and times using a specific style.

```
init(_ date: Date, style: Text.DateStyle)
```

## Parameters

`date`

The target date to display.

`style`

The style used when displaying a date.

## Discussion> Note: In a widget, a `Text` that uses the ``doc://com.apple.SwiftUI/documentation/SwiftUI/Text/DateStyle/relative``,
> ``doc://com.apple.SwiftUI/documentation/SwiftUI/Text/DateStyle/offset``, or ``doc://com.apple.SwiftUI/documentation/SwiftUI/Text/DateStyle/timer`` style becomes
> horizontally flexible and expands to fill the available width.
> Widgets can’t perform layout again after the system archives them,
> so the text can’t measure itself against its eventual content,
> which changes as the date updates, without risking clipping. If
> you want to constrain the width, apply a
> ``doc://com.apple.SwiftUI/documentation/SwiftUI/View/frame(width:height:alignment:)`` modifier, and use
> ``doc://com.apple.SwiftUI/documentation/SwiftUI/View/multilineTextAlignment(_:)`` to align the text within
> that frame.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)