reflex icon indicating copy to clipboard operation
reflex copied to clipboard

[REF-2647] Toast Reflex component! (Sonner)

Open ema11412 opened this issue 4 months ago β€’ 4 comments

The creation of a Toast in reflex would be very useful.

for example


def toast() -> rx.Component:
    """The toast component."""
    return rx.toast(
        tile="Hello, world!",
        status="success",
        duration=5000,
        is_open=State.toast_open,
        position="top-right",
        onClose=State.close_toast,
    )

Ref:

REF-2647

ema11412 avatar Apr 02 '24 04:04 ema11412

I also suggest Sonner :)

carlosabadia avatar Apr 11 '24 21:04 carlosabadia

i think rather than having the toast declarative, we would probably implement it as an event that you could return from a backend event handler or in response to an event trigger.

rx.button(
    "Toast 🍸",
    on_click=rx.toast(
        tile="Hello, world!",
        status="success",
        duration=5000,
        position="top-right",
        onClose=State.close_toast,
    )
)

masenf avatar Apr 11 '24 21:04 masenf

@masenf Agreed, it serves a similar functionality to rx.window_alert

picklelo avatar Apr 11 '24 21:04 picklelo

I also suggest Sonner :)

Chance are high that we will go with the one from Radix since this it the lib we use as our core one.

Feel free to try wrapping the Sonner one as a 3rd party component if you want to. (https://reflex.dev/docs/custom-components/overview/)

Lendemor avatar Apr 12 '24 00:04 Lendemor