Open haruki-m opened 9 months ago
@haruki-m Thanks for reporting this. We're working on it.
@haruki-m Thank you for reporting the issue. We have addressed it and a pull request (PR) has been submitted.
Here are the modifications we suggest:
flexShrink={1}
in the Vstack to properly wrap the description text.borderColor="red"
(or any color you prefer) to the toast component.duration=null
.I have provided the full code, for reference.
import { config } from "@gluestack-ui/config";
import {
GluestackUIProvider,
Button,
ButtonText,
Toast,
ToastDescription,
ToastTitle,
VStack,
useToast,
Icon,
Pressable,
SafeAreaView,
} from "@gluestack-ui/themed";
import "react-native-svg";
import { AlertCircle as AlertIcon, X as CloseIcon } from "lucide-react-native";
export default function App() {
return (
<GluestackUIProvider config={config}>
<SafeAreaView>
<Example />
</SafeAreaView>
</GluestackUIProvider>
);
}
function Example() {
const toast = useToast();
return (
<Button
mt={100}
onPress={() => {
toast.show({
placement: "top",
duration: null,
render: ({ id }) => {
const toastId = "toast-" + id;
return (
<Toast
bg="$backgroundDarkWarning"
nativeID={toastId}
variant="accent"
action="warning"
borderColor="red"
>
<Icon as={AlertIcon} color="$white" mt="$1" mr="$3" />
<VStack flexShrink={1} space="xs">
<ToastTitle color="$textLight50">Warning</ToastTitle>
<ToastDescription color="$textLight50">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Nesciunt nemo animi laborum quod eveniet ex, voluptates
fugit optio alias quam saepe Lorem, ipsum dolor. Lorem,
ipsum dolor. Lorem, ipsum dolor.
</ToastDescription>
</VStack>
<Pressable mt="$1" onPress={() => toast.close(id)}>
<Icon as={CloseIcon} color="$coolGray50" />
</Pressable>
</Toast>
);
},
});
}}
>
<ButtonText>Press Me</ButtonText>
</Button>
);
}
@RishabhSahu24 Thank you!
Description
I was following the example on Dismissable Toasts, but there are clear UI issues when there are icons next to
ToastTitle
andToastDescription
. If the description spans the toast container width, it gets pushed out of the view port by the icon. Also, ifvariant="accent"
, I couldn't find a way to change the color of the vertical strip on the left (looks off on dark mode). Lastly if I omitduration
or setduration={null}
the toast still disappears after a few seconds.CodeSandbox/Snack link
No response
Steps to reproduce
gluestack-ui Version
1.1.6
Platform
Other Platform
No response
Additional Information
No response