mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
94.02k stars 32.3k forks source link

[material-ui] Add Bento Grid component #43034

Open CHRIBUR0309 opened 4 months ago

CHRIBUR0309 commented 4 months ago

Summary

I suggest you make a bento ui component with MUI.

I just started using MUI several days ago and I'm not good at using it. So, the code below is mainly written by ChatGPT-4o (I rewrote a few lines). There might be some mistakes....

import { FC, ReactNode } from 'react';
import {
  Grid,
  Box,
  type SxProps,
  type Theme,
} from '@mui/material';

export type BentoItemProps = {
  gridArea: string;
  children: ReactNode;
  sx?: SxProps<Theme>;
}

export const BentoItem: FC<BentoItemProps> = ({ children, gridArea, sx }) => (
  <Box sx={{ ...sx, gridArea }}>
    {children}
  </Box>
);

export type BentoGridProps = {
  layout: string;
  children: ReactNode;
  sx?: SxProps<Theme>;
}

export const BentoGrid: FC<BentoGridProps> = ({ layout, children, sx }) => (
  <Box sx={{
    ...sx,
    display: 'grid',
    gridTemplateAreas: layout,
  }}>
    {children}
  </Box>
);

If the bento ui doesn't match the Material Design Systems, you can ignore this suggestion.

Examples

Sorry, no example.

Motivation

Tailwind Grid Generator

I want the UI layout above with MUI.

Search keywords: bento

CHRIBUR0309 commented 4 months ago

Oh, I forgot the gap prop....

TheOneTheOnlyJJ commented 3 months ago

This would provide extreme versatility. +1