Skip to content

.frame(maxWidth:) ignores parent bounds #339

@dfabulich

Description

@dfabulich
VStack(spacing: 16) {
    Text("Divider (fills available width with padding)")
    Color.gray.frame(height: 1)

    Text("HStack with .frame(maxWidth: 400)")
    HStack {
        Text("Label")
            .foregroundColor(.secondary)
        Spacer()
        Text("Value")
    }
    .frame(maxWidth: 400)
    .border(.red)
}
.padding()

On iOS, the HStack aligns horizontally with the divider. On Android, the .frame(maxWidth: 400) forces the HStack to ignore the parent bounds.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions