Toolpad

repository·master·Indexed 23 days ago

https://github.com/mui/toolpad

A suite of tools and components, including @toolpad/core, designed for building internal tools, admin panels, and CRUD applications. It provides integrations for Next.js, Vite, and various authentication providers, and includes a CLI tool, create-toolpad-app, for bootstrapping projects from examples.

Tokens
65.3K
Snippets
154
Records
398
Agent score
82%

What's inside Toolpad

  1. Overview of Toolpad Core components

    master

    Toolpad Core provides a set of pre-built components designed to accelerate the development of internal tools and dashboards. The core component library includes:

    • Account: User profile and account management UI.
    • App Provider: The root provider for managing application state and configuration.
    • CRUD: Components for performing Create, Read, Update, and Delete operations on data.
    • Dashboard Layout: A structured layout for dashboard-style applications.
    • Page Container: A wrapper for consistent page-level layout and spacing.
    • Sign-in Page: A ready-to-use authentication UI.
  2. Overview of Toolpad Core

    master
    Toolpad Core is a set of full-stack components designed for building dashboards, internal tools, and B2B web applications using React. It is built on top of Next.js and provides high-level components for layout, navigation, authentication, and data management to accelerate the development of scalable dashboards.
  3. Capabilities demonstrated in the Basic CRUD application

    master

    The basic-crud-app example serves as a reference implementation for several core Toolpad patterns:

    • Backend functions: How to implement and invoke logic on the server side.
    • Forms and Components: Using standard UI components and form handling within the Toolpad ecosystem.
    • Data Grid Operations: How to perform row-level actions such as deleting or adding rows in a data grid.
    • Query Parameter Binding: How to bind component state or behavior to URL query parameters.
  4. Toolpad Studio JavaScript API Reference

    master
    Toolpad Studio provides a set of JavaScript APIs to extend its capabilities. The primary entry points for extending the platform are through specialized creation functions that allow you to define new components, data providers, functions, and handlers, as well as a method to retrieve the current execution context.
  5. Capabilities demonstrated in the npm-stats example

    master

    The npm-stats example serves as a reference implementation for several Toolpad Studio capabilities:

    1. Third-party REST API integration: Fetching data from external sources into a Toolpad Studio app.
    2. Custom components: Implementing and using custom UI elements like charts.
    3. Material UI integration: Using pre-built components such as the MUI X Date Picker.
    4. Data transformation: Processing and transforming raw data for display within the dashboard.
  6. Capabilities demonstrated in the QR Code generator example

    master

    The QR Code generator example serves as a reference for several Toolpad Studio capabilities:

    • Custom Functions: Using a custom function that accepts parameters.
    • External Dependencies: Importing and using external npm packages.
    • UI Components: Utilizing TextInput and Image components.
    • Data Binding: Binding a TextInput component to a query parameter.
  7. Implement Role-Based Access Control (RBAC) with AuthorizationProvider

    master

    To enable Role-Based Access Control (RBAC) across your application, wrap your layout with the AuthorizationProvider from @mui/toolpad/auth. You must provide a getRolesFromUser function that extracts roles from your user object.

    This provider enables both UI-level protection and data-level enforcement.

    // app/layout.tsx
    import { AuthorizationProvider } from '@mui/toolpad/auth';
    
    function getRolesFromUser(user) {
      return user.roles;
    }
    
    export default function Layout() {
      return <AuthorizationProvider getRolesFromUser={getRolesFromUser} />;
    }
  8. Bind data to UI components

    master

    Toolpad Studio allows you to connect data (from queries or state) to component properties using the Bind button found in the inspector.

    How to Bind

    1. Select a component (e.g., a Data Grid).
    2. Locate a bindable property in the inspector (e.g., rows). Properties with a Bind button next to them can be connected to page state.
    3. Click the Bind button to open the binding editor.
    4. Enter a JavaScript expression that references the available state. For a query named dogQuery, you would use:
      dogQuery.data;
    5. Save the binding.
    dogQuery.data;
  9. Project structure for Toolpad Core (Next.js App Router)

    master

    When using the automatic installation with the Next.js App router, the directory structure varies depending on whether authentication was selected.

    Without Authentication

    Focuses on the (dashboard) route group for application pages.

    With Authentication

    Includes additional routes for authentication, such as app/auth/signin/page.tsx and API routes for handling authentication logic (e.g., app/api/auth/[...nextauth]/route.ts). If authentication is enabled, you must configure the generated .env files with the necessary credentials.

    # Without Authentication
    ├── app
    │   ├── (dashboard)
    │   │   ├── layout.tsx
    │   │   ├── page.tsx
    │   │   └── orders
    │   │       └── page.tsx
    │   └── layout.tsx
    ├── .env
    ├── package.json
    └── ...
    
    # With Authentication
    ├── app
    │   ├── auth
    │   │   └── signin
    │   │       └── page.tsx
    │   ├── api
    │   │   └── auth
    │   │       └── [...nextauth]
    │   │           └── route.ts
    │   ├── (dashboard)
    │   │   ├── layout.tsx
    │   │   ├── page.tsx
    │   │   └── orders
    │   │       └── page.tsx
    │   └── layout.tsx
    ├── .env
    ├── package.json
    └── ...