---
title: "displayWhen(_:matches:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/url/formatstyle/componentdisplayoption/displaywhen(_:matches:)"
---

# displayWhen(_:matches:)

Returns a display option that displays the component when a specified component meets the specified requirements.

## Declaration

```swift
static func displayWhen(_ component: URL.FormatStyle.Component, matches requirements: Set<String>) -> URL.FormatStyle.ComponentDisplayOption
```

## Parameters

- `component`: A component to compare. This may or may not be the component the strategy modifies. For example, a display option for the query might match against known values for the path.
- `requirements`: A set of string values to match against. Matching any member of the set allows the format style to display the component.

## Return Value

Return Value A display option that displays the component when a specified component meets the specified requirements.

## See Also

### Display options

- [always](foundation/url/formatstyle/componentdisplayoption/always.md)
- [never](foundation/url/formatstyle/componentdisplayoption/never.md)
- [omitIfHTTPFamily](foundation/url/formatstyle/componentdisplayoption/omitifhttpfamily.md)
- [omitWhen(_:matches:)](foundation/url/formatstyle/componentdisplayoption/omitwhen(_:matches:).md)
- [URL.FormatStyle.Component](foundation/url/formatstyle/component.md)
