Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Documentation for DioxusFormattable Trait #446

Open
vitordeoliveira opened this issue Feb 17, 2025 · 0 comments
Open

Add Documentation for DioxusFormattable Trait #446

vitordeoliveira opened this issue Feb 17, 2025 · 0 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@vitordeoliveira
Copy link

Currently, the DioxusFormattable trait in Dioxus lacks official documentation. This trait is useful for custom types that need to be formatted as strings within the framework.

In my use case, I created a wrapper struct Icon around Asset and implemented DioxusFormattable for it. This allows Icon instances to be used seamlessly as formatted strings in components.

Example usage:

#[derive(PartialEq, Props, Clone)]
pub struct MenuProps {
    icon: Icon,
    children: Element,
    #[props(into)]
    to: NavigationTarget,
}

#[component]
pub fn ManuLink(props: MenuProps) -> Element {
    let MenuProps { to, children, icon } = props;
    rsx! {
        Link {
            to,
            div {
                class: "flex items-center gap-8 p-5 rounded hover:bg-secondary-darker",
                img {src: icon}
                {children}
            }
        }
    }
}

Adding documentation for DioxusFormattable would help developers understand its purpose, usage, and best practices for implementing it in their own projects.

@ealmloff ealmloff added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants