Dinachi UI is heavily inspired by Base UI and provides accessible, composable components styled with Tailwind CSS.
delaycloseDelayimport { PreviewCard, PreviewCardContent, PreviewCardTrigger } from "@/components/ui/preview-card"
const cards = {
"Base UI": "Unstyled React components and hooks from the creators of Material UI. Ship accessible interfaces without compromising creative freedom.",
"Tailwind CSS": "A utility-first CSS framework for rapidly building custom designs without ever leaving your HTML.",
}
function Mention({ name }: { name: keyof typeof cards }) {
return (
<PreviewCard>
<PreviewCardTrigger href="#">{name}</PreviewCardTrigger>
<PreviewCardContent>
<div className="space-y-2">
<h4 className="text-sm font-semibold">{name}</h4>
<p className="text-sm text-muted-foreground">{cards[name]}</p>
</div>
</PreviewCardContent>
</PreviewCard>
)
}
export function Credits() {
return (
<p className="max-w-md text-sm leading-relaxed">
Dinachi UI is heavily inspired by <Mention name="Base UI" /> and provides accessible,
composable components styled with <Mention name="Tailwind CSS" />.
</p>
)
}Usage
import {
PreviewCard,
PreviewCardContent,
PreviewCardTrigger,
} from "@/components/ui/preview-card"
export function ProfileLink() {
return (
<PreviewCard>
<PreviewCardTrigger href="/people/ada">Ada Lovelace</PreviewCardTrigger>
<PreviewCardContent>
<p className="text-sm">Mathematician. Wrote the first published program.</p>
</PreviewCardContent>
</PreviewCard>
)
}Examples
Dinachi UI is heavily inspired by Base UI and provides accessible, composable components styled with Tailwind CSS.
import { PreviewCard, PreviewCardTrigger, PreviewCardContent } from '@/components/ui/preview-card';
export function Example() {
return (
<p className="text-sm leading-relaxed text-foreground max-w-md">
Dinachi UI is heavily inspired by{' '}
<PreviewCard>
<PreviewCardTrigger href="#">
Base UI
</PreviewCardTrigger>
<PreviewCardContent>
<div className="space-y-2">
<h4 className="text-sm font-semibold">Base UI</h4>
<p className="text-sm text-muted-foreground">
Unstyled React components and hooks from the creators of Material UI. Ship accessible interfaces without compromising creative freedom.
</p>
</div>
</PreviewCardContent>
</PreviewCard>
{' '}and provides accessible, composable components styled with{' '}
<PreviewCard>
<PreviewCardTrigger href="#">
Tailwind CSS
</PreviewCardTrigger>
<PreviewCardContent>
<div className="space-y-2">
<h4 className="text-sm font-semibold">Tailwind CSS</h4>
<p className="text-sm text-muted-foreground">
A utility-first CSS framework for rapidly building custom designs without ever leaving your HTML.
</p>
</div>
</PreviewCardContent>
</PreviewCard>
.
</p>
);
}import { PreviewCard, PreviewCardTrigger, PreviewCardContent } from '@/components/ui/preview-card';
export function Example() {
return (
<PreviewCard>
<PreviewCardTrigger href="#">
@dinachi
</PreviewCardTrigger>
<PreviewCardContent>
<div className="space-y-2">
<div className="flex items-center gap-3">
<div className="h-10 w-10 rounded-full bg-primary/20 flex items-center justify-center text-sm font-bold">
D
</div>
<div>
<h4 className="text-sm font-semibold">Dinachi UI</h4>
<p className="text-xs text-muted-foreground">@dinachi</p>
</div>
</div>
<p className="text-sm text-muted-foreground">
A modern React component library built with Base UI and Tailwind CSS.
</p>
</div>
</PreviewCardContent>
</PreviewCard>
);
}import {
PreviewCard,
PreviewCardTrigger,
PreviewCardPortal,
PreviewCardPositioner,
PreviewCardPopup,
PreviewCardArrow,
PreviewCardViewport,
createPreviewCardHandle,
} from '@/components/ui/preview-card';
const profiles = [
{ name: 'Alice Chen', handle: '@alice', bio: 'Design systems engineer. Building accessible UIs.', initials: 'AC' },
{ name: 'Bob Rivera', handle: '@bob', bio: 'Full-stack developer. Open source contributor.', initials: 'BR' },
{ name: 'Carol Park', handle: '@carol', bio: 'Frontend architect. Tailwind CSS enthusiast.', initials: 'CP' },
];
export function Example() {
const handle = createPreviewCardHandle();
return (
<div className="flex gap-4 items-center">
{profiles.map((profile) => (
<PreviewCardTrigger key={profile.handle} href="#" handle={handle} payload={profile}>
{profile.handle}
</PreviewCardTrigger>
))}
<PreviewCard handle={handle}>
{({ payload }) => {
const profile = payload as (typeof profiles)[number] | undefined;
return (
<PreviewCardPortal>
<PreviewCardPositioner>
<PreviewCardPopup>
<PreviewCardArrow />
<PreviewCardViewport>
{profile && (
<div className="space-y-2">
<div className="flex items-center gap-3">
<div className="h-10 w-10 rounded-full bg-primary/20 flex items-center justify-center text-sm font-bold">
{profile.initials}
</div>
<div>
<h4 className="text-sm font-semibold">{profile.name}</h4>
<p className="text-xs text-muted-foreground">{profile.handle}</p>
</div>
</div>
<p className="text-sm text-muted-foreground">{profile.bio}</p>
</div>
)}
</PreviewCardViewport>
</PreviewCardPopup>
</PreviewCardPositioner>
</PreviewCardPortal>
);
}}
</PreviewCard>
</div>
);
}Notes
Content only
For reading only. Touch screens have no hover, so keep essential content on the linked page and put controls in a Popover.
One card, many triggers
Pass a createPreviewCardHandle() handle to the PreviewCard and each PreviewCardTrigger, and give each trigger a payload; the children function receives it. Triggers outside the PreviewCard are not tied to its agent entry, so the agent sees them as plain links.
API
details.cancel() refuses the change.createPreviewCardHandle().PreviewCard to it.Takes the props of the element it renders.
Takes the props of the element it renders.
Takes the props of the element it renders.
Takes the props of the element it renders.
Takes the props of the element it renders.
Takes the props of the element it renders.
Agent
Inside an AgentProvider, it appears in agent.snapshot() as popover.
Reads
labelThe trigger's text.
openWhether the card is showing.
Actions
open()Opens the card. Only while closed.
close()Closes the card. Only while open.
Once open, the trigger stays the control and the card is read as content. An agent's change runs through onOpenChange. isAgentChange(details) is true for it, and details.cancel() refuses it; the agent is told the app refused.
await agent.act({
steps: [{ ref: "Base UI", action: "open" }],
})Accessibility
- The trigger is a plain link; it works if the card never opens.
- Opens on hover and on keyboard focus of the trigger.