<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URL/FormatStyle/init(scheme:user:password:host:port:path:query:fragment:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation3URLV11FormatStyleV6scheme4user8password4host4port4path5query8fragmentA2E22ComponentDisplayOptionV_A2oE04HostnO0VA4Otcfc"
  },
  "title" : "init(scheme:user:password:host:port:path:query:fragment:)"
}
-->

# init(scheme:user:password:host:port:path:query:fragment:)

Creates a URL format style with the given display options.

```
init(scheme: URL.FormatStyle.ComponentDisplayOption = .always, user: URL.FormatStyle.ComponentDisplayOption = .never, password: URL.FormatStyle.ComponentDisplayOption = .never, host: URL.FormatStyle.HostDisplayOption = .always, port: URL.FormatStyle.ComponentDisplayOption = .omitIfHTTPFamily, path: URL.FormatStyle.ComponentDisplayOption = .always, query: URL.FormatStyle.ComponentDisplayOption = .never, fragment: URL.FormatStyle.ComponentDisplayOption = .never)
```

## Parameters

`scheme`

An option to control display of the URL scheme component.

`user`

An option to control display of the URL user component.

`password`

An option to control display of the URL password component.

`host`

An option to control display of the URL host component.

`port`

An option to control display of the URL port component.

`path`

An option to control display of the URL path component.

`query`

An option to control display of the URL query component.

`fragment`

An option to control display of the URL fragment component.

## Discussion

Explicitly create a URL format style in situations where you want to format multiple URLs with the same style configuration. For one-time use, call [`formatted()`](/documentation/Foundation/URL/formatted()) for a default style, or create a style with [`url`](/documentation/Foundation/FormatStyle/url) and customize it with the modifiers in Customizing style behavior.

---

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)