Tailwind Example/Boilerplate
Anyone have a Tailwind 4.0 and Refine Example app public? We are picking shadcn and tailwind for all our design systems. And wanted to see if anyone was already using it.
tailwind.config.js and adding the Tailwind directives to your CSS.RefineThemes from @refinedev/antd Documentation > Docs > Examples > Themes."Refine is a headless React-based framework... it can be used without being tied to any UI elements or framework." Top React Component Libraries and Frameworks Every Developer Should Know
useShow hook in sub-components of the <Show> tag in refine, you need to extract the data from the hook in your parent component and then pass it down to child components. Here's how you can do it:useShow hook returns a query result that contains the data for the record you're viewing. You can extract this data and pass it to child components:query property rather than queryResult:useShow hook automatically reads the resource and ID from the current URL, but you can also specify them explicitly if needed.useOne hook in child components to fetch related data based on the record's ID or other properties.useShow hook in refine, there are a couple of alternative approaches you can use:useShow in Each ComponentuseShow hook directly in any component that needs the data, even in child components. Since the hook reads the resource and ID from the URL by default, it will return the same data:useShow:``
This approach allows any nested component to access the record data without prop drilling, while still maintaining a single data fetch.
Both approaches are valid in refine, and the choice depends on your specific requirements and component structure. The context approach is generally more maintainable for complex component trees, while directly using useShow` in each component is simpler for smaller applications."Hey Community Member 100 we planto release MUI 6 in the nexy release cycle, which is December 5th" ask-any-questionMUI 6
@refinedev/nestjsx-crud where the query parameter format doesn't match what your server expects.sort[0]=id,ASC, but your server doesn't recognize this array notation in the sort parameter.getList method of the data provider. This is mentioned in a few GitHub issues as a solution for similar problems:npm create refine-app@latest -- --example blog-responsive-navbarnpm install -D tailwindcss postcss autoprefixer
npx tailwindcss initRefineThemesuseShowuseShowuseShowuseShowuseShowuseShowuseShow<Show>queryResult``
This approach allows any nested component to access the record data without prop drilling, while still maintaining a single data fetch.
Both approaches are valid in refine, and the choice depends on your specific requirements and component structure. The context approach is generally more maintainable for complex component trees, while directly using sort[0]=id,ASCimport { useShow } from "@refinedev/core";
import { Show } from "@refinedev/antd"; // or any other UI package
const ParentComponent = () => {
const { queryResult } = useShow();
const { data, isLoading } = queryResult;
const record = data?.data;
return (
<Show isLoading={isLoading}>
<ChildComponent record={record} />
<AnotherChildComponent record={record} />
</Show>
);
};
const ChildComponent = ({ record }) => {
return <div>{record?.title}</div>;
};import { useShow } from "@refinedev/core";
import { Show, MarkdownField } from "@refinedev/antd";
import { Typography } from "antd";
const { Title, Text } = Typography;
const PostShow = () => {
const { queryResult } = useShow();
const { data, isLoading } = queryResult;
const record = data?.data;
return (
<Show isLoading={isLoading}>
<Title level={5}>Id</Title>
<Text>{record?.id}</Text>
<Title level={5}>Title</Title>
<Text>{record?.title}</Text>
<CustomComponent record={record} />
</Show>
);
};
const CustomComponent = ({ record }) => {
// Use record data here
return <div>Custom view of {record?.title}</div>;
};import { useShow } from "@refinedev/core";
import { Show, TextField } from "@refinedev/mui";
import { Typography, Stack } from "@mui/material";
const ProductShow = () => {
const { queryResult } = useShow();
const { data, isLoading } = queryResult;
const record = data?.data;
return (
<Show isLoading={isLoading}>
<Stack gap={1}>
<Typography variant="body1" fontWeight="bold">
Id
</Typography>
<TextField value={record?.id ?? ""} />
<DetailSection record={record} />
</Stack>
</Show>
);
};
const DetailSection = ({ record }) => {
// Use record data here
return (
<>
<Typography variant="body1" fontWeight="bold">
Additional Details
</Typography>
<div>{record?.additionalInfo}</div>
</>
);
};import { useShow } from "@refinedev/core";
import { Show, TextField } from "@refinedev/chakra-ui";
import { Heading } from "@chakra-ui/react";
const ProductShow = () => {
const { queryResult } = useShow();
const { data, isLoading } = queryResult;
const record = data?.data;
return (
<Show isLoading={isLoading}>
<Heading as="h5" size="sm">
Id
</Heading>
<TextField value={record?.id} />
<RelatedInfo record={record} />
</Show>
);
};
const RelatedInfo = ({ record }) => {
// Use record data here
return (
<>
<Heading as="h5" size="sm" mt={4}>
Related Information
</Heading>
<div>{record?.relatedData}</div>
</>
);
};const { query } = useShow();
const { data, isLoading } = query;
const record = data?.data;import { useShow } from "@refinedev/core";
const ChildComponent = () => {
const { queryResult } = useShow();
const { data, isLoading } = queryResult;
const record = data?.data;
return <div>{record?.title}</div>;
}; import { DataProvider } from "@refinedev/nestjsx-crud";
const originalDataProvider = DataProvider("YOUR_API_URL");
const customDataProvider = {
...originalDataProvider,
getList: async ({ resource, pagination, filters, sorters, meta }) => {
// Modify the sorters format here to match what your server expects
// For example, if your server expects sort=id,ASC instead of sort[0]=id,ASC
return originalDataProvider.getList({
resource,
pagination,
filters,
sorters,
meta: {
...meta,
// You might need to add custom query params here
},
});
},
}; import { useTable } from "@refinedev/core";
const { tableQuery, sorters } = useTable({
sorters: {
mode: "off", // This disables server-side sorting
initial: [{ field: "id", order: "asc" }]
},
});
// Then sort the data client-side
const sortedData = useMemo(() => {
if (sorters.length === 0) {
return tableQuery.data;
}
return tableQuery.data.sort((a, b) => {
const sorter = sorters[0];
if (sorter.order === "asc") {
return a[sorter.field] > b[sorter.field] ? 1 : -1;
} else {
return a[sorter.field] < b[sorter.field] ? 1 : -1;
}
});
}, [tableQuery.data, sorters]);