Next UI doesn't fully support Astro? #1741
-
I see that there is a Button Usage in the official Usage, but when I try other components, e.g. Card and Navbar, I get the error: useNavbarContext: I would like to ask what to do in this situation? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
I have the exact same issue. Unfortunately it led me to uninstall Next UI again, since i couldn't use a majority of the components because of this. |
Beta Was this translation helpful? Give feedback.
-
@dragonjay-lyj @scharf-dev you can solve it wrapping the Next UI component this way: // NextCard.tsx
import { Button, Card, CardBody, CardHeader } from "@nextui-org/react";
import { useState } from "react";
export default function NextCard({ header }: { header: string }) {
const [count, setCount] = useState(0);
return (
<Card className="py-4">
<CardHeader className="pb-0 pt-2 px-4 flex-col items-start">
<p className="text-tiny uppercase font-bold">{header}</p>
</CardHeader>
<CardBody className="overflow-visible py-2">
<Button color="primary" onClick={() => setCount(count + 1)}>
Button
</Button>
<p>Count: {count}</p>
</CardBody>
</Card>
);
} And then use it in a file like ---
import NextCard from "../components/NextCard";
import Layout from "../layouts/Layout.astro";
---
<Layout title="Homepage">
<main>
<NextCard client:visible header="Header" />
</main>
</Layout> |
Beta Was this translation helpful? Give feedback.
-
Do i still need to wrap the component with nextUIProvider? |
Beta Was this translation helpful? Give feedback.
@dragonjay-lyj @scharf-dev you can solve it wrapping the Next UI component this way: