The following code example is taken from the book
C++20 - The Complete Guide by Nicolai M. Josuttis, Leanpub, 2021
The code is licensed under a Creative Commons Attribution 4.0 International License. Creative Commons License

// raw code

#include <format>
#include <string>

enum class Color { red, green, blue };

//*** formatter for enum type Color:
struct std::formatter<Color> : public std::formatter<std::string>
  auto format(Color c, format_context& ctx) const {
    // initialize a string for the value:
    std::string value;
    switch (c) {
      using enum Color;
      case red:
        value = "red";
      case green:
        value = "green";
      case blue:
        value = "blue";
        value = std::format("Color{}", static_cast<int>(c));
    // and delegate the rest of formatting to the string formatter:
    return std::formatter<std::string>::format(value, ctx);