Skip to content

[Toast] Fix type safety for toast options and support ref as prop on container #647

@ravisuhag

Description

@ravisuhag

Summary

Toast wraps Sonner for notifications. Has type safety issues with the toast function signature and missing ref prop support on the container.

Improvements

1. Fix toast function type signature

toast() uses ToasterProps as the options type but Sonner expects ToastOptions. The Object.assign pattern masks this type mismatch.

2. Accept ref as a prop on ToastContainer

Container component doesn't accept a ref prop, limiting imperative control.

3. Document exposed Sonner props

position, dir, hotkey, and other ToasterProps are passable via spread but not documented or discoverable.

4. Remove empty interface extension

ToastContainerProps extends ToasterProps {} is an empty interface providing no additional typing benefit.

5. Add CSS variable fallbacks

All styling hardcoded to CSS variables (lines 21-25) with no fallback values if variables are undefined.

6. Verify and document accessibility

Relies on Sonner's accessibility (aria-live, roles, keyboard shortcuts) without verification or documentation. The alt+T hotkey is undocumented.

Files

  • packages/raystack/raystack/components/toast/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions