mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
chore: fixing the placement option in toast docs (#4857)
This commit is contained in:
parent
943dfdbd66
commit
99d1674793
@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import {HeroUIProvider, ToastProvider} from "@heroui/react";
|
||||
import {HeroUIProvider} from "@heroui/react";
|
||||
import {ThemeProvider as NextThemesProvider} from "next-themes";
|
||||
import {ThemeProviderProps} from "next-themes";
|
||||
import {useRouter} from "next/navigation";
|
||||
@ -44,7 +44,6 @@ export function Providers({children, themeProps}: ProvidersProps) {
|
||||
return (
|
||||
<ProviderWrapper>
|
||||
<HeroUIProvider navigate={router.push}>
|
||||
<ToastProvider />
|
||||
<NextThemesProvider {...themeProps}>{children}</NextThemesProvider>
|
||||
</HeroUIProvider>
|
||||
</ProviderWrapper>
|
||||
|
||||
@ -1,15 +1,26 @@
|
||||
import {addToast, Button} from "@heroui/react";
|
||||
import {addToast, ToastProvider, Button} from "@heroui/react";
|
||||
import React from "react";
|
||||
|
||||
export default function App() {
|
||||
const [placement, setPlacement] = React.useState("bottom-right");
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"].map(
|
||||
(position) => (
|
||||
<>
|
||||
<ToastProvider placement={placement} toastOffset={placement.includes("top") ? 60 : 0} />
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{[
|
||||
"top-left",
|
||||
"top-center",
|
||||
"top-right",
|
||||
"bottom-left",
|
||||
"bottom-center",
|
||||
"bottom-right",
|
||||
].map((position) => (
|
||||
<Button
|
||||
key={position}
|
||||
variant={"flat"}
|
||||
onPress={() => {
|
||||
setPlacement(position);
|
||||
addToast({
|
||||
title: "Toast title",
|
||||
description: "Toast displayed successfully",
|
||||
@ -18,8 +29,8 @@ export default function App() {
|
||||
>
|
||||
{position}
|
||||
</Button>
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ Toast has the following slots:
|
||||
},
|
||||
{
|
||||
attribute: "placement",
|
||||
type: "bottom-right" | "bottom-left" | "bottom-center" | "top-right" | "top-left" | "top-center",
|
||||
type: "bottom-right | bottom-left | bottom-center | top-right | top-left | top-center",
|
||||
description: "The placement of the toast.",
|
||||
default: "bottom-right"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user