def format_prop(
    prop: Var | EventChain | ComponentStyle | str,
) -> int | float | str:
    """Format a prop.

    Args:
        prop: The prop to format.

    Returns:
        The formatted prop to display within a tag.

    Raises:
        exceptions.InvalidStylePropError: If the style prop value is not a valid type.
        TypeError: If the prop is not valid.
        ValueError: If the prop is not a string.
    """
    # import here to avoid circular import.
    from reflex.event import EventChain
    from reflex.utils import serializers
    from reflex.vars import Var

    try:
        # Handle var props.
        if isinstance(prop, Var):
            return str(prop)

        # Handle event props.
        if isinstance(prop, EventChain):
            return str(Var.create(prop))

        # Handle other types.
        if isinstance(prop, str):
            if is_wrapped(prop, "{"):
                return prop
            return json_dumps(prop)

        # For dictionaries, convert any properties to strings.
        if isinstance(prop, dict):
            prop = serializers.serialize_dict(prop)  # pyright: ignore [reportAttributeAccessIssue]

        else:
            # Dump the prop as JSON.
            prop = json_dumps(prop)
    except exceptions.InvalidStylePropError:
        raise
    except TypeError as e:
        msg = f"Could not format prop: {prop} of type {type(prop)}"
        raise TypeError(msg) from e

    # Wrap the variable in braces.
    if not isinstance(prop, str):
        msg = f"Invalid prop: {prop}. Expected a string."
        raise ValueError(msg)
    return wrap(prop, "{", check_first=False)
Format a prop.

    Args:
        prop: The prop to format.

    Returns:
        The formatted prop to display within a tag.

    Raises:
        exceptions.InvalidStylePropError: If the style prop value is not a valid type.
        TypeError: If the prop is not valid.
        ValueError: If the prop is not a string.
    
reflex/utils/format.py