Skip to content

add slots and header to toast component #16791

Closed

Description

@zakton5

Feature Request

Ionic version:

[x] 4.x

Describe the Feature Request
Toasts are great and all but they can't be highly customized in terms of layout. At the very least it would be great to have start and end slots similar to ion-item to present success or error messages and show a check or an x based on the type of message. In addition, these slots could house buttons that take different handlers similar to alert buttons. Why be limited to just a close button?

A header property would also be great for presenting in-app notifications to users such as

Message from Susan (header)
Hey how are you? (message)

Describe Preferred Solution

Add the following properties to ToastOptions: header, actionStart, actionEnd

this.toastCtrl.create({
    header: 'Message from Susan',
    message: 'Hey how are you?',
    actionStart: {
        text: '',
        handler: () => {
            //...
        }
    },
    actionEnd: {
        text: '',
        handler: () => {
            //...
        }
    }
})

Describe Alternatives
I'm not so sure actionStart and actionEnd are good names, but you get the idea!

Activity

  1. added
    type: feature request
    and removed on Dec 18, 2018
  2. zakton5 commented on Dec 18, 2018

    @zakton5
    ContributorAuthor

    @paulstelzer I would interested in making a PR if the general idea above looks good to you

  3. brandyscarney commented on Dec 18, 2018

    @brandyscarney
    Member

    We are holding off on merging in feature requests at the moment as we push to get bug fixes in and a final release out. If it were up to me though, I'd think the API would look more like this:

    this.toastCtrl.create({
      header: 'Message from Susan',
      message: 'Hey how are you?',
      buttons: [{
        text: 'Confirm',
        icon: 'add',
        slot: 'start',
        handler: () => {
          //...
        }
      }, {
        icon: 'close',
        slot: 'end',
        handler: () => {
          //...
        }
      }]
    })

    This would match with the way we add buttons to action sheet, for example. However, I'm not sure if it's worth the effort at the moment to submit a PR for this, since we won't be able to review or merge it for a bit and I would need to discuss the API with other team members.

  4. zakton5 commented on Dec 18, 2018

    @zakton5
    ContributorAuthor

    @brandyscarney Looks better and even more flexible. I'll hold off until an update from you guys.

  5. zakton5 commented on Jan 17, 2019

    @zakton5
    ContributorAuthor

    @brandyscarney I've gotten to the point where I need this in my app so I'm going to attempt to create a PR unless you all have other plans

  6. ionitron-bot commented on May 11, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  7. locked and limited conversation to collaborators on May 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions