5.21.0 • Published 10 months ago

@refinedev/mui v5.21.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Discord Twitter Follow

It eliminates repetitive tasks in CRUD operations and provides industry-standard solutions for critical project components like authentication, access control, routing, networking, state management, and i18n.

Material UI integration for Refine

Material UI is a library of React UI components that implements Google's Material Design.

Refine is headless by design, offering unlimited styling and customization options. Moreover, Refine ships with ready-made integrations for Ant Design, Material UI, Mantine, and Chakra UI for convenience.

Refine has connectors for 15+ backend services, including REST API, GraphQL, and popular services like Airtable, Strapi, Supabase, Firebase, and NestJS.

Installation

To use Refine with Material UI, you need to install the following package @refinedev/mui along with the Material UI packages:

npm install @refinedev/mui @mui/material @mui/lab @mui/x-data-grid @emotion/react @emotion/styled

⚡ Try Refine

Start a new project with Refine in seconds using the following command:

npm create refine-app@latest my-refine-app

Or you can create a new project on your browser:

Quick Start

Here's Refine in action, the below code is an example of a simple CRUD application using Refine + React Router + Material UI:

import React from "react";
import { Refine, useMany } from "@refinedev/core";
import { ThemedLayoutV2 } from "@refinedev/mui";
import dataProvider from "@refinedev/simple-rest";
import routerBindings from "@refinedev/react-router-v6";
import { BrowserRouter, Outlet, Route, Routes } from "react-router-dom";

import CssBaseline from "@mui/material/CssBaseline";

export default function App() {
  return (
    <BrowserRouter>
      <CssBaseline />
      <Refine
        dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
        routerProvider={routerBindings}
        resources={[
          {
            name: "products",
            list: "/products",
          },
        ]}
      >
        <Routes>
          <Route
            element={
              <ThemedLayoutV2>
                <Outlet />
              </ThemedLayoutV2>
            }
          >
            <Route path="/products">
              <Route index element={<ProductList />} />
            </Route>
          </Route>
        </Routes>
      </Refine>
    </BrowserRouter>
  );
}

// src/pages/products/list.tsx

import { List, useDataGrid, DateField } from "@refinedev/mui";
import { DataGrid, GridColDef } from "@mui/x-data-grid";

export const ProductList = () => {
  const { dataGridProps } = useDataGrid();

  const { data: categories, isLoading } = useMany({
    resource: "categories",
    ids:
      dataGridProps?.rows?.map((item) => item?.category?.id).filter(Boolean) ??
      [],
    queryOptions: {
      enabled: !!dataGridProps?.rows,
    },
  });

  const columns = React.useMemo<GridColDef[]>(
    () => [
      { field: "id", headerName: "ID", type: "number" },
      { field: "name", flex: 1, headerName: "Name" },
      {
        field: "category",
        flex: 1,
        headerName: "Category",
        renderCell: ({ value }) =>
          isLoading
            ? "Loading..."
            : categories?.data?.find((item) => item.id === value?.id)?.title,
      },
      {
        field: "createdAt",
        flex: 1,
        headerName: "Created at",
        renderCell: ({ value }) => <DateField value={value} />,
      },
    ],
    [categories?.data, isLoading],
  );

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

The result will look like this:

Refine + Material UI Example

Documentation

5.21.0

10 months ago

5.16.0

1 year ago

5.17.0

1 year ago

5.20.0

11 months ago

5.18.0

12 months ago

5.19.0

12 months ago

5.15.1

1 year ago

5.15.0

1 year ago

5.14.6

1 year ago

6.0.0

1 year ago

5.14.5

1 year ago

5.14.4

1 year ago

5.14.3

1 year ago

5.14.3-alpha.0

1 year ago

5.14.2

1 year ago

5.14.1

2 years ago

5.14.0

2 years ago

5.13.2

2 years ago

5.13.1

2 years ago

5.13.0

2 years ago

5.11.2

2 years ago

5.11.1

2 years ago

5.11.0

2 years ago

5.8.0

2 years ago

5.12.0

2 years ago

5.10.0

2 years ago

5.13.9

2 years ago

5.13.8

2 years ago

5.13.7

2 years ago

5.13.6

2 years ago

5.13.5

2 years ago

5.13.4

2 years ago

5.13.3

2 years ago

5.13.16

2 years ago

5.13.17

2 years ago

5.13.18

2 years ago

5.13.12

2 years ago

5.13.13

2 years ago

5.13.14

2 years ago

5.13.15

2 years ago

5.9.0

2 years ago

5.13.10

2 years ago

5.13.11

2 years ago

5.7.0

2 years ago

5.6.0

2 years ago

4.18.1

2 years ago

4.16.3

2 years ago

4.14.5

2 years ago

5.5.0

2 years ago

4.18.2

2 years ago

4.16.4

2 years ago

4.14.6

2 years ago

4.14.7

2 years ago

5.3.0

2 years ago

4.14.1

2 years ago

5.1.0

2 years ago

4.16.0

2 years ago

4.14.2

2 years ago

4.16.1

2 years ago

4.14.3

2 years ago

4.18.0

2 years ago

4.16.2

2 years ago

5.4.0

2 years ago

5.2.0

2 years ago

4.15.0

2 years ago

5.0.0

2 years ago

4.17.0

2 years ago

4.14.0

2 years ago

4.13.0

2 years ago

4.12.0

2 years ago

4.11.0

2 years ago

4.10.3

2 years ago

4.10.1

2 years ago

4.10.0

2 years ago

4.9.0

2 years ago

4.8.0

2 years ago

4.7.2

2 years ago

4.7.1

2 years ago

4.7.0

2 years ago

4.6.0

2 years ago

4.5.10

2 years ago

4.5.9

2 years ago

4.5.8

2 years ago

4.5.7

2 years ago

4.5.6

2 years ago

4.5.5

2 years ago

4.5.4

2 years ago

4.5.3

2 years ago

4.5.2

2 years ago

4.5.1

2 years ago

4.5.0

2 years ago

4.4.0

2 years ago

4.3.2

2 years ago

4.3.1

2 years ago

4.3.0

2 years ago

4.2.0

2 years ago

4.1.0

2 years ago

4.0.0

2 years ago