Skip to content

Feature: Support iconPosition for custom Toast icons #605

@romantrukhtanov

Description

@romantrukhtanov

Description

Currently, toast notifications allow passing a custom icon, but do not provide a public API to control the icon position inside the toast layout

This is limiting in cases where the icon should be:

  • top-aligned for multi-line content
  • placed on the right and vertically centered
  • placed on the right and top-aligned

At the moment, this can only be done with custom className and CSS overrides, which makes the solution dependent on internal layout styles

Proposed API

Add an iconPosition option to toast API, for example:

  • start-center
  • start-top
  • end-center
  • end-top

Example:

toast.show({
  title: "Saved",
  children: "Changes have been published",
  icon: <Icon svg={Check} size={5} color="positive" />,
  iconPosition: "end-top",
});

Reproduction

I created a reproduction case showing that while toast supports a custom icon, its position can't be configured through public API and currently requires CSS overrides

CodeSandbox: https://codesandbox.io/p/devbox/reshaped-toast-icon-position-3-9-0-jvc9lh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    3.11.0

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions