Skip to content

ViewOnly

The ViewOnly component displays data as read-only label-value pairs. It supports single-column and responsive two-column layouts, horizontal or vertical item layouts, loading states, and custom React content for any value.

Variations

Single column layout

Force a single-column layout regardless of container width with layout="singleColumn".

Two-column layout

By default the component uses a responsive two-column layout when the container is wide enough (≥800px), automatically splitting the data between the two columns.

Loading state

Display skeleton placeholders while data is being fetched.

Empty values

When a value is empty, null, or undefined, the component displays “empty” in a disabled style.

Custom value content

Values can be any React node, allowing for custom formatting and components.

Using ViewOnlyItem directly

Use the ViewOnlyItem component directly for more control over layout.

Installation

import { ViewOnly } from "@harnessio/ui/components";
<ViewOnly
title="Section Title"
data={[
{ label: "Label 1", value: "Value 1" },
{ label: "Label 2", value: "Value 2" },
]}
/>;