- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Form
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Number Field
- Pagination
- Pin Input
- Popover
- Progress
- Questionnaire
- Radio Group
- Range Calendar
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Stepper
- Switch
- Table
- Tabs
- Tags Input
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Trace
- Typography
Next.js streams a route in chunks, so the page shows up before every request finishes.
Wrap a slow part of the page in a Suspense boundary and React sends the fallback first. When the data resolves, the finished HTML streams into the same response and replaces the fallback, with no extra request from the browser. Server Components help here, because their code never ships to the browser.
A loading.tsx file does the same for a whole route segment. It all runs over chunked transfer encoding, so there is nothing extra to set up.
<script setup lang="ts">
import { createReusableTemplate } from '@vueuse/core'
import { Button } from '@/components/ui/button'
import {
HoverCard,
HoverCardContent,
HoverCardTrigger,
} from '@/components/ui/hover-card'
interface Source {
url: string
title: string
description: string
}
const sources = {
streaming: {
url: 'https://nextjs.org/docs/app/getting-started/linking-and-navigating#streaming',
title: 'Linking and Navigating',
description: 'How the App Router streams a route to the browser.',
},
suspense: {
url: 'https://react.dev/reference/react/Suspense',
title: '<Suspense>',
description: 'Display a fallback until its children have finished loading.',
},
serverComponents: {
url: 'https://react.dev/reference/rsc/server-components',
title: 'Server Components',
description: 'Components that render ahead of time, on the server.',
},
loading: {
url: 'https://nextjs.org/docs/app/api-reference/file-conventions/loading',
title: 'loading.js',
description: 'Show an instant loading state for a route segment.',
},
chunked: {
url: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Transfer-Encoding',
title: 'Transfer-Encoding',
description: 'Send a response as a series of chunks.',
},
} satisfies Record<string, Source>
function hostname(url: string) {
return new URL(url).hostname.replace(/^www\./, '')
}
const [DefineCitation, Citation] = createReusableTemplate<{ source: Source }>()
</script>
<template>
<DefineCitation v-slot="{ source }">
<HoverCard :open-delay="10" :close-delay="100">
<HoverCardTrigger as-child>
<Button variant="secondary" size="xs">
{{ hostname(source.url) }}
</Button>
</HoverCardTrigger>
<HoverCardContent class="flex w-64 flex-col gap-1">
<div class="font-medium">
{{ source.title }}
</div>
<p class="text-muted-foreground">
{{ source.description }}
</p>
<a
:href="source.url"
target="_blank"
rel="noreferrer"
class="text-xs text-muted-foreground underline-offset-4 hover:underline"
>
{{ hostname(source.url) }}
<span class="sr-only"> (opens in a new tab)</span>
</a>
</HoverCardContent>
</HoverCard>
</DefineCitation>
<div class="mx-auto flex max-w-sm flex-col gap-3 py-6 text-sm leading-relaxed">
<p>
Next.js streams a route in chunks, so the page shows up before every
request finishes. <Citation :source="sources.streaming" />
</p>
<p>
Wrap a slow part of the page in a Suspense boundary and React sends the
fallback first. When the data resolves, the finished HTML streams into
the same response and replaces the fallback, with no extra request from
the browser. <Citation :source="sources.suspense" /> Server Components
help here, because their code never ships to the browser.
<Citation :source="sources.serverComponents" />
</p>
<p>
A loading.tsx file does the same for a whole route segment.
<Citation :source="sources.loading" /> It all runs over chunked transfer
encoding, so there is nothing extra to set up.
<Citation :source="sources.chunked" />
</p>
</div>
</template>Inline Citation is a source that sits in the sentence it supports. It is a Hover Card on a Button.
To show a list of sources after the reply, use Sources.
Installation
Inline Citation is built with the Hover Card and Button components.
pnpm dlx shadcn-vue@latest add hover-card button
Usage
<script setup lang="ts">
import { Button } from '@/components/ui/button'
import {
HoverCard,
HoverCardContent,
HoverCardTrigger,
} from '@/components/ui/hover-card'
</script>
<template>
<HoverCard :open-delay="10" :close-delay="100">
<HoverCardTrigger as-child>
<Button variant="secondary" size="xs">
{{ hostname }}
</Button>
</HoverCardTrigger>
<HoverCardContent class="flex w-64 flex-col gap-1">
<div class="font-medium">
{{ title }}
</div>
<a :href="url" target="_blank" rel="noreferrer">
{{ hostname }}
<span class="sr-only"> (opens in a new tab)</span>
</a>
</HoverCardContent>
</HoverCard>
</template>AI SDK
A source-url part is the citation. Set sendSources: true on toUIMessageStreamResponse(), or write the part yourself.
writer.write({
type: 'source-url',
sourceId: 'shadcn-vue',
url: 'https://www.shadcn-vue.com',
title: 'shadcn-vue',
})const sources = computed(() =>
props.message.parts.filter(part => part.type === 'source-url'),
)title is optional. Fall back to the URL's hostname.
Migrating from AI Elements Vue
If you added Inline Citation from AI Elements Vue, your project has a components/ai-elements/inline-citation/ folder. Paste this prompt into your coding agent to rebuild it on Hover Card and Button. Every export keeps its name and props, so the code that uses it keeps working.
Migrate components/ai-elements/inline-citation/ from AI Elements Vue to the shadcn-vue Hover Card and Button components.
Keep every export, with the same name, props and emits, so the code that imports it keeps working. Only change how each part renders.
1. Install the components: npx shadcn-vue@latest add hover-card button
2. Read https://www.shadcn-vue.com/docs/ai-elements/inline-citation and build Inline Citation the same way.
3. Rebuild each part:
- InlineCitationCard.vue renders a HoverCard. Set open-delay and close-delay on it.
- InlineCitationCardTrigger.vue renders a HoverCardTrigger with as-child and a Button with variant="secondary" and size="xs" inside, instead of a Badge, so it can take keyboard focus.
- InlineCitationCardBody.vue renders a HoverCardContent.
- InlineCitationSource.vue renders the title and a link to the URL that opens in a new tab, with "(opens in a new tab)" in an sr-only span.
- Keep InlineCitation.vue, InlineCitationText.vue, InlineCitationQuote.vue and the carousel parts as they are.
4. Remove the imports the files no longer use.
5. Run vue-tsc and fix any errors.Sponsors
Your logo hereshadcn-vue is free and open source. Sponsorship keeps it maintained.
Become a sponsor