question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow more custom toast style customization

See original GitHub issue

Description

It would be preferred to have a simple way to override the backgroundColor in containerStyle. If there is a way, I did not find it.

Problem Statement/Justification

The current colors based on status are rather imposing.

Proposed Solution or API

For example:

export const postChangedToast = (): UseToastOptions => ({
    title: "This post got updated",
    description: "Test description",
    duration: 5000,
    position: "top",
    containerStyle: {
        backgroundColor: "red"
    }
});

This still renders the default infobox, and just colors the background ‘behind’ the infobox.

Alternatives

I’ve tried the demos on the documentation page. Couldn’t manage to change the background color, although changing some other styles worked.

Additional Information

It seems that standard React styles are used, but I couldn’t manage to change the color of the toast box. Don’t really understand I couldn’t find another issue describing the same (maybe I didn’t look well enough), it’s the first thing I tried before adding it to my site.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
hrishikeshpaulcommented, Feb 10, 2022

Hey @kimgysen this is what I’ve done and it works fine,

components: {
        Alert: {
            variants: {
                toast: (P: any) => {
                    return {
                        container: {
                            ...P.theme.components.Alert.variants.solid(P).container,
                            bottom: '64px',
                        },
                    };
                },
            },
        },
    },

The offset in my case is from the bottom. Hope this helps.

1reaction
TimKolbergercommented, Feb 10, 2022

You can use the variant property in UseToastOptions to choose the Alert variant Chakra UI Docs | Toast | Variants Kindly see this CodeSandbox for an example.

Kindly close this issue if it solves you issue ✨

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Custom Toast in Android | by Usman Khan
You can of course customize the Toast however you want by playing around with gravity , duration , layout etc, the above is...
Read more >
How to customize style of Toast window? - css - Stack Overflow
I needed to add an additional reference to the toast container in styles.css. The html remains mostly the same. <p-toast class="custom-toast"></ ...
Read more >
How to add a custom styled Toast in Android using Kotlin
Go to res -> layout (right-click) -> new -> Layout Resource file -> Create (custom_toast_layout.xml) file. Add a CardView to contain the custom...
Read more >
CUSTOM TOAST VIEWS IN ANDROID. Have you ... - Medium
Have you come across custom Toasts that are different from your default Toast and you are wondering how they were made?
Read more >
Android Custom Toast with Examples - Tutlane
Android custom toast with examples. In android we can customize the style of toast notification to change the appearance to show the messages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found