---
title: priority
framework: swiftui
role: symbol
role_heading: Instance Property
path: swiftui/layoutsubview/priority
---

# priority

The layout priority of the subview.

## Declaration

```swift
var priority: Double { get }
```

## Discussion

Discussion If you define a custom layout type using the Layout protocol, you can read this value from subviews and use the value when deciding how to assign space to subviews. For example, you can read all of the subview priorities into an array before placing the subviews in a custom layout type called BasicVStack: extension BasicVStack {     func placeSubviews(         in bounds: CGRect,         proposal: ProposedViewSize,         subviews: Subviews,         cache: inout ()     ) {         let priorities = subviews.map { subview in             subview.priority         }

// Place views, based on priorities.     } } Set the layout priority for a view that appears in your layout by applying the layoutPriority(_:) view modifier. For example, you can assign two different priorities to views that you arrange with BasicVStack: BasicVStack {     Text("High priority")         .layoutPriority(10)     Text("Low priority")         .layoutPriority(1) }

## See Also

### Getting subview characteristics

- [dimensions(in:)](swiftui/layoutsubview/dimensions(in:).md)
- [sizeThatFits(_:)](swiftui/layoutsubview/sizethatfits(_:).md)
- [spacing](swiftui/layoutsubview/spacing.md)
