Grid layout is the optimal choice for achieving this task as it provides control over the arrangement both horizontally and vertically. Utilize the SimpleGrid
component in MantineUI.
Remember that each Mantine component corresponds to specific CSS properties, so selecting a component applies those styles rather than purely organizing code. Below exemplifies how you can streamline your code and enhance maintainability by eliminating unnecessary Mantine components (see demo here).
//App.js
import { Fragment } from "react";
import {
MantineProvider,
Divider,
Paper,
SimpleGrid,
Text,
Title
} from "@mantine/core";
import { data } from "./data.js";
export default function App() {
const breakpoints = [
{ maxWidth: "60rem", cols: 3, spacing: "md" },
{ maxWidth: "40rem", cols: 2, spacing: "sm" },
{ maxWidth: "30rem", cols: 1, spacing: "sm" }
];
return (
<MantineProvider withGlobalStyles withNormalizeCSS>
<Paper shadow="xs" radius="xs" p="1rem" m="1rem">
<Title order={2}>Conta</Title>
<Text size="sm" color="violet-purple.0" fw={700} mb="lg">
Restaurante Vila do Fausto Ltda
</Text>
<Divider size="xs" variant="dotted" />
{data.map((section) => (
<Fragment key={section.title}>
<Title order={5} my="lg"gt;
{section.title}
</Title>
<SimpleGrid cols={4} spacing="lg" mb="lg" breakpoints={breakpoints}>
{section.content.map((item) => (
<div key={item.heading}>
<Text color="#7C9599" fw={700} size="sm">
{item.heading}:
</Text>
<Text size="0.8rem">{item.details}</Text>
</div>
))}
</SimpleGrid>
</Fragment>
))}
</Paper>
</MantineProvider>
);
}
//data.js
export const data = [
{
title: "Informações Gerais",
content: [
{ heading: "Nome da Empresa", details: "Lorem Ipsum" },
{ heading: "CPF / CNPJ", details: "Lorem Ipsum" },
{ heading: "Razão Social ", details: "Lorem Ipsum" },
{ heading: "E-mail", details: "Lorem Ipsum" },
{ heading: "Telefone", details: "Lorem Ipsum" },
{ heading: "Natureza Jurídica", details: "Lorem Ipsum" },
{ heading: "NIRE", details: "Lorem Ipsum" },
{ heading: "Orgão de Registro ", details: "Lorem Ipsum" }
]
},
{
title: "Endereço Principal",
content: [
{ heading: "Logradouro", details: "Lorem Ipsum" },
{ heading: "Número", details: "Lorem Ipsum" },
{ heading: "Bairro", details: "Lorem Ipsum" },
{ heading: "Cidade", details: "Lorem Ipsum" },
{ heading: "Estado", details: "Lorem Ipsum" },
{ heading: "Complemento", details: "Lorem Ipsum" },
{ heading: "CEP", details: "Lorem Ipsum" }
]
}
];