Skip to content

[toast] Create new Toast component#1467

Merged
atomiks merged 50 commits intomui:masterfrom
atomiks:feat/Toast
Apr 8, 2025
Merged

[toast] Create new Toast component#1467
atomiks merged 50 commits intomui:masterfrom
atomiks:feat/Toast

Conversation

@atomiks
Copy link
Contributor

@atomiks atomiks commented Feb 21, 2025

Closes #220

Preview: https://deploy-preview-1467--base-ui.netlify.app/react/components/toast

  • Refine Toast interface/props APIs/placeholder code
  • Ability to swipe
  • Ability to stack
  • Global queue
  • Docs with animated examples
  • Tests

@netlify
Copy link

netlify bot commented Feb 21, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 415a75e
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/67f5a27f5b95b500087cd019
😎 Deploy Preview https://deploy-preview-1467--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@oliviertassinari oliviertassinari added component: toast Changes related to the toast component. type: new feature Expand the scope of the product to solve a new problem. and removed component: toast labels Mar 1, 2025
@atomiks atomiks force-pushed the feat/Toast branch 5 times, most recently from afa920e to 62be009 Compare March 11, 2025 06:22
@atomiks atomiks marked this pull request as ready for review March 12, 2025 11:04
let counter = 0;
export function generateId(prefix: string) {
counter += 1;
return `${prefix}-${Math.random().toString(36).slice(2, 6)}-${counter}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't ${prefix}-${counter} alone be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not with multiple independent versions of the library being used (e.g. extensions)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to play with the toast using just this page as a reference and I feel having a section about swiping and animating the toast position could be useful.
I found out that not having user-select: none on the toast can make the swipe interaction weirdly sticky - it's also something to underline in the docs (or fix if possible)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think user-select: none added to the examples is fine - it should be obvious that you don't want text selection while swiping. I added docs about stacking & animations though as that gets complex.

}
```

The `title` and `description` strings are what are used to announce the toast to screen readers. Screen readers do not announce any extra content rendered inside `Toast.Root`, including the `Toast.Title` or `Toast.Description` components.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be convenient if these strings could be used as the default children of the Title/Description components so they can be used like <Toast.Title /> (like our *.Value) components, though I'm not sure if it's very unusual for components called Title/Description to not require children 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since <Field.Error> and <Select.Value> both do this I think it's consistent actually

setTimeout(() => resolve('world!'), 1000);
}),
{
// Each are a shortcut for the children of `Toast.Description`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the strings and not the children?

Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

@atomiks atomiks merged commit af1f6e0 into mui:master Apr 8, 2025
22 checks passed
@atomiks atomiks deleted the feat/Toast branch April 8, 2025 23:36
@oliviertassinari oliviertassinari changed the title [Toast] Create new Toast component [toast] Create new Toast component Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: toast Changes related to the toast component. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[toast] Implement Toast

5 participants