---
title: "subscript(_:)"
framework: swiftui
role: symbol
role_heading: Instance Subscript
path: "swiftui/layoutsubview/subscript(_:)"
---

# subscript(_:)

Gets the value for the subview that’s associated with the specified key.

## Declaration

```swift
subscript<K>(key: K.Type) -> K.Value where K : LayoutValueKey { get }
```

## Overview

Overview If you define a custom layout value using LayoutValueKey, you can read the key’s associated value for a given subview in a layout container by indexing the container’s subviews with the key type. For example, if you define a Flexibility key type, you can put the associated values of all the layout’s subviews into an array: let flexibilities = subviews.map { subview in     subview[Flexibility.self] } For more information about creating a custom layout, see Layout.
