ShowButton
ShowButton
The <ShowButton> component is a link button that navigates to the show/detail page of the current record. It must be used inside a RecordContext.
Usage
Use it in a DataTable or as an action button:
import { DataTable, ShowButton, EditButton } from '@/components/admin';
const PostList = () => (
<DataTable>
<DataTable.Col source="title" />
<DataTable.Col source="author" />
<DataTable.Col label="Actions">
<div className="flex gap-2">
<ShowButton />
<EditButton />
</div>
</DataTable.Col>
</DataTable>
);Installation
npx better-admin add show-buttonProps
| Prop | Required | Type | Default | Description |
|---|---|---|---|---|
label | Optional | string | "Show" | Button label text |
record | Optional | object | From context | Record object with id |
resource | Optional | string | From context | Resource name |
icon | Optional | ReactNode | Eye icon | Custom button icon |
variant | Optional | string | "ghost" | Button variant |
Row Click Alternative
Make entire rows clickable to navigate to show page:
<DataTable rowClick="show">
<DataTable.Col source="title" />
<DataTable.Col source="author" />
<DataTable.Col source="published_at" />
</DataTable>Custom Label
<ShowButton label="View" />
<ShowButton label="Details" />Custom Icon
import { Eye } from 'lucide-react';
<ShowButton icon={<Eye />} />Different Variants
<ShowButton variant="default" />
<ShowButton variant="outline" />
<ShowButton variant="ghost" />With better-query
ShowButton works with better-query data:
import { List, DataTable, ShowButton } from '@/components/admin';
import { useQuery } from 'better-admin';
import { query } from '@/lib/query';
export function UserList() {
const { data } = useQuery("user", query);
return (
<List>
<DataTable data={data}>
<DataTable.Col source="name" />
<DataTable.Col source="email" />
<DataTable.Col label="Actions">
<ShowButton />
</DataTable.Col>
</DataTable>
</List>
);
}Complete Example
import {
DataTable,
ShowButton,
EditButton,
DeleteButton,
TextField,
DateField,
} from '@/components/admin';
export const OrderList = () => (
<DataTable>
<DataTable.Col source="id" />
<DataTable.Col source="order_number">
<TextField />
</DataTable.Col>
<DataTable.Col source="total" />
<DataTable.Col source="created_at">
<DateField />
</DataTable.Col>
<DataTable.Col label="Actions">
<div className="flex gap-2">
<ShowButton variant="outline" />
<EditButton />
<DeleteButton variant="destructive" />
</div>
</DataTable.Col>
</DataTable>
);Related Components
- Show - Show page container
- EditButton - Navigate to edit page
- DataTable - Table component