Sean Thorburn
Sean Thorburn

Reputation: 1778

Bootstrap Toast at bottom right of page

I am looking for the most efficient way to display stacking Bootstrap 4 toasts at the bottom right of the page.

I haven't been able to find any decent examples of how to do this online.

Currently I have them stacking from the top right.

<div aria-live="polite" aria-atomic="true" style={{ position: "relative" }}>
        <div style={{ position: "absolute", top: 0, right: 0, zIndex: 9999, float: "right" }}>
            {errors.map(function (error, index) {
                return (
                    <Toast key={index}>
                        <ToastHeader fade="true" icon="danger" aria-live="assertive" aria-atomic="true">
                            Error
                    </ToastHeader>
                        <ToastBody>{error}</ToastBody>
                    </Toast>
                );
            })
        }
        </div>
</div>

Any help will be appreciated.

Upvotes: 4

Views: 4909

Answers (1)

Carol Skelly
Carol Skelly

Reputation: 362340

Remove relative from the parent div, and set bottom: 0...

   <div aria-live="polite" aria-atomic="true">
        <div style={{ position: "absolute", bottom: 0, right: 0, zIndex: 9999, float: "right" }}>
            {errors.map(function (error, index) {
                return (
                    <Toast key={index}>
                        <ToastHeader fade="true" icon="danger" aria-live="assertive" aria-atomic="true">
                            Error
                        </ToastHeader>
                        <ToastBody>{error}</ToastBody>
                    </Toast>
                )
            })
        }
        </div>
   </div>

https://codeply.com/p/PRg42pwASa

Upvotes: 3

Related Questions