示例工程 16-shadcn-ui-component-layer
16-shadcn-ui-component-layer/app/src/components/ui/toaster.tsx
// vendored from shadcn/ui (base style) — toast
// source: https://ui.shadcn.com/docs/components/toast
// fetched: 2026-11-26 · shadcn CLI 4.23.0 · base-nova
// 本地修改:用 Base UI Toast + useToastManager 重写,样式用 token
import { Toast } from "@base-ui-components/react/toast";
export function Toaster() {
const { toasts } = Toast.useToastManager();
return (
<Toast.Viewport className="fixed bottom-4 right-4 z-[100] flex w-80 flex-col gap-2 outline-none">
{toasts.map((toast) => (
<Toast.Root
key={toast.id}
toast={toast}
data-testid="toast"
className="rounded-card border border-border bg-surface p-3 text-text shadow-xl"
>
<Toast.Title className="text-sm font-medium" />
<Toast.Description className="mt-0.5 text-xs text-muted" />
<Toast.Close
className="absolute right-2 top-2 rounded px-1 text-xs text-muted hover:text-text"
aria-label="关闭通知"
>
×
</Toast.Close>
</Toast.Root>
))}
</Toast.Viewport>
);
}