⚠️ Portosaur & This docs is Work In Progress!
Skip to content

Interactive Previews

You can use the <Pv /> component to preview various file types, including PDFs, images, code files, and more.

Main difference with <a> tag is that this opens a preview window instead of navigating to the file.


Basic Usage

:

mdx
Here is my <Pv href="/resume.pdf">Resume</Pv>.

:

mdx
These are <Pv href={["/resume.pdf", "/work-samples.zip"]}>Resume & Samples</Pv>.

<Pv /> Props

PropTypeDefaultDescription
hrefstring | array-Can be:
1. The root-relative (e.g. /code/script.py) or absolute URL of an asset
2. External direct asset URL
3. Embed URL
4. An Array of above
typestringautoForce a specific renderer. Can be:
1. video: play as video
2. image: view image
3. pdf: render PDF document
4. text: syntax highlighted code/text
5. web: embed external site in an iframe
titlestring-Custom title for the window header.
descstring-Tooltip text shown on hover.
idstring-Custom ID for the URL hash (e.g. #my-id-pv?m=popup).
dockbooleanfalseOpen in Dock mode.
pipbooleanfalseOpen in PiP mode.
modeSwitchbooleantrueShow/hide the mode switch (Dock/PiP) toggle.
noUlbooleanfalseIf true, disables the trigger link underline.

Automatic File Detection

You don't need to tell what kind of file is it for the basic usage. The system automatically detects and renders:

  • Documents: PDFs.
  • Code: 100+ languages with syntax highlighting.
  • Images: High-res previews with click-to-zoom.
  • Video: Native video player (mp4, webm, ogg, mkv).
  • Websites: Full external sites with a "Visit" fallback.

Forcing a Specific Renderer

If your URL doesn't have a standard extension (like an API endpoint or a dynamic stream), the auto-detection might not work. You can force a specific renderer by passing the type prop:

jsx
<Pv href="https://example.com/stream" type="video">
  Watch Live Stream
</Pv>

Choosing your Layout

There are 3 layout modes. You can set the starting layout mode using boolean flags, and the user can switch between them using the header buttons.

1. Popup (default)

It opens a centered modal that focuses user's attention on the document.

jsx
<Pv href="/design-spec.pdf">Open Specification</Pv>

2. PiP (pip)

Creates a floating window that stays visible while the user scrolls the main page.

  • Mobile: Becomes a YouTube-style mini-player at the bottom.
  • Desktop: A sleek floating window you can drag anywhere.
jsx
<Pv href="/demo.mp4" pip>
  Watch Demo while reading
</Pv>

3. Dock (dock)

Splits the screen to show content side-by-side.

  • Desktop: Pushes the documentation to the left and docks the preview to the right.
  • Mobile: Becomes a bottom-half "Peek" sheet.
jsx
<Pv href="/api-example.js" dock>
  View Code Side-by-Side
</Pv>

Tabbed Preview (Multi-Source)

You can group related files into a single preview window by passing an array to the href prop. Users can switch between files using an tab bar.

jsx
<Pv
  title="Project Source"
  href={[
    { path: "/src/index.js", label: "Logic" },
    { path: "/src/styles.css", label: "Theme" },
  ]}
>
  Browse Project Files
</Pv>

INFO

You don't have to pass separate path and label objects. You can just pass an array of strings, and the filename will automatically be used as the tab label:

jsx
<Pv href={["/src/index.js", "/src/styles.css"]}>Browse Project Files</Pv>