FileViewer

Auto-detecting file viewer. Accepts a FileSource (URL / base64 / bytes) and routes to the right renderer by category: image (delegates to ImageViewer), markdown (tabbed Preview / Source), text (highlight.js coloured), embedded (PDF and other browser-renderable types via <iframe>), zip (tree + nested viewer for the selected entry), and unsupported (info message). Detection prefers the source's MIME, otherwise the file extension.

Image source

Image kinds delegate to ImageViewer with Framed + Downloadable.

placeholder.png

Markdown source (inline bytes)

UTF-8 bytes decoded and rendered with Markdig in a Preview / Source tabbed pane.

Preview

Hello FileViewer

The FileViewer picks a renderer per file kind.

  • Images flow through ImageViewer.
  • Markdown picks up Markdig.
  • Text/code is coloured with highlight.js.
  • Zip archives expand to a tree.
var source = new FileSource.Bytes(bytes) { FileName = "readme.md" };
Text
# Hello FileViewer

The **FileViewer** picks a renderer per file kind.

- Images flow through `ImageViewer`.
- Markdown picks up Markdig.
- Text/code is coloured with highlight.js.
- Zip archives expand to a tree.

```csharp
var source = new FileSource.Bytes(bytes) { FileName = "readme.md" };
```

Text source (inline bytes, JSON)

UTF-8 bytes rendered through highlight.js using the language inferred from the file extension.

{
  "name": "ImageViewer",
  "features": ["rotate", "zoom", "flip", "crop"],
  "version": "1.0"
}

Unsupported

Unknown extensions fall through to a friendly message instead of throwing.

No inline preview is available for this file type.
Blazor

FileViewer Class

Parameters

Name
Type
Default
Description
FallbackRenderFragment?
Rendered when FileViewer.Source is null.
FileNamestring?
File name used for category detection (extension), the embedded <iframe> title, and as the default download name. Falls back to the source's own FileSource.FileName, otherwise to the URL's last path segment, otherwise to 'file'.
MaxHeightstring
60vh
Maximum height for inline renderers (text, markdown viewport, embedded iframe). Sets the scrollable region. Defaults to 60vh.
SourceFileSource?
File data to render. When null, FileViewer.Fallback is rendered instead (or nothing if no fallback is supplied).
Name: Fallback
Type: RenderFragment?
Description: Rendered when FileViewer.Source is null.
Name: FileName
Type: string?
Description: File name used for category detection (extension), the embedded <iframe> title, and as the default download name. Falls back to the source's own FileSource.FileName, otherwise to the URL's last path segment, otherwise to 'file'.
Name: MaxHeight
Type: string
Default: 60vh
Description: Maximum height for inline renderers (text, markdown viewport, embedded iframe). Sets the scrollable region. Defaults to 60vh.
Name: Source
Type: FileSource?
Description: File data to render. When null, FileViewer.Fallback is rendered instead (or nothing if no fallback is supplied).
React