Skip to main content
Clever Ops

Citation Rail

Inline numbered source chips paired with a rail of sources, favicon placeholder, domain, and title, plus a keyboard-accessible snippet peek on hover or focus.

Preview & code

Loading Citation Rail preview

Installation

pnpm dlx shadcn@latest add @cleverui/citation-rail

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { CitationRail } from '@/components/ui/citation-rail'
Exampletsx
'use client'

import { CitationRail, type CitationSource } from '@/components/ui/citation-rail'

const PASSAGE =
  'Stripe refunds settle in two to seven business days for US debit cards [1], while chargebacks follow a separate dispute timeline that can stretch past 75 days [2]. For enterprise billing, Acme Logistics posted a 12% reduction in open exceptions after wiring Meridian into their Xero close pack [3].'

const SOURCES: CitationSource[] = [
  {
    id: 'stripe-refunds',
    title: 'Refunds, timing and settlement windows',
    domain: 'stripe.com',
    snippet:
      'Most US debit-card refunds appear within 2–7 business days. Credit cards may take one full statement cycle depending on the issuing bank.',
    href: 'https://stripe.com/docs/refunds',
  },
  {
    id: 'stripe-disputes',
    title: 'Disputes and chargeback timelines',
    domain: 'stripe.com',
    snippet:
      'Issuers can open a dispute for up to 75–120 days after the charge posts. Respond with evidence before the deadline listed in the Dashboard.',
    href: 'https://stripe.com/docs/disputes',
  },
  {
    id: 'meridian-case',
    title: 'How Acme Logistics cut month-end exceptions by 12%',
    domain: 'meridian.dev',
    snippet:
      'After connecting Meridian to Xero, the finance team closed March with 41 fewer open invoice exceptions and a single human approval gate on refunds over $500.',
    href: 'https://meridian.dev/customers/acme-logistics',
  },
]

export default function CitationRailDemo() {
  return (
    <div className="mx-auto w-full max-w-5xl px-4 py-12 sm:px-6 sm:py-16">
      <div className="mb-8 max-w-2xl">
        <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground sm:text-xs">
          Answer · refund policy
        </p>
        <h2 className="mt-3 text-xl font-semibold tracking-tight text-balance sm:text-2xl">
          When does a Stripe refund hit the card?
        </h2>
      </div>
      <CitationRail
        passage={PASSAGE}
        sources={SOURCES}
        railLabel="Sources"
        onSourceClick={() => {
          /* demo: parent would open source detail */
        }}
      />
    </div>
  )
}

API reference

CitationRail accepts the following props.

PropTypeDefaultDescription
passage*stringanswer text containing [1]-style markers bound to sources by number
sources*CitationSource[]ordered source list; index+1 matches the passage markers
railLabelstring'Sources'mono micro-label heading the rail
onSourceClick(id: string) => voidfires on rail-entry or chip activation

…plus everything from React.HTMLAttributes<HTMLElement>: className, event handlers, aria attributes and the rest pass straight through.

Referenced types

Typestsx
export interface CitationSource {
  id: string
  title: string
  domain: string
  snippet?: string
  href?: string
}

Frequently asked questions

How do I install the Citation Rail component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/citation-rail`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Citation Rail require?

Citation Rail uses motion and lucide-react on top of React and Tailwind CSS. You don't need to install them manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Citation Rail to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services