---
title: Rule
framework: tipkit
role: symbol
role_heading: Type Alias
path: tipkit/tip/rule
---

# Rule

A condition to meet before displaying a tip.

## Declaration

```swift
typealias Rule = Tips.Rule
```

## Overview

Overview Use rules to control when your tips display. Parameter Rules Parameter based rules track app state. For example, to display a tip when someone logs in: Define the app state you want to track using the @Parameter macro. Define a rule based on that app state using the #Rule macro. Set the conditions for when the tip displays in the macro closure. struct FavoriteLandmarkTip: Tip {     // Define the app state you want to track.     @Parameter     static var userIsLoggedIn: Bool = false

var rules: [Rule] {         // Define a rule based on the app state.         #Rule(Self.$userIsLoggedIn) {             // Set the conditions for when the tip displays.             $0 == true         }     } } Event Rules Event based rules track user interactions. For example, to display a tip only when a Event occurs three or more times: Define the user interaction you want to track as a Event with a unique id. Define a rule based on that interaction using a #Rule macro. Set the conditions for when the tip displays in the macro closure. struct FavoriteLandmarkTip: Tip {     // Define the user interaction you want to track.     static let didViewLandmark: Event = Event(id: "didViewLandmark")

var rules: [Rule] {         // Define a rule based on the interaction.         #Rule(Self.didViewLandmark) {             // Set the conditions for when the tip displays.             $0.donations.count > 3         }     } } note: If no rules are defined within a tip content structure, the tip displays until dismissed or they exceed the threshold of their display frequency.

## Topics

### Creating parameters

- [Parameter](tipkit/tips/parameter.md)

### Creating events and adding donations

- [Event](tipkit/tips/event.md)
