---
title: "Fixed Frames"
description: "How to use the frame modifier in SwiftUI"
url: https://www.swiftuifieldguide.com/layout/fixed-frames
markdown_url: https://www.swiftuifieldguide.com/layout/fixed-frames.md
---
> Convenience Markdown export of the HTML page. Interactive samples, diagrams, and visualizations stay on the canonical page.
# Fixed Frames

A fixed frame lets us specify an optional width and height (as opposed to a [flexible frame](/layout/flexible-frames), which lets us specify upper and lower bounds). The behavior of a fixed frame only has a few rules: If we specify a non-`nil` dimension, that value is proposed to the child (regardless of the value proposed to the frame). Likewise, the frame reports that dimension as its value, disregarding the value of the child.

In the example below, we can see that the text is always wrapped inside its frame. The frame has a constant size, regardless of what's proposed.

> Pretty-printed code from Sample0

```swift
Text("Hello, world")
    .frame(width: , height: 100)
    /* .border(.red) */
```

> Interactive example on HTML page: Sample0.

We can also specify an alignment parameter. The default is `.center`. Note that the alignment parameter also works when the frame is smaller than its content.

> Pretty-printed code from Sample1

```swift
Text("Hello, world")
    .fixedSize()
    .frame(width: 150, height: 100)
    .border(.red)
```

> Interactive example on HTML page: Sample1.
