Skip to main content
Refine AI
Version: 3.xx.xx
Swizzle Ready

Import

<ImportButton> is compatible with the useImport hook and is meant to be used as it's upload button. It uses Material UI <LoadingButton> component and native html <input> element. It wraps a <label> with a <LoadingButton> component and <input> element and accepts it's own properties for separately.

Refer to the for more detailed information about useImport.

Swizzle

You can swizzle this component to customize it with the refine CLI

Usage

Use it like any other Material UI <LoadingButton>. You can use it with useImport:

localhost:3000/posts
Live previews only work with the latest documentation.
import { useImport } from "@pankod/refine-core";
import {
useDataGrid,
DataGrid,
GridColumns,
List,
ImportButton,
} from "@pankod/refine-mui";

const columns: GridColumns = [
{ field: "id", headerName: "ID", type: "number" },
{ field: "title", headerName: "Title", minWidth: 400, flex: 1 },
];

const PostsList: React.FC = () => {
const { dataGridProps } = useDataGrid<IPost>();

const { inputProps, isLoading } = useImport<IPost>();

return (
<List
headerButtons={
<ImportButton inputProps={inputProps} loading={isLoading} />
}
>
<DataGrid {...dataGridProps} columns={columns} autoHeight />
</List>
);
};

interface IPost {
id: number;
title: string;
}

Properties

hideText

It is used to show and not show the text of the button. When true, only the button icon is visible.

localhost:3000
Live previews only work with the latest documentation.
import { ImportButton } from "@pankod/refine-mui";

const MyImportComponent = () => {
return (
<ImportButton
hideText={true}
/>
);
};

API Reference

Properties

External Props

It also accepts all props of Material UI LoadingButton.