The DisplayData component is a UI component used to render a list of data rows within a Section. It automatically formats different types of values into appropriate UI elements like links, checkboxes, or color indicators.
Row Types
Each object in the rows array must follow the DisplayDataRow type:
- Link type:
{ type: 'link', value?: string } — Renders an "Open" link using the provided URL. - ReactNode type:
{ value: ReactNode } — Renders custom React elements. The component applies special logic based on the type of value:string: If the string is a valid RGB color (detected via isRGB), it renders an <RGB /> component. Otherwise, it renders the string.boolean: Renders a disabled <Checkbox /> indicating the state.undefined: Renders an empty placeholder.
Props
rows: An array of DisplayDataRow objects (required).header: Optional React node to display as the section header.footer: Optional React node to display as the section footer.
import { DisplayData, type DisplayDataRow } from '@/components/DisplayData/DisplayData';
const rows: DisplayDataRow[] = [
{ title: 'Status', value: true }, // Renders a disabled checkbox
{ title: 'Color', value: '#ff0000' }, // Renders an RGB color component
{ type: 'link', value: 'https://t.me/example' }, // Renders an "Open" link
{ title: 'Custom', value: <span>Custom Content</span> }, // Renders raw ReactNode
{ title: 'Empty', value: undefined }, // Renders *empty*
];
export const MyComponent = () => (
<DisplayData
header={<span>My Data Section</span>}
rows={rows}
/>
);