#How do I make a notification show when a button is clicked?
5 messages ยท Page 1 of 1 (latest)
You can call the showNotification function on click, it makes it easier. Without seeing your code it's a bit hard to help, though.
This is my whole app or whatever ```jsx
return (
<MantineProvider>
<TypographyStylesProvider>
<Title align="center" order={1}>
Discounter
</Title>
<Stack align="center" spacing="xs">
<NumberInput
mt="xl"
label="Price"
description="The price of the product / item"
placeholder="Enter a number"
withAsterisk
icon={<IconTag size={18} />}
/>
<NumberInput
mt="xl"
label="Discount"
description="Percent to discount off of the price"
placeholder="Enter a percentage"
withAsterisk
icon={<IconPercentage size={18} />}
/>
<Group>
<Button onClick={() => {}}>Calculate</Button>
<Button variant="light">Clear</Button>
</Group>
</Stack>
</TypographyStylesProvider>
</MantineProvider>
);
Put the showNotification function inside the onClick function: https://mantine.dev/others/notifications/
The other option is to use state and manually show it, but this extra package just makes it so much easier to manage.
Thank you ๐