Skip to main content
Refine AI
Version: 4.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.

For more information, refer to the useImport documentation โ†’

Good to know:

You can swizzle this component with the Refine CLI to customize it.

Usageโ€‹

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

localhost:3000
import {
useDataGrid,
List,
ImportButton,
} from "@refinedev/mui";
import { DataGrid, GridColDef } from "@mui/x-data-grid";

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

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

return (
<List>
<ImportButton />
<DataGrid {...dataGridProps} columns={columns} />
</List>
);
};

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

Propertiesโ€‹

hideTextโ€‹

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

localhost:3000
import { ImportButton } from "@refinedev/mui";

const MyImportComponent = () => {
return (
<ImportButton
resource="posts"
/>
);
};

API Referenceโ€‹

Propertiesโ€‹

PropertyTypeDescriptionDefault
hideText

boolean

Whether should hide the text and show only the icon or not.

false

inputProps
๏นก

UseImportInputPropsType

svgIconProps

SvgIconProps

loading

boolean

Set the loading status of button

false

External Props:

It also accepts all props of Material UI LoadingButton.