Components
Inspector
Inspector presents supplemental controls or contextual details beside primary content.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { useState } from 'react';
import { Button, Text, VStack } from '@swiftuijs/ui';
import { Inspector, type IInspectorProps } from '@swiftuijs/ui';
function Demo(props: Partial<IInspectorProps>) {
const [isPresented, setIsPresented] = useState(true);
return (<VStack spacing={12}>
<Button onClick={() => setIsPresented((value) => !value)}>
{isPresented ? 'Hide inspector' : 'Show inspector'}
</Button>
<Inspector content={<VStack spacing={8}>
<Text>Selection details</Text>
<Text>Properties</Text>
<Text>Actions</Text>
</VStack>} isPresented={isPresented} onOpenChange={setIsPresented} style={{ minHeight: '280px' }} title="Inspector" {...props}>
<VStack spacing={8}>
<Text>Main document content</Text>
<Text>Inspector is useful for secondary controls and metadata.</Text>
</VStack>
</Inspector>
</VStack>);
}
export default function Example() {
return (<Demo />);
}Usage and limitations
- Use
isPresentedandonOpenChangeto control visibility from React state - Use
contentfor the secondary inspection panel - Use
placement="leading"when the inspector should appear before primary content
More examples
Leading Placement
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
isPresented | boolean | Yes | Whether the inspector is visible. |
onOpenChange | (isPresented: boolean) => void | No | Called when the visibility should change. |
content | ReactNode | Yes | Inspector content rendered in the side panel. |
placement | 'leading' | 'trailing' | No | Placement of the inspector relative to the main content. Default: 'trailing' |
width | number | string | No | Panel width. Default: 320 |
title | string | No | Accessible title for the inspector region. |
dismissLabel | string | No | Dismiss button label. Default: 'Hide inspector' |
Inherits additional props from IBaseComponent.