Preheat the air fryer to 350°F (180°C) for 3 minutes.
In a bowl, toss the thinly sliced onion with olive oil or butter, ¼ teaspoon salt, black pepper, and sugar if using.
Spread the onions evenly in the air fryer basket or tray and air fry for 10–12 minutes, shaking or stirring halfway through, until golden and soft.
If onions brown too quickly, reduce temperature to 320°F (160°C) and extend cooking time.
Lightly oil a small oven-safe dish or silicone egg cups, then crack 2 eggs into each.
Season eggs with remaining salt and pepper.
Place egg dishes in the air fryer at 320–340°F (160–170°C) and cook for 7–10 minutes depending on desired yolk doneness.
Remove the eggs and spoon warm caramelized onions over them.
Serve eggs topped with onions over toasted bread or English muffins, adding avocado, herbs, and hot sauce as desired.