---
title: "defaultSize(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/scene/defaultsize(_:)"
---

# defaultSize(_:)

Sets a default size for a window.

## Declaration

```swift
nonisolated func defaultSize(_ size: CGSize) -> some Scene

```

## Parameters

- `size`: The default size for new windows created from a scene.

## Return Value

Return Value A scene that uses a default size for new windows.

## Discussion

Discussion Use this scene modifier to indicate a default initial size for a new window that the system creates from a Scene declaration. For example, you can request that new windows that a WindowGroup generates occupy 600 points in the x-dimension and 400 points in the y-dimension: @main struct MyApp: App {     var body: some Scene {         WindowGroup {             ContentView()         }         .defaultSize(CGSize(width: 600, height: 400))     } } The size that you specify acts only as a default for when the window first appears. People can later resize the window using interface controls that the system provides. Also, during state restoration, the system restores windows to their most recent size rather than the default size. If you specify a default size that’s outside the range of the window’s inherent resizability in one or both dimensions, the system clamps the affected dimension to keep it in range. You can configure the resizability of a scene using the windowResizability(_:) modifier. The default size modifier affects any scene type that creates windows in macOS, namely: WindowGroup Window DocumentGroup Settings If you want to specify the input directly in terms of width and height, use defaultSize(width:height:) instead.

## See Also

### Sizing a window

- [Positioning and sizing windows](visionos/positioning-and-sizing-windows.md)
- [defaultSize(width:height:)](swiftui/scene/defaultsize(width:height:).md)
- [defaultSize(width:height:depth:)](swiftui/scene/defaultsize(width:height:depth:).md)
- [defaultSize(_:in:)](swiftui/scene/defaultsize(_:in:).md)
- [defaultSize(width:height:depth:in:)](swiftui/scene/defaultsize(width:height:depth:in:).md)
- [windowResizability(_:)](swiftui/scene/windowresizability(_:).md)
- [WindowResizability](swiftui/windowresizability.md)
- [windowIdealSize(_:)](swiftui/scene/windowidealsize(_:).md)
- [WindowIdealSize](swiftui/windowidealsize.md)
