diff --git a/.github/workflows/build-examples.yml b/.github/workflows/build-examples.yml
index 2f2f25320399..f6f9e364d139 100644
--- a/.github/workflows/build-examples.yml
+++ b/.github/workflows/build-examples.yml
@@ -23,10 +23,11 @@ on:
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
- environment:
- description: "Environment to run tests against"
- type: environment
+ build_all_examples:
+ description: "Build all examples"
+ type: boolean
required: false
+ default: true
jobs:
chunks:
@@ -67,7 +68,7 @@ jobs:
- name: Split Into Chunks
id: chunkstep
- run: CHUNKS=6 BASE_REF=${{ github.base_ref }} BUILD_ALL_EXAMPLES=${{ (contains(steps.pr-labels.outputs.labels, ' build-examples ') || github.event_name == 'schedule' ) && 'true' || 'false' }} node ./.github/workflows/scripts/build-example-chunks.js
+ run: CHUNKS=6 BASE_REF=${{ github.base_ref }} BUILD_ALL_EXAMPLES=${{ (github.event.inputs.build_all_examples || contains(steps.pr-labels.outputs.labels, ' build-examples ') || github.event_name == 'schedule' ) && 'true' || 'false' }} node ./.github/workflows/scripts/build-example-chunks.js
build-chunk-1:
runs-on: ubuntu-latest
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3a8ca942433a..914caccd60ba 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,9 +2,6 @@ name: Release
on:
push:
- paths:
- - ".changeset/**"
- - "packages/**"
branches:
- main
diff --git a/documentation/blog/2022-11-17-antd-dynamic-form.md b/documentation/blog/2024-12-20-antd-dynamic-form.md
similarity index 96%
rename from documentation/blog/2022-11-17-antd-dynamic-form.md
rename to documentation/blog/2024-12-20-antd-dynamic-form.md
index 93c30c85201b..e9ac6ef02797 100644
--- a/documentation/blog/2022-11-17-antd-dynamic-form.md
+++ b/documentation/blog/2024-12-20-antd-dynamic-form.md
@@ -4,12 +4,17 @@ description: Easy way to creating dynamic forms in React CRUD apps with Ant Desi
slug: react-crud-app-with-dynamic-form-ant-design
authors: david_omotayo
tags: [react, Refine, tutorial, ant-design]
-image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-11-17-antd-dynamic-form/social.png
+image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-11-17-antd-dynamic-form/social-2.png
hide_table_of_contents: false
---
+**This article was last updated on December 20, 2024, to include advanced styling techniques for Ant Design dynamic forms and integration with form libraries like Formik and React Hook Form. Additionally, the introduction has been updated for clarity.**
+
## Introduction
+**TL;DR:** What is Ant Design Dynamic Form?
+Ant Design provides a dynamic form that enables the developer to create flexible and interactive forms, where users can dynamically add or remove fields if needed, making it quite suitable for complex data collection.
+
Forms are one of the most adaptable elements in web development. They come in distinct structures for various use cases.
However, due to the sporadic complexity of the information they collect, they tend to grow larger with several fields, which can be a big turnoff for most users.
@@ -31,7 +36,8 @@ Steps we'll cover:
- [Adding icons](#adding-icons)
- [Validation](#validation)
- [Building the edit page](#building-the-edit-page)
-- [Live StackBlitz Example](#example)
+- [FAQ's](#faqs)
+- [Why Use AntD Dynamic Forms?](#why-use-antd-dynamic-forms)
**Prerequisite**
@@ -1174,7 +1180,26 @@ This is a duplicate of the form component we created inside the `UserCreate` pag
That's it. We've successfully built an application that uses an API to post and edit response records using a **dynamic form**.
-As a challenge, visit Refine's [documentation](https://refine.dev/docs/) to learn how you can add a `delete` button to the fields on the table and make your application a full-fledged CRUD application. Cheers!
+As a challenge, visit Refine's [documentation](https://refine.dev/docs/) to learn how you can add a `delete` button to the fields on the table and make your application a full-fledged CRUD application.
+
+## FAQ's
+
+- What is a dynamic form?
+ A dynamic form is one that automatically changes its structure depending on what the user enters, often allowing users to add or remove fields dynamically.
+
+- How do I start using dynamic fields from Ant Design?
+ To manage dynamic fields, use the component and methods provided by `
`: add() and remove().
+
+- Is it possible to add validation to dynamic form fields?
+ Yes, you can utilize the rules prop on `` to extend your own validate logic.
+
+## Why Use AntD Dynamic Forms?
+
+Dynamic forms improve user satisfaction by:
+
+- Simplifying User Input: Users only see fields they need, reducing form clutter.
+- Flexibility: Provide the user with the facility to add or remove fields as required.
+- Streamlining Complex Data: Collect additional details without overwhelming users with lengthy forms upfront. • Saving Time: Automate repetitive input scenarios with less manual work.
## Conclusion
diff --git a/documentation/blog/2022-10-30-mui-select.md b/documentation/blog/2024-12-20-mui-select.md
similarity index 86%
rename from documentation/blog/2022-10-30-mui-select.md
rename to documentation/blog/2024-12-20-mui-select.md
index a84f4cc98786..313468bc5d86 100644
--- a/documentation/blog/2022-10-30-mui-select.md
+++ b/documentation/blog/2024-12-20-mui-select.md
@@ -4,12 +4,30 @@ description: We'll discover the Material UI select component with examples
slug: material-ui-select-component
authors: doro_onome
tags: [material-ui, react]
-image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-10-30-mui-select/social.png
+image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-10-30-mui-select/social-2.png
hide_table_of_contents: false
---
+**This article was last updated on December 20, 2024, to include advanced styling techniques for Material UI Select and integration with form libraries like Formik and React Hook Form. Also the introduction is updated for clarity.**
+
## Introduction
+**TL;DR:**
+
+Material UI Select is a component to create dropdowns in React that provides native customization options for styles, indicators, decorators, and grouped options.
+
+**How to use Material UI Select?**
+
+- Import the required components, Select and Option, from @mui/joy:.
+- Customize with props like placeholder, defaultValue, and indicator.
+- Sx to style for responsive and dynamic designs.
+
+**Key Features of Material-UI Select:**
+
+- Custom Indicators: Replaces the default dropdown arrow for your icon.
+- Decorators: Appending icons or elements before or after the select field.
+- Options Grouped Together: A categorization of options contributes towards better usability. 4. Clearable Select: Add a clear button for resetting the selection. 5. - - - Accessibility: Native support for ARIA attributes.
+
Material UI provides a plethora of available styled components that assist developers in creating responsive and aesthetically pleasing web designs. One of these components is Material UI's Select, which is an input field that showcases a list of customizable options. In this tutorial, we will deeply dive into **Material UI Select**, look at its prop possibilities, and highlight its features. We will also investigate a potential use case in a real-world application.
Steps we'll cover:
@@ -18,12 +36,11 @@ Steps we'll cover:
- [Getting Started with Material UI Select](#getting-started-with-material-ui-select)
- [The Option component](#the-option-component)
- [Other Material UI Select features](#other-material-ui-select-features)
- - [Indicator](#indicator)
- - [Decorator](#decorator)
- - [Grouped Options](#grouped-options)
- [Clearing the Select field](#clearing-the-select-field)
- [Accessibility](#accessibility)
- [Building a Sign-up Form UI with React and Material UI Select](#building-a-sign-up-form-ui-with-react-and-material-ui-select)
+- [Advanced Styling with Material UI Select](#advanced-styling-with-material-ui-select)
+- [Integration with Form Libraries (Formik and React Hook Form)](#integration-with-form-libraries-formik-and-react-hook-form)
## What is Material UI
@@ -527,6 +544,72 @@ And the result:
+## Advanced Styling with Material UI Select
+
+Material UI Select has more detailed customization with the sx prop and themes. On this page you can show how to:
+
+- Override default styles for hover, focus, and selected states.
+- Integrate custom themes to maintain consistent styling throughout the application.
+- Add animations for dropdown behavior or transitions.
+
+```tsx
+
+ Option One
+ Option Two
+ Option Three
+
+```
+
+## Integration with Form Libraries (Formik and React Hook Form)
+
+This section would appeal to developers building forms with validation.
+
+Example with React Hook Form:
+
+```tsx
+import { useForm, Controller } from "react-hook-form";
+import Select from "@mui/joy/Select";
+import Option from "@mui/joy/Option";
+
+export default function FormWithSelect() {
+ const { control, handleSubmit } = useForm();
+
+ const onSubmit = (data) => {
+ console.log(data);
+ };
+
+ return (
+
+ );
+}
+```
+
## Conclusion
This article covered the **Material UI Select** component, navigated its features, and highlighted its functionalities in a React application. We also investigated a use case by developing a Sign-up form UI in React with **Material UI Select**. I hope you find this post helpful.
diff --git a/documentation/blog/2023-03-07-react-dnd.md b/documentation/blog/2024-12-24-react-dnd.md
similarity index 89%
rename from documentation/blog/2023-03-07-react-dnd.md
rename to documentation/blog/2024-12-24-react-dnd.md
index f8d48d5c7237..7d44b07c1ab7 100644
--- a/documentation/blog/2023-03-07-react-dnd.md
+++ b/documentation/blog/2024-12-24-react-dnd.md
@@ -4,17 +4,19 @@ description: We'll be using the react-dnd library to create draggable components
slug: react-draggable-components-with-react-dnd
authors: david_omotayo
tags: [react, Refine, tutorial]
-image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2023-03-07-react-dnd/social.png
+image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2023-03-07-react-dnd/social-2.png
hide_table_of_contents: false
---
+**This article was last updated on December 24, 2024, to include advanced techniques for optimizing React-DND performance, such as avoiding unnecessary re-renders, virtualizing large lists, and supporting mobile devices with the Touch Backend, along with simplified explanations for better clarity.**
+
-# Introduction
+## Introduction
The HTML Drag-and-Drop API is a pioneering feature of the web, whose introduction has inspired developers to find innovative ways of using it to enhance the user experience on their websites.
@@ -688,15 +690,6 @@ Now, if you save your project go back to the browser, you should see the cards r
-
-
-
-
-
## Using the useDrag hook
To make our cards draggable, we'll declare the `useDrag` hook inside the `cards` component, give it a `type` and item `value`, and then pass the `dragRef` variable to the card component using the `ref` attribute.
@@ -901,6 +894,114 @@ If you save your progress and revisit the browser, you should now be able to dra
That's all. We have successfully created a kanban board with draggable cards and columns with drop zones. You can enhance the appearance by adding designs based on the state of each card and column.
+## Optimizing Performance with React-DND
+
+Performance can become an issue when working with React-DND, especially with a large number of draggable items. Below are some tips to keep things running efficiently:
+
+**Avoid Unnecessary Re-Renders**
+
+Utilize `React.memo` or `useMemo` to avoid unnecessary re-renders. For instance, if your draggable items remain unchanged, memoizing them can save a lot of processing time.
+
+**Batch State Updates**
+
+When updating multiple items after a drop, batch those updates instead of triggering multiple state changes. This minimizes React’s render cycles.
+
+**Minimize the `collect` Function’s Scope**
+
+The `collect` function in `useDrag` and `useDrop` is powerful, but adding excessive logic can degrade performance. Only gather data that’s absolutely necessary.
+
+**Virtualize Large Lists**
+
+For hundreds of draggable items, consider using libraries like `react-window` or `react-virtualized`. These libraries render only the visible items, reducing React’s workload.
+
+By applying these strategies, you’ll achieve a drag-and-drop experience that is both fast and functional.
+
+## Error Handling and Debugging
+
+React-DND is a robust library, but you might encounter some common issues. Here’s how to resolve them:
+
+**Missing `DndProvider`**
+
+If you forget to wrap your app with `DndProvider`, nothing will work. Ensure your root component includes it:
+
+```jsx
+import { DndProvider } from "react-dnd";
+import { HTML5Backend } from "react-dnd-html5-backend";
+
+function App() {
+ return (
+
+
+
+ );
+}
+```
+
+**Type Mismatches Between useDrag and useDrop**
+
+The type property in useDrag must match the accept property in useDrop. Otherwise, the drop zone won’t recognize the dragged item:
+
+```tsx
+const [{ isDragging }, dragRef] = useDrag({ type: "item" });
+const [{ isOver }, dropRef] = useDrop({ accept: "item" });
+```
+
+**Monitor Data Not Updating**
+
+If collect isn’t providing accurate data, ensure you’re returning the correct values from the monitor:
+
+```tsx
+collect: (monitor) => ({ isDragging: monitor.isDragging() });
+```
+
+Debugging these small issues can save significant time. Always refer to the documentation and browser console for detailed error messages.
+
+**Mobile Device Support**
+
+React-DND’s default backend (HTML5Backend) works well on desktop browsers but struggles on mobile devices. Here’s how to enable drag-and-drop for touchscreens:
+
+**Use the Touch Backend**
+
+Install the react-dnd-touch-backend package designed for touch devices:
+
+```
+npm install react-dnd-touch-backend
+```
+
+**Set Up the Touch Backend**
+
+Replace HTML5Backend with TouchBackend in your app’s DndProvider:
+
+```tsx
+import { DndProvider } from "react-dnd";
+import { TouchBackend } from "react-dnd-touch-backend";
+
+function App() {
+ return (
+
+
+
+ );
+}
+```
+
+**Customize Touch Behavior**
+
+You can tweak the touch backend’s settings for better performance, such as adjusting the drag delay:
+
+```tsx
+const backendOptions = {
+ enableMouseEvents: true,
+ delay: 100,
+};
+
+
+
+ ;
+```
+
+With these adjustments, your drag-and-drop features will work seamlessly across both desktop and mobile devices.
+
## Conclusion
This article introduced Refine and React-DND, detailing the process of setting up a Refine project with predefined CRUD pages via the Superplate CLI and integrating React-DND. It also covered the creation of a dashboard page featuring a kanban board that utilizes the useDrag and useDrop hooks from React-DND for its drag-and-drop functionality.
diff --git a/documentation/blog/2022-12-15-mui-checkbox.md b/documentation/blog/2024-12-25-mui-checkbox.md
similarity index 82%
rename from documentation/blog/2022-12-15-mui-checkbox.md
rename to documentation/blog/2024-12-25-mui-checkbox.md
index c7f12043b17f..73afb06610b5 100644
--- a/documentation/blog/2022-12-15-mui-checkbox.md
+++ b/documentation/blog/2024-12-25-mui-checkbox.md
@@ -4,30 +4,40 @@ description: We'll discover the Material UI Checkbox component with examples
slug: material-ui-checkbox-component
authors: doro_onome
tags: [material-ui, react]
-image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-12-15-mui-checkbox/social.png
+image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-12-15-mui-checkbox/social-2.png
hide_table_of_contents: false
---
+**This article was last updated on December 25, 2024, to include advanced Material UI Checkbox customization techniques, improved form validation patterns, and accessibility best practices.**
+
## Introduction
-Material UI offers a wide range of component and utilities that empowers developers with the appropriate tools to create more responsive web designs and bolster the UX of their apps. A checkbox is a small box that, when selected by the user, indicates that a specific feature or option has been enabled. Material UI provides this valuable component on a platter and makes them customizable to apply to your project fittingly. This article will deeply traverse the Material UI Checkbox component, investigate its processes and highlight its syntax application. We will also explore a potential use case in a real-world application.
+### What is Material UI Checkbox?
+
+Material UI Checkbox is a form input component that allows users to select one or more options out of a given set of choices. It is part of the Material UI library, which provides an up-to-date, accessible, and customizable implementation of the checkbox for React applications.
+
+Key Features and Benefits
+
+- **Easy Integration**: Easy to implement with just a single import
+- **Accessibility**: ARIA support included; keyboard navigation
+- **Customization**: Rich styling with props and themes
+- **Form Support**: Seamless integrations with form libraries
+- **State Management**: controlled and uncontrolled component options
+- **Responsive**: Works on all sizes of devices - **TypeScript Support**: Full type definitions included
+
+Material UI offers a wide range of component and utilities that empowers developers with the appropriate tools to create more responsive web designs and bolster the UX of their apps. A checkbox is a small box that, when selected by the user, indicates that a specific feature or option has been enabled. Material UI provides this valuable component on a platter and makes them customizable to apply to your project fittingly.
+
+This article will deeply traverse the Material UI Checkbox component, investigate its processes and highlight its syntax application. We will also explore a potential use case in a real-world application.
Steps we'll cover:
- [What is Material UI?](#what-is-material-ui)
- [Getting started with Material UI Checkbox](#getting-started-with-material-ui-checkbox)
- [Customizing your Material UI Checkbox](#customizing-your-material-ui-checkbox)
- - [Adding Labels](#adding-labels)
- - [Controlling the Checkbox Size](#controlling-the-checkbox-size)
- - [Controlling the Checkbox Color](#controlling-the-checkbox-color)
- - [Label Placement](#label-placement)
- - [Checkbox Icons](#checkbox-icons)
- [Other handy features](#other-handy-features)
- - [FormGroup](#formgroup)
- - [Indeterminate](#indeterminate)
-- [When to use the Material UI Checkbox](#when-to-use-the-mui-checkbox)
- - [Checkboxes vs Radio buttons](#checkboxes-vs-radio-buttons)
- - [Checkboxes vs Switches](#checkboxes-vs-switches)
+- [Error Handling \& Validation](#error-handling--validation)
+- [Advanced Customization](#advanced-customization)
+- [When to use the Material UI Checkbox](#when-to-use-the-material-ui-checkbox)
- [Material UI Checkbox Accessibility](#material-ui-checkbox-accessibility)
## What is Material UI?
@@ -460,12 +470,108 @@ export default function IndeterminateCheckbox() {
-
-
+## Error Handling & Validation
+
+When working with checkboxes in forms, proper error handling is essential. Here's a simple example of form validation with Material UI Checkbox:
+
+```tsx
+import * as React from "react";
+import {
+ Checkbox,
+ FormControlLabel,
+ FormHelperText,
+ FormControl,
+} from "@mui/material";
+
+export default function ValidationExample() {
+ const [checked, setChecked] = React.useState(false);
+ const [error, setError] = React.useState(false);
+
+ const handleSubmit = (event) => {
+ event.preventDefault();
+ if (!checked) {
+ setError(true);
+ return;
+ }
+ setError(false);
+ // Handle form submission
+ };
+
+ return (
+
+ );
+}
+```
+
+Common validation scenarios include:
+
+- Required field validation
+- Minimum selection requirements
+- Group validation rules
+
+## Advanced Customization
+
+### Custom Styling
+
+You can create your own styled checkbox using the `styled` API:
+
+```tsx
+import { styled } from "@mui/material/styles";
+import Checkbox from "@mui/material/Checkbox";
+
+const CustomCheckbox = styled(Checkbox)`
+ &.MuiCheckbox-root {
+ color: #666;
+ }
+ &.Mui-checked {
+ color: #2196f3;
+ }
+`;
+
+export default function StyledExample() {
+ return ;
+}
+```
+
+### Custom Icons
+
+You can also use custom icons for your checkboxes:
+
+```tsx
+import FavoriteIcon from "@mui/icons-material/Favorite";
+import FavoriteBorderIcon from "@mui/icons-material/FavoriteBorder";
+
+export default function CustomIconExample() {
+ return (
+ }
+ checkedIcon={ }
+ sx={{ color: "pink" }}
+ />
+ );
+}
+```
+
+These customizations allow you to:
+
+- Match your application's design system
+- Create unique visual elements
+- Improve user experience with custom interactions
## When to use the Material UI Checkbox
diff --git a/documentation/blog/2023-01-04-mui-card.md b/documentation/blog/2024-12-26-mui-card.md
similarity index 91%
rename from documentation/blog/2023-01-04-mui-card.md
rename to documentation/blog/2024-12-26-mui-card.md
index 156e594051dc..b97478d7c055 100644
--- a/documentation/blog/2023-01-04-mui-card.md
+++ b/documentation/blog/2024-12-26-mui-card.md
@@ -4,36 +4,51 @@ description: We'll discover the Material UI Card component with examples
slug: material-ui-card
authors: doro_onome
tags: [material-ui, react]
-image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2023-01-04-mui-card/social.png
+image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2023-01-04-mui-card/social-2.png
hide_table_of_contents: false
---
## Introduction
+### Quick Summary: What is Material UI Card?
+
+Think of a Material UI Card as a digital container - like a paper card in real life, but for your website. It's a neat way to show related information in one place. You can put all sorts of things in it: text, pictures, buttons, and more.
+
+Here's what makes Material UI Cards so useful:
+
+- They keep information organized and tidy
+- You can easily add images and other media
+- They're interactive - users can click, expand, or interact with them
+- They look great on both desktop and mobile screens
+- You can style them however you want to match your website
+
+The best part? They're super easy to use, even if you're just starting with React!
+
Material UI cards are an important part of modern web design. They make it simple for users to access and interact with important information, whether text, images, or a combination of the two. Developers can use Material UI to easily create powerful and interactive cards that integrate seamlessly into their website design. This article will go over the various features, benefits, and applications of Material UI cards to give web developers a thorough understanding of how the component can help them create beautiful and engaging user experiences.
Steps we'll cover:
+- [Quick Summary: What is Material UI Card?](#quick-summary-what-is-material-ui-card)
- [What is Material UI?](#what-is-material-ui)
- [Getting started with Material UI Card](#getting-started-with-material-ui-card)
- [Other Material UI Card Variants](#other-material-ui-card-variants)
- - [Image Cards](#image-cards)
- - [Outlined Cards](#outlined-cards)
- [Material UI Card Component Classes](#material-ui-card-component-classes)
- [Material UI Card Interactions](#material-ui-card-interactions)
- [Building a simple Blog Layout with React and Material UI Cards](#building-a-simple-blog-layout-with-react-and-material-ui-cards)
+- [Frequently Asked Questions (FAQ)](#frequently-asked-questions-faq)
## What is Material UI?
Material UI is a React-based UI framework designed to aid in the creation of consistent user interfaces across web and mobile applications. It includes a large library of components and tools to help developers easily create modern user interfaces.
It provides a comprehensive library of components and tools to help developers create modern user interfaces with ease. Some of which include:
-Input components
-Surface components
-Data Display components
-Navigation components
-Feedback components
-Layout components
+
+- Input components
+- Surface components
+- Data Display components
+- Navigation components
+- Feedback components
+- Layout components
The Material UI Card is an example of the Material UI Surfaces.
@@ -545,12 +560,34 @@ Here’s the result:
-
-
+## Frequently Asked Questions (FAQ)
+
+### Can I customize the look of Material UI Cards?
+
+Absolutely! You can change pretty much everything about how a card looks. Colors, shadows, borders, spacing - it's all customizable using the `sx` prop or custom styles.
+
+### Do Material UI Cards work well on mobile devices?
+
+Yes! Cards are responsive by default and will adjust their size based on the screen. Just make sure to set appropriate width values (like maxWidth) to control how they display.
+
+### What can I put inside a Material UI Card?
+
+Almost anything! Common elements include:
+
+- Text content
+- Images and videos
+- Buttons and links
+- Icons
+- Action areas
+- Expandable sections
+
+### Are Material UI Cards accessible?
+
+Yes, they're built with accessibility in mind. They work well with screen readers and can be navigated using a keyboard. Just remember to add proper ARIA labels when needed!
+
+### How do I handle card interactions like clicking or expanding?
+
+It's pretty straightforward! You can add onClick handlers to the Card or CardActionArea components, and use the Collapse component for expandable content. Check out our examples above to see how it works.
## Conclusion
diff --git a/documentation/blog/2023-03-22-react-admin-templates.md b/documentation/blog/2024-12-27-react-admin-templates.md
similarity index 69%
rename from documentation/blog/2023-03-22-react-admin-templates.md
rename to documentation/blog/2024-12-27-react-admin-templates.md
index 47b030965828..6e2646e7b319 100644
--- a/documentation/blog/2023-03-22-react-admin-templates.md
+++ b/documentation/blog/2024-12-27-react-admin-templates.md
@@ -1,13 +1,15 @@
---
-title: Top React Admin Templates 2023
+title: Top React Admin Templates 2025
description: We have compiled a list of the top 5 React admin templates that are currently available on the market.
slug: react-admin-template
authors: chidume_nnamdi
tags: [comparison]
-image: https://refine.ams3.cdn.digitaloceanspaces.com/blog%2F2023-03-22-react-admin-templates%2Fsocial.png
+image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2023-03-22-react-admin-templates/social-2.png
hide_table_of_contents: false
---
+**This article was last updated on December 27, 2024, to include practical strategies for choosing React admin templates, such as avoiding overly complex templates, ensuring scalability, and verifying licenses. Simplified explanations and real-world examples have been added for improved clarity and usability.**
+
## Introduction
Templates are blueprints or models or guides used to make something. We can have a house template, that is used as a sample to build a house. Also in the world of software development, we have website design templates that present ideas on how to create a specific website for specific industries.
@@ -18,7 +20,7 @@ As React continues to gain popularity in web development, it is becoming increas
## 1. Refine CRM admin template
-[Refine CRM admin](https://example.crm.refine.dev/) is a open source React admin template powered by [Refine](https://github.com/refinedev/refine).
+[Refine CRM admin](https://example.crm.refine.dev/) is an enterprise-grade React admin template powered by [Refine](https://github.com/refinedev/refine).
@@ -124,6 +126,118 @@ Another key feature of the Wieldy template is its real-time chat integration. It
Finally, the Wieldy react admin template is highly customizable. It comes with a range of theme options and customization tools, allowing businesses to tailor the design to their specific needs. It also has a range of customization options for the pre-built components, making it easy to create a unique and user-friendly admin interface that meets the specific needs of the business.
+## Top 10 Mistakes to Avoid When Choosing Admin Templates
+
+1. Picking looks over features.
+2. Choosing a template that doesn't match your tech stack.
+3. Choosing too complicated templates.
+4. Neglecting scalability.
+5. Skipping documentation review.
+6. Forgetting to test responsiveness.
+7. Overlooking performance.
+8. Using templates that have unclear licenses.
+9. Blind reliance on free templates without scrutiny. 10. Ignoring accessibility requirements.
+
+## Common Mistakes While Choosing an Admin Template (And How I Avoid Them)
+
+During all these years, I have tried lots of admin templates. Sometimes, they worked just fine, but other times I ran into big problems because I didn't think things through.
+
+Let me share with you some of the mistakes I've made and seen others make, and how you can avoid them.
+
+### Picking Looks Over Features
+
+**What I Did Wrong:**
+I used to select templates based on how good they look. Later on, I felt some of them lacked charts or good form handling that I needed.
+
+**What I Do Now:**
+First, I make sure that the template will have all the tools that I need for my project. Although the design is important, features like authentication, dashboards, and responsive layouts concern me more.
+
+### Not Matching It to My Tech Stack
+
+**What I Did Wrong:**
+
+It once happened that I accidentally chose a Vue template for a React project. Suffice it to say that didn't go well, and I had to build much of it from scratch.
+
+**What I Do Now:**
+
+I will only use templates that are made specifically for the framework I am working in. For instance, if I were working in React, then I would find templates using either Material UI or Tailwind CSS.
+
+### Choosing Over-Complicated Templates
+
+**What I Did Wrong:**
+I made a very bad choice with a template, which had too many features for what I needed, such as multi-language support and drag-and-drop tools, that made everything harder to customize.
+
+**What I Do Now:**
+Me, I keep it simple: I don't need all advanced features; if so, I use a basic template. Easier to work with, faster to set up.
+
+### Forgetting About Scalability
+
+**What I Did Wrong:**
+
+I once chose a template, which was fine for small projects, but became a nightmare when my app grew. It didn't handle large amounts of data well.
+
+**What I Do Now:**
+
+I check whether the template is well-structured. Are the components reusable? Can I scale it up if the project grows? Templates with clear folder structures are way easier to maintain.
+
+### Ignoring Documentation
+
+**What I Did Wrong:**
+
+Once, I selected a free template with zero documentation. I had to spend hours trying to figure out how things worked.
+
+**What I Do Now:**
+
+I always check the documentation first. A well-documented template saves a lot of time. If it is a paid template, I make sure it comes with support.
+
+### Not Testing on Different Devices
+
+**What I Did Wrong:**
+
+I once completed an administrative panel and realized it looked terrible on a mobile device. It just wasn't responsive at all.
+
+**What I Do Now:**
+
+Before I start building, I am testing the demo on both mobile and desktop; a good template should look great everywhere.
+
+### Forgetting About Performance
+
+**What I Did Wrong:**
+
+I used a template with so many animations and libraries not really needed. It made my app really slow.
+
+**What I Do Now:**
+
+I run a quick performance test using Lighthouse on the demo. Looking for templates featuring lazy loading with minimal dependencies.
+
+### Not Verifying the License
+
+**What I Did Wrong:**
+
+Once, I did not know that the license for using the template in one of my client projects prohibited commercial use. I had to redo everything.
+
+**What I Do Now:**
+
+I always check out the license, whether I use a template or not. In case there's a commercial project in line, then I really see to it that this covers under its license.
+
+### Free Templates Not Vetted
+
+**What I Did Wrong:**
+I used a free template without reviewing the code. It was badly written and full of bugs.
+
+**What I Do Now:**
+If it's free, I check out the GitHub repo for how often it is updated and how many issues it has. Sometimes, it's worth paying for a high-quality template.
+
+### Ignoring Accessibility
+
+**What I Did Wrong:**
+
+Early on, I never thought about accessibility. Then, I realized that some users couldn't navigate my admin panel properly.
+
+**What I Do Now:**
+
+I look for templates with keyboard navigation, screen reader, and high-contrast mode support. Accessibility is more important than you think.
+
## Conclusion
We have gone through all the most popular React admin templates. We have seen their features and uniqueness. Also, we have learned what each template is capable of doing and on what occasions each of them is best suitable.
diff --git a/documentation/blog/2023-05-09-material-ui-modal.md b/documentation/blog/2024-12-30-material-ui-modal.md
similarity index 80%
rename from documentation/blog/2023-05-09-material-ui-modal.md
rename to documentation/blog/2024-12-30-material-ui-modal.md
index e4440a7fcff1..31f00e52d28c 100644
--- a/documentation/blog/2023-05-09-material-ui-modal.md
+++ b/documentation/blog/2024-12-30-material-ui-modal.md
@@ -4,10 +4,12 @@ description: We'll learn how to use Material UI Modal to create a popup window t
slug: material-ui-modal
authors: doro_onome
tags: [material-ui, react]
-image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2023-05-09-material-ui-modal/social.png
+image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2023-05-09-material-ui-modal/social-2.png
hide_table_of_contents: false
---
+**This article was last updated on December 30, 2024, to include common mistakes to avoid when working with Material UI Modals, such as accessibility or performance optimizations. A Frequently Asked Questions section has also been added to address common concerns.**
+
## Introduction
Material UI is a popular front-end library for React that provides a comprehensive set of tools for creating user interfaces. One of the most valuable components of Material UI is the Modal, which allows developers to create a popup window that can display important information or facilitate user input. This tutorial will explain how to use the Material UI Modal and customize it to your needs.
@@ -389,14 +391,129 @@ Here’s the result:
-
+## Common Mistakes and How to Avoid Them
-
-
+Here are a few lessons I’ve learned the hard way while working with Material UI Modals. These are some common mistakes I’ve either made myself or seen others make, along with how I’ve managed to avoid them. Hopefully, this saves you some trouble too!
+
+### Forgetting to Manage the Open State Properly
+
+Initially, I forgot to control the modal’s open state correctly. Sometimes, the modal would stay open forever—or even worse—open and close unpredictably.
+
+**How I Avoid It Now:**
+
+I always use React state to manage the modal’s state, like this:
+
+```tsx
+const [open, setOpen] = React.useState(false);
+
+ setOpen(false)} />;
+```
+
+### Not Testing Responsiveness
+
+I built a modal that looked amazing on desktop but completely broke on mobile. Text overflowed, buttons were missing—it was chaos.
+
+**How I Avoid It Now:**
+
+I test the modal on various screen sizes, especially mobile. Although Material UI Modals are responsive by default, I sometimes tweak the styles:
+
+```tsx
+const style = {
+ width: "90%",
+ maxWidth: "400px", // Keeps it compact on larger screens
+};
+```
+
+### Overloading the Modal with Too Much Content
+
+I once built a five-field form, a sidebar, and additional instructions into a single modal. It became overwhelming and hard to use.
+
+**How I Avoid It Now:**
+
+I keep the modal focused on one task. If more space is required, I use a drawer or redirect to another page.
+
+### Ignoring Accessibility
+
+I forgot to add aria attributes, making the modal inaccessible to screen readers. It was a significant oversight.
+
+**How I Avoid It Now:**
+
+Put proper aria attributes are included, like this:
+
+```tsx
+
+Modal Header
+This is the content.
+```
+
+### Not Optimizing Performance
+
+I created a modal with heavy animations and a large component tree, which caused noticeable lag whenever the modal opened.
+
+**How I Avoid It Now:**
+
+I use the `keepMounted` prop to avoid unnecessary re-renders and optimize the child components inside the modal:
+
+```tsx
+
+```
+
+### Disabling the Backdrop Click Without Thinking
+
+I disabled the backdrop click to prevent accidental closures. However, users were frustrated when they couldn’t easily close the modal.
+
+**How I Avoid It Now:**
+
+I leave the backdrop click enabled unless there’s a compelling reason to disable it. If I do disable it, I make sure to include a clear “Close” button.
+
+## Frequently Asked Questions
+
+**Q: How do I open and close a Material UI Modal?**
+A: You can use React state to control the open property.
+
+```tsx
+const [open, setOpen] = React.useState(false);
+
+ setOpen(false)}>
+ Modal Content Here
+ ;
+```
+
+**Q: Is Material UI Modal accessible?**
+A: Yes, Material UI is designed with accessibility in mind. You can use aria-labelledby and aria-describedby attributes to ensure it works well with screen readers.
+
+**Q: How do I make the Modal responsive?**
+A: You can define responsive styles to adapt the modal to different screen sizes.
+
+```tsx
+const style = {
+ width: "90%",
+ maxWidth: "400px",
+};
+```
+
+This way, the modal looks great on both mobile and desktop.
+
+**Q: Can I add animations to the Modal?**
+A: Yes, Material UI supports transitions. Wrap the content with the Fade component for animations:
+
+```tsx
+
+
+ Animated Modal Content
+
+
+```
+
+**Q: How can I close the Modal by clicking outside it?**
+A: That’s the default behavior. Clicking the backdrop (outside the modal) will close it. No extra code is needed unless you want to disable this feature:
+
+```tsx
+
+```
## Conclusion
diff --git a/documentation/docs/data/packages/strapi-v4/index.md b/documentation/docs/data/packages/strapi-v4/index.md
index fad5c22e349b..0edafc913770 100644
--- a/documentation/docs/data/packages/strapi-v4/index.md
+++ b/documentation/docs/data/packages/strapi-v4/index.md
@@ -409,7 +409,7 @@ const App: React.FC = () => {
render( );
```
-##### Relations Population for `/me` request
+#### Relations Population for `/me` request
If you need to the population for the `/me` request you can use it like this in your `authProvider`.
diff --git a/documentation/docs/guides-concepts/forms/index.md b/documentation/docs/guides-concepts/forms/index.md
index 001d10354bb6..41e28237e133 100644
--- a/documentation/docs/guides-concepts/forms/index.md
+++ b/documentation/docs/guides-concepts/forms/index.md
@@ -332,7 +332,7 @@ useForm({
});
```
-##### **Usage of ` `**
+#### **Usage of ` `**
diff --git a/documentation/docs/packages/list-of-packages/index.md b/documentation/docs/packages/list-of-packages/index.md
index 2078bb10c5cd..0bc9c8dd0b04 100644
--- a/documentation/docs/packages/list-of-packages/index.md
+++ b/documentation/docs/packages/list-of-packages/index.md
@@ -79,3 +79,4 @@ To learn more about Live Providers, check out [Realtime](/docs/guides-concepts/r
- [`@refine-auth/kinde-react`](https://github.com/hirenf14/refine-auth-kinde-react) - Support for [Kinde](https://kinde.com) authentication.
- [`refine-pocketbase`](https://github.com/kruschid/refine-pocketbase) - Connector for backends created with [PocketBase](https://pocketbase.io/). Also has auth provider and live provider supports.
- [`refine-postgrest-ts`](https://github.com/ffimnsr/refine-postgrest-ts) - Connector for [PostgREST](https://postgrest.org) backends.
+- [`refine-chakra-ui-v3-ts`](https://github.com/ffimnsr/refine-chakra-ui-v3-ts) - Integration for [Chakra UI v3](https://www.chakra-ui.com).
diff --git a/documentation/docs/routing/integrations/react-router/migration-guide-v6-to-v7.md b/documentation/docs/routing/integrations/react-router/migration-guide-v6-to-v7.md
index 62deabc7db39..cd1c820b2569 100644
--- a/documentation/docs/routing/integrations/react-router/migration-guide-v6-to-v7.md
+++ b/documentation/docs/routing/integrations/react-router/migration-guide-v6-to-v7.md
@@ -5,7 +5,7 @@ sidebar_label: v6 to v7
In this guide, we will cover the breaking changes of `@refinedev/react-router-v6` and how to migrate your project to `@refinedev/react-router` with `react-router` v7.
-> 🚨 Refine doesn't introduce any breaking changes besides the package name changes. However, we recommend you to read the [React Router v7 migration guide](https://reactrouter.com/en/main/upgrading/v6) for more detailed information about React Router v7 changes.
+> 🚨 Refine doesn't introduce any breaking changes besides the package name changes. However, we recommend you to read the [React Router v7 migration guide](https://reactrouter.com/upgrading/v6) for more detailed information about React Router v7 changes.
## Package Changes
@@ -28,7 +28,7 @@ npm install @refinedev/react-router react-router
```diff
- "@refinedev/react-router-v6": "^4.6.0"
-+ "@refinedev/react-router": "^5.0.0"
++ "@refinedev/react-router": "^1.0.1"
- "react-router-dom": "^6.8.1"
- "react-router": "^6.8.1"
@@ -64,5 +64,5 @@ npx @refinedev/codemod@latest refine-react-router-v6-to-refine-react-router
For `react-router-dom` to `react-router`:
```bash
-npx @refinedev/codemod@latest react-router-dom-to-react-router"
+npx @refinedev/codemod@latest react-router-dom-to-react-router
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/basic-views/create/index.md b/documentation/docs/ui-integrations/ant-design/components/basic-views/create/index.md
index ea1760cf28b4..df87f5f8f870 100644
--- a/documentation/docs/ui-integrations/ant-design/components/basic-views/create/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/basic-views/create/index.md
@@ -8,6 +8,8 @@ swizzle: true
We will show what `` does using properties with examples.
```tsx live hideCode url=http://localhost:3000/posts/create
+setInitialRoutes(["/posts/create"]);
+
interface ICategory {
id: number;
title: string;
@@ -90,21 +92,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -121,7 +141,7 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
`title` allows you to add a title inside the `` component. If you don't pass the title props, it uses the "Create" prefix and the singular resource name by default. For example, for the `/posts/create` resource, it would be "Create post".
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { Form, Input, Select, useForm, useSelect, CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -137,21 +157,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -160,7 +198,7 @@ render(
The `` component has a save button that submits the form by default. If you want to customize this button you can use the `saveButtonProps` property:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { Form, Input, Select, useForm, useSelect, CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -176,21 +214,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -200,18 +256,16 @@ render(
The `` component reads the `resource` information from the route by default. If you want to use a custom resource for the `` component, you can use the `resource` prop:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/custom
-// handle initial routes in new way
-setInitialRoutes(["/custom"]);
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
+setInitialRoutes(["/posts/create"]);
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
import { Refine } from "@refinedev/core";
+import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Create } from "@refinedev/antd";
-const MyComponent: React.FC = () => {
+const CustomPage: React.FC = () => {
return (
/* highlight-next-line */
@@ -221,27 +275,41 @@ const MyComponent: React.FC = () => {
};
// visible-block-end
-const App: React.FC = () => {
- return (
+render(
+
,
- path: "/custom",
- },
- ],
- // highlight-end
- }}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
-
-render( );
+ resources={[
+ {
+ name: "posts",
+ list: "/posts",
+ create: "/posts/create",
+ },
+ ]}
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
+);
```
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
@@ -253,7 +321,7 @@ If you have multiple resources with the same name, you can pass the `identifier`
To customize the back button or to disable it, you can use the `goBack` property:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -271,21 +339,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -316,7 +402,7 @@ const PostCreate: React.FC = () => {
To toggle the loading state of the ` ` component, you can use the `isLoading` property:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -332,21 +418,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -355,7 +459,7 @@ render(
To customize or disable the breadcrumb, you can use the `breadcrumb` property. By default the `Breadcrumb` component from the `@refinedev/antd` package is used for breadcrumbs.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create, Breadcrumb } from "@refinedev/antd";
@@ -383,21 +487,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -408,7 +530,7 @@ render(
You can use the `wrapperProps` property if you want to customize the wrapper of the ` ` component. The `@refinedev/antd` wrapper elements are simply `
`s and `wrapperProps` and can get every attribute that `
` can get.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -432,21 +554,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -455,7 +595,7 @@ render(
You can use the `headerProps` property to customize the header of the ` ` component:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -480,21 +620,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -505,7 +663,7 @@ render(
You can use the `contentProps` property to customize the content of the ` ` component:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -529,21 +687,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -554,7 +730,7 @@ render(
You can customize the buttons at the header by using the `headerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -579,21 +755,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -602,7 +796,7 @@ render(
You can use the `headerButtonProps` property to customize the wrapper element of the buttons at the header:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -614,6 +808,10 @@ const PostCreate: React.FC = () => {
// highlight-start
headerButtonProps={{
style: {
+ // hide-start
+ float: "right",
+ marginRight: 24,
+ // hide-end
backgroundColor: "cornflowerblue",
padding: "16px",
},
@@ -628,21 +826,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -655,7 +871,7 @@ By default, the ` ` component has a [``][save-button] at the
You can customize the buttons at the footer by using the `footerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons, saveButtonProps }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -680,27 +896,47 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `saveButtonProps` to utilize the default values of the [``][save-button] component.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
+setInitialRoutes(["/posts/create"]);
+
// visible-block-start
import { Create, SaveButton } from "@refinedev/antd";
import { Button } from "antd";
@@ -727,25 +963,42 @@ const PostCreate: React.FC = () => {
);
};
-
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -754,7 +1007,7 @@ render(
You can customize the wrapper element of the buttons at the footer by using the `footerButtonProps` property.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
-const { CreateButton } = RefineAntd;
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/antd";
@@ -783,21 +1036,39 @@ const PostCreate: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- create: PostCreate,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -810,3 +1081,5 @@ render(
[save-button]: /docs/ui-integrations/ant-design/components/buttons/save-button
+
+
diff --git a/documentation/docs/ui-integrations/ant-design/components/basic-views/edit/index.md b/documentation/docs/ui-integrations/ant-design/components/basic-views/edit/index.md
index 4c2cd1eec84c..f91de2e237f8 100644
--- a/documentation/docs/ui-integrations/ant-design/components/basic-views/edit/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/basic-views/edit/index.md
@@ -7,114 +7,56 @@ swizzle: true
We will show what `` does using properties with examples.
-```tsx live hideCode url=http://localhost:3000/posts/edit/123
-const { EditButton } = RefineAntd;
-
-interface ICategory {
- id: number;
- title: string;
-}
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/custom/123
+setInitialRoutes(["/custom/123"]);
// visible-block-start
+import { Edit } from "@refinedev/antd";
-interface IPost {
- id: number;
- title: string;
- content: string;
- status: "published" | "draft" | "rejected";
- category: { id: number };
-}
-
-import { Edit, useForm, useSelect } from "@refinedev/antd";
-import { Form, Input, Select } from "antd";
-
-const PostEdit: React.FC = () => {
- const { formProps, saveButtonProps, query } = useForm({
- warnWhenUnsavedChanges: true,
- });
-
- const postData = query?.data?.data;
- const { selectProps: categorySelectProps } = useSelect({
- resource: "categories",
- defaultValue: postData?.category.id,
- });
-
+const CustomPage: React.FC = () => {
return (
-
-
-
-
-
-
-
-
-
-
-
+ /* highlight-next-line */
+
+ Rest of your page here
);
};
// visible-block-end
render(
- (
-
-
This page is empty.
-
Edit Item 123
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
+:::tip
+The example above shows how to use the `resource` prop when the component is rendered on a custom page with a different route than the resource route.
+:::
+
+If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
+
+> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
+
:::simple Good to know
You can swizzle this component to customize it with the [**Refine CLI**](/docs/packages/list-of-packages)
@@ -127,20 +69,8 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
`title` allows you to add a title inside the `` component. If you don't pass title props, it uses the "Edit" prefix and the singular resource name by default. For example, for the "posts" resource, it will be "Edit post".
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
-const { default: simpleRest } = RefineSimpleRest;
-
-const dataProvider = simpleRest("https://api.fake-rest.refine.dev");
-
-const customDataProvider = {
- ...dataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- return {
- data: {},
- };
- },
-};
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
// visible-block-start
import { Edit } from "@refinedev/antd";
@@ -156,21 +86,41 @@ const PostEdit: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Edit Item 2
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -178,8 +128,8 @@ render(
The `` component has a save button that submits the form by default. If you want to customize this button you can use the `saveButtonProps` property:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
// visible-block-start
import { Edit } from "@refinedev/antd";
@@ -195,21 +145,41 @@ const PostEdit: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -222,60 +192,25 @@ render(
If you want to customize this button you can use the `deleteButtonProps` property like the code below.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
-const { EditButton } = RefineAntd;
-const { default: simpleRest } = RefineSimpleRest;
-
-const dataProvider = simpleRest("https://api.fake-rest.refine.dev");
-
-const customDataProvider = {
- ...dataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- return {
- data: {},
- };
- },
-};
+setInitialRoutes(["/posts/edit/123"]);
-const authProvider = {
- login: () => {
- return {
- success: true,
- redirectTo: "/",
- };
- },
- register: () => {
- return {
- success: true,
- };
- },
- forgotPassword: () => {
- return {
- success: true,
- };
- },
- updatePassword: () => {
- return {
- success: true,
- };
- },
- logout: () => {
- return {
- success: true,
- redirectTo: "/",
- };
- },
- check: () => ({
- authenticated: true,
- }),
- onError: () => ({}),
- getPermissions: () => null,
- getIdentity: () => null,
-};
+interface ICategory {
+ id: number;
+ title: string;
+}
+
+interface IPost {
+ id: number;
+ title: string;
+ content: string;
+ status: "published" | "draft" | "rejected";
+ category: { id: number };
+}
-// visible-block-start
import { Edit } from "@refinedev/antd";
import { usePermissions } from "@refinedev/core";
+// visible-block-start
const PostEdit: React.FC = () => {
const { data: permissionsData } = usePermissions();
return (
@@ -293,23 +228,41 @@ const PostEdit: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Edit Item 123
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -321,12 +274,9 @@ render(
The `` component reads the `resource` information from the route by default. If you want to use a custom resource for the `` component, you can use the `resource` prop:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/custom/2
-setInitialRoutes(["/custom/2"]);
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/custom/123
+setInitialRoutes(["/custom/123"]);
-import { Refine } from "@refinedev/core";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/antd";
@@ -340,29 +290,36 @@ const CustomPage: React.FC = () => {
};
// visible-block-end
-const App: React.FC = () => {
- return (
+render(
+
,
- path: "/custom/:id",
- },
- ],
- // highlight-end
- }}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
-
-render( );
+ resources={[
+ {
+ name: "posts",
+ list: "/posts",
+ edit: "/posts/edit/:id",
+ },
+ ]}
+ >
+
+
+
+
+ }
+ />
+
+
+ ,
+);
```
+:::tip
+The example above shows how to use the `resource` prop when the component is rendered on a custom page with a different route than the resource route.
+:::
+
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
@@ -371,13 +328,13 @@ If you have multiple resources with the same name, you can pass the `identifier`
The `` component reads the `id` information from the route by default. When it cannot be read from the URL, which happens when it's used on a custom page, modal or drawer, `recordItemId` is used.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit, useModalForm } from "@refinedev/antd";
import { Modal, Button } from "antd";
+// visible-block-start
const PostEdit: React.FC = () => {
const { modalProps, id, show } = useModalForm({
action: "edit",
@@ -398,21 +355,41 @@ const PostEdit: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Edit Item 2
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -422,116 +399,57 @@ The `` component needs the `id` information for the `` to w
Determines which mode mutation will have while executing `` .
-```tsx live hideCode url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-interface ICategory {
- id: number;
- title: string;
-}
+import { Edit } from "@refinedev/antd";
// visible-block-start
-
-interface IPost {
- id: number;
- title: string;
- content: string;
- status: "published" | "draft" | "rejected";
- category: { id: number };
-}
-
-import { Edit, useForm, useSelect } from "@refinedev/antd";
-import { Form, Input, Select } from "antd";
-
const PostEdit: React.FC = () => {
- const { formProps, saveButtonProps, query } = useForm({
- warnWhenUnsavedChanges: true,
- });
-
- const postData = query?.data?.data;
- const { selectProps: categorySelectProps } = useSelect({
- resource: "categories",
- defaultValue: postData?.category.id,
- });
-
return (
-
-
-
-
-
-
-
-
-
-
-
+
+ Rest of your page here
);
};
// visible-block-end
render(
- (
-
-
This page is empty.
-
Edit Item 2
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -574,12 +492,12 @@ export const App: React.FC = () => {
To customize the back button or to disable it, you can use the `goBack` property:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
-const { EditButton } = RefineAntd;
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
import { Button } from "antd";
+// visible-block-start
const PostEdit: React.FC = () => {
const BackButton = () => ← ;
return (
@@ -592,39 +510,56 @@ const PostEdit: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Edit Item 123
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
If your route has no `:action` parameter or your action is `list`, the back button will not be shown even if you pass a `goBack` property. You can override this behavior by using the `headerProps` property:
```tsx
-/* highlight-next-line */
import { useBack } from "@refinedev/core";
import { Edit } from "@refinedev/antd";
import { Button } from "antd";
const PostEdit: React.FC = () => {
- /* highlight-next-line */
const back = useBack();
const BackButton = () => ← ;
return (
- /* highlight-next-line */
} headerProps={{ onBack: back }}>
Rest of your page here
@@ -636,12 +571,12 @@ const PostEdit: React.FC = () => {
To toggle the loading state of the ` ` component, you can use the `isLoading` property:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
/* highlight-next-line */
@@ -653,21 +588,41 @@ const PostEdit: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -675,12 +630,12 @@ render(
To customize or disable the breadcrumb, you can use the `breadcrumb` property. By default the `Breadcrumb` component from the `@refinedev/antd` package is used for breadcrumbs.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit, Breadcrumb } from "@refinedev/antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -728,12 +703,12 @@ render(
You can use the `wrapperProps` property if you want to customize the wrapper of the ` ` component. The `@refinedev/antd` wrapper elements are simply `
`s and `wrapperProps` and can get every attribute that `
` can get.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -775,12 +770,12 @@ render(
You can use the `headerProps` property to customize the header of the ` ` component:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -825,12 +840,12 @@ render(
You can use the `contentProps` property to customize the content of the ` ` component:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -878,13 +913,13 @@ You can customize the buttons at the header by using the `headerButtons` propert
If the "list" resource is not defined, the [``][list-button] will not render and `listButtonProps` will be `undefined`.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
import { Button } from "antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `refreshButtonProps` and `listButtonProps` to utilize the default values of the ``[list-button] and ``[refresh-button] components.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit, ListButton, RefreshButton } from "@refinedev/antd";
import { Button } from "antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -975,13 +1050,13 @@ render(
You can use the `headerButtonProps` property to customize the wrapper element of the buttons at the header:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
import { Button } from "antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
-> For more information, refer to the [`Space` documentation →](https://ant.design/components/space/)
-
### footerButtons
By default, the ` ` component has a [``][save-button] and a [``][delete-button] at the footer.
@@ -1030,13 +1123,13 @@ You can customize the buttons at the footer by using the `footerButtons` propert
If [`canDelete`](#candelete-and-deletebuttonprops) is `false`, the [``][delete-button] will not render and `deleteButtonProps` will be `undefined`.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
import { Button } from "antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `saveButtonProps` and `deleteButtonProps` to utilize the default values of the [``][save-button] and [``][delete-button] components.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit, SaveButton, DeleteButton } from "@refinedev/antd";
-import { Button } from "antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
(
<>
- Custom Button
{deleteButtonProps && (
@@ -1105,21 +1216,41 @@ const PostEdit: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -1127,22 +1258,20 @@ render(
You can customize the wrapper element of the buttons at the footer by using the `footerButtonProps` property.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { EditButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-// visible-block-start
import { Edit } from "@refinedev/antd";
+// visible-block-start
const PostEdit: React.FC = () => {
return (
{
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
-> For more information, refer to the [`Space` documentation →](https://ant.design/components/space/)
-
### autoSaveProps
You can use the auto save feature of the ` ` component by using the `autoSaveProps` property.
```tsx live url=http://localhost:3000/posts/edit/123
-const { EditButton } = RefineAntd;
+setInitialRoutes(["/posts/edit/123"]);
interface ICategory {
id: number;
@@ -1201,82 +1348,50 @@ import { Form, Input, Select } from "antd";
// visible-block-start
const PostEdit: React.FC = () => {
- const {
- formProps,
- saveButtonProps,
- query,
- // highlight-next-line
- autoSaveProps,
- } = useForm({
- warnWhenUnsavedChanges: true,
- // highlight-start
- autoSave: {
- enabled: true,
- },
- // highlight-end
- });
-
- const postData = query?.data?.data;
- const { selectProps: categorySelectProps } = useSelect({
- resource: "categories",
- defaultValue: postData?.category.id,
- });
+ const { current, gotoStep, stepsProps, formProps, saveButtonProps, query } =
+ useStepsForm({
+ stepsProps: {
+ items: [
+ {
+ title: "First Step",
+ },
+ {
+ title: "Second Step",
+ },
+ ],
+ },
+ });
return (
-
+
+
-
-
-
-
-
-
-
+
+
+ )}
+ {current === 1 && (
+
-
+ >
+
+
+ )}
);
@@ -1284,43 +1399,95 @@ const PostEdit: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Edit Item 123
-
- ),
- edit: PostEdit,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
+:::tip
+The `query` object from the `useForm` hook contains the query result from the data provider. You can use it to access the data returned from the API.
+
+```tsx
+const { query } = useForm();
+const record = query?.data?.data;
+```
+
+The `data.data` structure shown above is the default for the `@refinedev/simple-rest` data provider. This structure may be different for other data providers.
+:::
+
## API Reference
### Properties
-`](https://ant.design/components/breadcrumb/)"
-goBack-default="` `"
-goBack-type="`ReactNode`"
-/>
-
-> `*`: These properties have default values in `RefineContext` and can also be set on the **<[Refine](/docs/core/refine-component)>** component.
+
+
+:::tip External Props
+It also accepts all props of Ant Design [Form](https://ant.design/components/form/#API).
+:::
+
+### Type Parameters
+
+| Property | Extends | Default | Description |
+| ------------ | ------- | ------- | -------------------------------------------------------------- |
+| TQueryFnData | unknown | unknown | Result data returned by the query function. Extends unknown |
+| TError | unknown | unknown | Custom error object that extends unknown |
+| TVariables | object | object | Values for params. default `object` |
+| TData | unknown | unknown | Result data returned by the `select` function. Extends unknown |
+| TResponse | unknown | unknown | Result data returned by the mutation function. Extends unknown |
+
+### Return values
+
+| Property | Description |
+| ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
+| `queryResult` | If the `queryResult` prop is given, it will be returned. Otherwise, it will return `undefined`. |
+| `mutationResult` | Mutation result from `react-query`. [Check here →](https://tanstack.com/query/latest/docs/react/reference/useMutation) |
+| `saveButtonProps` | Props for a save button. |
+| `cancelButtonProps` | Props for a cancel button. |
+| `deleteButtonProps` | Props for a delete button. |
+| `formProps` | Props for the `
+ ,
+);
```
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
@@ -177,9 +213,10 @@ If you have multiple resources with the same name, you can pass the `identifier`
### canCreate and createButtonProps
-`canCreate` allows us to add the create button inside the `` component. If you want to customize this button you can use `createButtonProps` property like the code below:
+`canCreate` allows us to add the create button inside the `
` component. If you want to customize this button you can use `createButtonProps` property like the code below:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
const { Create } = RefineAntd;
const { default: simpleRest } = RefineSimpleRest;
@@ -253,20 +290,36 @@ const PostList: React.FC = () => {
// visible-block-end
render(
- {
- return Create Page ;
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ Create Page}
+ />
+
+
+
+ ,
);
```
@@ -281,6 +334,7 @@ To customize or disable the breadcrumb, you can use the `breadcrumb` property. B
[Refer to the `Breadcrumb` documentation for detailed usage. →](/docs/ui-integrations/ant-design/components/breadcrumb)
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
// visible-block-start
import { List } from "@refinedev/antd";
@@ -311,15 +365,29 @@ const PostList: React.FC = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -328,6 +396,8 @@ render(
You can use the `wrapperProps` property if you want to customize the wrapper of the `
` component. The `@refinedev/antd` wrapper elements are simply `
`s and `wrapperProps` and can get every attribute that `
` can get.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { List } from "@refinedev/antd";
@@ -350,15 +420,29 @@ const PostList: React.FC = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -367,6 +451,8 @@ render(
You can use the `headerProps` property to customize the header of the `
` component:
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { List } from "@refinedev/antd";
@@ -390,15 +476,29 @@ const PostList: React.FC = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -409,6 +509,8 @@ render(
You can use the `contentProps` property to customize the content of the ` ` component. The `
` components content is wrapped with a `
` and `contentProps` can get every attribute that `
` can get.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { List } from "@refinedev/antd";
@@ -431,15 +533,29 @@ const PostList: React.FC = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -452,6 +568,8 @@ You can customize the buttons at the header by using the `headerButtons` propert
If the "create" resource is not defined or if [`canCreate`](#cancreate-and-createbuttonprops) is false, the [``][create-button] will not render and `createButtonProps`will be `undefined`.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { List } from "@refinedev/antd";
import { Button } from "antd";
@@ -475,21 +593,37 @@ const PostList: React.FC = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `createButtonProps` to utilize the default values of the [``][create-button] component.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { List, CreateButton } from "@refinedev/antd";
import { Button } from "antd";
@@ -515,15 +649,29 @@ const PostList: React.FC = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -532,6 +680,8 @@ render(
You can customize the wrapper element of the buttons at the header by using the `headerButtonProps` property.
```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { List } from "@refinedev/antd";
import { Button } from "antd";
@@ -556,15 +706,29 @@ const PostList: React.FC = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/basic-views/show/index.md b/documentation/docs/ui-integrations/ant-design/components/basic-views/show/index.md
index 3a114bea8eb6..8f905ad164a5 100644
--- a/documentation/docs/ui-integrations/ant-design/components/basic-views/show/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/basic-views/show/index.md
@@ -7,7 +7,22 @@ swizzle: true
We will show what `` does using properties with examples.
-```tsx live hideCode url=http://localhost:3000/posts/show/2
+```tsx live hideCode url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
+
+interface ICategory {
+ id: number;
+ title: string;
+}
+
+interface IPost {
+ id: number;
+ title: string;
+ content: string;
+ status: "published" | "draft" | "rejected";
+ category: { id: number };
+}
+
// visible-block-start
import { Show, MarkdownField } from "@refinedev/antd";
import { Typography } from "antd";
@@ -48,21 +63,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Edit Item 2
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -78,20 +113,8 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
`title` allows you to add a title inside the `` component. If you don't pass title props, it uses the "Show" prefix and the singular resource name by default. For example, for the "posts" resource, it will be "Show post".
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
-const { default: simpleRest } = RefineSimpleRest;
-
-const dataProvider = simpleRest("https://api.fake-rest.refine.dev");
-
-const customDataProvider = {
- ...dataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- return {
- data: {},
- };
- },
-};
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -107,21 +130,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Show Item 2
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -129,12 +172,12 @@ render(
The `` component reads the `resource` information from the route by default. If you want to use a custom resource for the `` component, you can use the `resource` prop:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/custom/2
-setInitialRoutes(["/custom/2"]);
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
import { Refine } from "@refinedev/core";
-import routerProvider from "@refinedev/react-router-v6/legacy";
import dataProvider from "@refinedev/simple-rest";
+
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -147,27 +190,44 @@ const CustomPage: React.FC = () => {
);
};
// visible-block-end
-const App: React.FC = () => {
- return (
- ,
- path: "/custom/:id",
- },
- ],
- // highlight-end
- }}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
-render( );
+render(
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
+);
```
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
@@ -180,8 +240,8 @@ If you have multiple resources with the same name, you can pass the `identifier`
When clicked on, the delete button executes the `useDelete` method provided by the [`dataProvider`](/docs/data/data-provider) and the edit button redirects the user to the record edit page.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton, Edit } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
const { default: simpleRest } = RefineSimpleRest;
@@ -255,39 +315,56 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Show Item 2
-
- ),
- show: PostShow,
- edit: () => {
- return Edit Page ;
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+ Edit Page} />
+
+
+
+ ,
);
```
-> For more information, refer to the [`usePermission` documentation →](/docs/authentication/hooks/use-permissions)
-
-> For more information, refer to the [``](/docs/ui-integrations/ant-design/components/buttons/delete-button) and the [``](/docs/ui-integrations/ant-design/components/buttons/edit-button) documentations.
+[Refer to the `usePermissions` documentation for detailed usage. →](/docs/api-reference/core/hooks/authentication/usePermissions/)
### recordItemId
-The`` component reads the `id` information from the route by default. `recordItemId` is used when it cannot read from the URL (when used on a custom page, modal or drawer).
+The `` component reads the `id` information from the route by default. `recordItemId` is used when it cannot read from the URL (when used on a custom page, modal or drawer).
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show, useModalForm } from "@refinedev/antd";
@@ -313,21 +390,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Show Item 2
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -369,8 +466,8 @@ export const App: React.FC = () => {
To customize the back button or to disable it, you can use the `goBack` property:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -380,7 +477,7 @@ const PostShow: React.FC = () => {
const BackButton = () => ← ;
return (
/* highlight-next-line */
- back}>
+ }>
Rest of your page here
);
@@ -388,21 +485,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
Show Item 2
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -432,8 +549,8 @@ const PostShow: React.FC = () => {
Since `` uses the Ant Design [``](https://ant.design/components/card/) component, the `isLoading` property can be set like the below:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -449,21 +566,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -471,8 +608,8 @@ render(
To customize or disable the breadcrumb, you can use the `breadcrumb` property. By default the `Breadcrumb` component from the `@refinedev/antd` package is used for breadcrumbs.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show, Breadcrumb } from "@refinedev/antd";
@@ -500,21 +637,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -524,8 +681,8 @@ render(
You can use the `wrapperProps` property if you want to customize the wrapper of the ` ` component. The `@refinedev/antd` wrapper elements are simply `
`s and `wrapperProps` and can get every attribute that `
` can get.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -549,21 +706,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -571,8 +748,8 @@ render(
You can use the `headerProps` property to customize the header of the ` ` component:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -597,21 +774,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -621,8 +818,8 @@ render(
You can use the `contentProps` property to customize the content of the ` ` component:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -646,21 +843,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -678,8 +895,8 @@ If [`canDelete`](#candelete-and-canedit) is `false`, the [``][dele
If [`canEdit`](#candelete-and-canedit) is `false`, [``][edit-button] will not render and `editButtonProps` will be `undefined`.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -704,28 +921,48 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `createButtonProps` to utilize the default values of the [``][list-button], [``][edit-button], [``][delete-button], and [``][refresh-button] components.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import {
@@ -770,21 +1007,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -792,8 +1049,8 @@ render(
You can use the `headerButtonProps` property to customize the wrapper element of the buttons at the header:
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -819,21 +1076,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -843,8 +1120,8 @@ render(
You can customize the buttons at the footer by using the `footerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -869,21 +1146,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -891,8 +1188,8 @@ render(
You can customize the wrapper element of the buttons at the footer by using the `footerButtonProps` property.
-```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/2
-const { ShowButton } = RefineAntd;
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/antd";
@@ -910,10 +1207,8 @@ const PostShow: React.FC = () => {
// highlight-start
footerButtonProps={{
style: {
- // hide-start
float: "right",
marginRight: 24,
- // hide-end
backgroundColor: "cornflowerblue",
padding: "16px",
},
@@ -927,21 +1222,41 @@ const PostShow: React.FC = () => {
// visible-block-end
render(
- (
-
-
This page is empty.
-
-
- ),
- show: PostShow,
- },
- ]}
- />,
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/breadcrumb/index.md b/documentation/docs/ui-integrations/ant-design/components/breadcrumb/index.md
index 4ce98b7730db..b39c0f822e25 100644
--- a/documentation/docs/ui-integrations/ant-design/components/breadcrumb/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/breadcrumb/index.md
@@ -80,6 +80,9 @@ const PostList = () => {
return (
Content of your list page...
+
+ Show Post 123
+
);
};
@@ -87,12 +90,8 @@ const PostList = () => {
setInitialRoutes(["/posts/show/123"]);
render(
-
-
+
-
- } />
- } />
-
+
+ } />
+ } />
+
-
- ,
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/clone-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/clone-button/index.md
index 20478c621b18..f965e758cfbe 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/clone-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/clone-button/index.md
@@ -15,8 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live previewHeight=300px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
@@ -54,21 +55,37 @@ interface IPost {
}
// visible-block-end
-const PostCreate = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+const PostClone = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -78,33 +95,49 @@ render(
`recordItemId` is used to append the record id to the end of the route path. By default, the `recordItemId` is inferred from the route params.
-```tsx live disableScroll previewHeight=120px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { CloneButton } from "@refinedev/antd";
const MyCloneComponent = () => {
- return ;
+ return ;
};
// visible-block-end
const ClonedPage = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -114,37 +147,48 @@ Clicking the button will trigger the `clone` method of [`useNavigation`](/docs/r
`resource` is used to redirect the app to the `clone` action of the given resource name. By default, the app redirects to the inferred resource's `clone` action path.
-```tsx live disableScroll previewHeight=120px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/categories"]);
// visible-block-start
import { CloneButton } from "@refinedev/antd";
const MyCloneComponent = () => {
- return ;
+ return ;
};
// visible-block-end
-const ClonedPage = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+const CategoryClone = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+ } />
+ }
+ />
+
+
+ ,
);
```
@@ -170,15 +214,15 @@ const MyComponent = () => {
It is used to show and not show the text of the button. When `true`, only the button icon is visible.
-```tsx live disableScroll previewHeight=120px
-const { useRouterContext } = RefineCore;
-
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { CloneButton } from "@refinedev/antd";
const MyCloneComponent = () => {
return (
@@ -188,21 +232,36 @@ const MyCloneComponent = () => {
// visible-block-end
const ClonedPage = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/create-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/create-button/index.md
index 2ee69a995303..b59595f9e5fd 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/create-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/create-button/index.md
@@ -15,8 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live previewHeight=300px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
@@ -49,20 +50,36 @@ interface IPost {
// visible-block-end
const CreatePage = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -72,42 +89,48 @@ render(
`resource` is used to redirect the app to the `create` action path of the given resource name. By default, the app redirects to the inferred resource's `create` action path.
-```tsx live disableScroll previewHeight=120px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/categories"]);
// visible-block-start
import { CreateButton } from "@refinedev/antd";
const MyCreateComponent = () => {
- return (
-
- );
+ return ;
};
// visible-block-end
-const CreatePage = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+const CategoryCreate = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+ } />
+ }
+ />
+
+
+ ,
);
```
@@ -133,8 +156,8 @@ const MyComponent = () => {
It is used to show and not show the text of the button. When `true`, only the button icon is visible.
-```tsx live disableScroll previewHeight=120px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { CreateButton } from "@refinedev/antd";
@@ -151,21 +174,36 @@ const MyCreateComponent = () => {
// visible-block-end
const CreatePage = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -178,7 +216,12 @@ import { CreateButton } from "@refinedev/antd";
export const MyListComponent = () => {
return (
-
+
);
};
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/delete-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/delete-button/index.md
index dec9b7086f6e..f3a131a1642c 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/delete-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/delete-button/index.md
@@ -15,7 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
@@ -25,7 +27,7 @@ import {
} from "@refinedev/antd";
import { Table } from "antd";
-const PostList: React.FC = () => {
+const PostList = () => {
const { tableProps } = useTable();
return (
@@ -55,14 +57,29 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -72,12 +89,13 @@ render(
`recordItemId` allows us to manage which record will be deleted. By default, the `recordItemId` is inferred from the route params.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live disableScroll previewHeight=120px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { DeleteButton } from "@refinedev/antd";
-const MyEditComponent = () => {
+const MyDeleteComponent = () => {
return (
{
// visible-block-end
render(
- {
- return List page here... ;
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -111,8 +140,8 @@ Clicking the button will trigger the [`useDelete`](/docs/data/hooks/use-delete)
`resource` allows us to manage which resource's record is going to be deleted. By default, the `resource` is inferred from the route params.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live disableScroll previewHeight=120px
+setInitialRoutes(["/categories"]);
// visible-block-start
import { DeleteButton } from "@refinedev/antd";
@@ -124,28 +153,28 @@ const MyDeleteComponent = () => {
// visible-block-end
render(
- {
- return List page here... ;
+
+ {
- return List page here... ;
+ {
+ name: "categories",
+ list: "/categories",
},
- },
- ]}
- DashboardPage={MyDeleteComponent}
- />,
+ ]}
+ >
+
+ } />
+
+
+ ,
);
```
-Clicking the button will trigger the [`useDelete`](/docs/data/hooks/use-delete) method and then the record whose resource is "categories" and whose id is "2" will be deleted.
+Clicking the button will trigger the [`useDelete`](/docs/data/hooks/use-delete) method and then the record whose resource is "categories" and whose id is "123" will be deleted.
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
@@ -157,10 +186,8 @@ If you have multiple resources with the same name, you can pass the `identifier`
For example, let's `console.log` after deletion:
-```tsx live url=http://localhost:3000 previewHeight=150px disableScroll
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
+```tsx live disableScroll previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { DeleteButton } from "@refinedev/antd";
@@ -168,7 +195,7 @@ import { DeleteButton } from "@refinedev/antd";
const MyDeleteComponent = () => {
return (
{
console.log(value);
@@ -195,15 +222,30 @@ const App = () => {
};
return (
-
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+
);
};
@@ -216,11 +258,14 @@ Determines which mode mutation will have while executing ``.
> For more information, refer to the [mutation mode documentation →](/advanced-tutorials/mutation-mode.md)
-```tsx
+```tsx live disableScroll previewHeight=360px
+setInitialRoutes(["/posts"]);
+
+// visible-block-start
import { List, DeleteButton, useTable } from "@refinedev/antd";
import { Table } from "antd";
-export const PostList: React.FC = () => {
+const PostList = () => {
const { tableProps } = useTable();
return (
@@ -244,14 +289,46 @@ export const PostList: React.FC = () => {
);
};
+
+interface IPost {
+ id: number;
+ title: string;
+}
+// visible-block-end
+
+render(
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
+);
```
### hideText
It is used to show and not show the text of the button. When `true`, only the button icon is visible.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live disableScroll previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { DeleteButton } from "@refinedev/antd";
@@ -259,9 +336,9 @@ import { DeleteButton } from "@refinedev/antd";
const MyDeleteComponent = () => {
return (
);
};
@@ -269,15 +346,29 @@ const MyDeleteComponent = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -290,7 +381,12 @@ import { DeleteButton } from "@refinedev/antd";
export const MyListComponent = () => {
return (
-
+
);
};
```
@@ -299,44 +395,6 @@ export const MyListComponent = () => {
Use `resource` prop instead.
-## How to override confirm texts?
-
-You can change the text that appears when you confirm a transaction with the `confirmTitle` prop, as well as what the 'ok' and 'cancel' buttons' text look like with the `confirmOkText` and `confirmCancelText` props.
-
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
-
-// visible-block-start
-import { DeleteButton } from "@refinedev/antd";
-
-const MyDeleteComponent = () => {
- return (
-
- );
-};
-
-// visible-block-end
-
-render(
- ,
-);
-```
-
## API Reference
### Properties
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/edit-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/edit-button/index.md
index 281e66e712f8..8827747cbc11 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/edit-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/edit-button/index.md
@@ -15,8 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live previewHeight=300px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
@@ -55,20 +56,36 @@ interface IPost {
// visible-block-end
const PostEdit = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -78,8 +95,9 @@ render(
`recordItemId` is used to append the record id to the end of the route path. By default, the `recordItemId` is inferred from the route params.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { EditButton } from "@refinedev/antd";
@@ -95,22 +113,37 @@ const MyEditComponent = () => {
// visible-block-end
+const PostEdit = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
+};
+
render(
- {
- return List page here... ;
+
+ {
- return Edit page here... ;
- },
- },
- ]}
- DashboardPage={MyEditComponent}
- />,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -120,8 +153,8 @@ Clicking the button will trigger the `edit` method of [`useNavigation`](/docs/ro
The redirection endpoint is defined by the `resource` property and its `edit` action path. By default, `` uses the inferred resource from the route.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/categories"]);
// visible-block-start
import { EditButton } from "@refinedev/antd";
@@ -138,31 +171,42 @@ const MyEditComponent = () => {
// visible-block-end
+const CategoryEdit = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
+};
+
render(
- {
- return List page here... ;
- },
- edit: () => {
- return Edit page here... ;
+
+ {
- return List page here... ;
+ {
+ name: "categories",
+ list: "/categories",
+ edit: "/categories/:id/edit",
},
- edit: () => {
- return Edit page here... ;
- },
- },
- ]}
- DashboardPage={MyEditComponent}
- />,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -188,8 +232,8 @@ const MyComponent = () => {
It is used to show and not show the text of the button. When `true`, only the button icon is visible.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { EditButton } from "@refinedev/antd";
@@ -197,28 +241,46 @@ import { EditButton } from "@refinedev/antd";
const MyEditComponent = () => {
return (
);
};
// visible-block-end
+const PostEdit = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
+};
+
render(
- {
- return Edit page here... ;
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -232,12 +294,10 @@ import { EditButton } from "@refinedev/antd";
export const MyListComponent = () => {
return (
);
};
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/export-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/export-button/index.md
index e43eacec8978..7ebe37ccaf2c 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/export-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/export-button/index.md
@@ -19,7 +19,9 @@ You can use it like any other Ant Design [``][button].
For example, you can use it with [useExport][useexport]:
-```tsx live
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { useExport } from "@refinedev/core";
import {
@@ -58,14 +60,29 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -75,8 +92,8 @@ render(
`hideText` is used to hide the text of the button. When its `true`, only the button icon will be visible.
-```tsx live disableScroll previewHeight=120px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ExportButton } from "@refinedev/antd";
@@ -93,15 +110,29 @@ const MyExportComponent = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/import-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/import-button/index.md
index 5d796d2cd9dc..715dc3848b96 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/import-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/import-button/index.md
@@ -15,7 +15,10 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts"]);
+
+// visible-block-start
import {
List,
useTable,
@@ -59,14 +62,29 @@ interface IPostFile {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -76,8 +94,8 @@ render(
`hideText` is used to hide the text of the button. When its `true`, only the button icon will be visible.
-```tsx live disableScroll previewHeight=120px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ImportButton, useImport } from "@refinedev/antd";
@@ -97,15 +115,29 @@ const MyImportComponent = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/list-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/list-button/index.md
index ca5b44faf36d..802021e7dcd3 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/list-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/list-button/index.md
@@ -15,7 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live url=http://localhost:3000/posts/show/123
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts/show/123"]);
+
// visible-block-start
import { useShow } from "@refinedev/core";
import {
@@ -51,22 +53,34 @@ interface IPost {
// visible-block-end
render(
- {
- return (
-
- Your list page here
-
- );
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ Your list page here...}
+ />
+ } />
+
+
+
+ ,
);
```
@@ -78,8 +92,8 @@ The button text is defined automatically by Refine based on the `resource` defin
The redirection endpoint is defined by the `resource`'s `list` action path. By default, `` uses the inferred resource from the route.
-```tsx live disableScroll previewHeight=120px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/"]);
// visible-block-start
import { ListButton } from "@refinedev/antd";
@@ -91,25 +105,33 @@ const MyListComponent = () => {
// visible-block-end
render(
- {
- return (
-
- Your list page here
-
- );
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ Your list page here...}
+ />
+
+
+
+ ,
);
```
@@ -135,13 +157,16 @@ const MyComponent = () => {
`hideText` is used to hide the text of the button. When its `true`, only the button icon will be visible.
-```tsx live disableScroll previewHeight=120px
+```tsx live previewHeight=120px
+setInitialRoutes(["/"]);
+
// visible-block-start
import { ListButton } from "@refinedev/antd";
const MyListComponent = () => {
return (
@@ -151,22 +176,33 @@ const MyListComponent = () => {
// visible-block-end
render(
- {
- return (
-
- Your list page here
-
- );
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ Your list page here...}
+ />
+
+
+
+ ,
);
```
@@ -179,7 +215,12 @@ import { ListButton } from "@refinedev/antd";
export const MyListComponent = () => {
return (
-
+
);
};
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/refresh-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/refresh-button/index.md
index 0effed58ae1d..43c6c4e36acc 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/refresh-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/refresh-button/index.md
@@ -13,7 +13,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts/show/123"]);
+
// visible-block-start
import { useShow } from "@refinedev/core";
import {
@@ -52,22 +54,31 @@ interface IPost {
// visible-block-end
render(
- {
- return (
-
- Your list page here
-
- );
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ List page here...} />
+ } />
+
+
+
+ ,
);
```
@@ -77,7 +88,9 @@ render(
`recordItemId` allows us to manage which data is going to be refreshed. By default, the `recordItemId` is inferred from the route params.
-```tsx live disableScroll previewHeight=120px
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { RefreshButton } from "@refinedev/antd";
@@ -86,32 +99,48 @@ const MyRefreshComponent = () => {
);
};
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
-Clicking the button will trigger the [`useInvalidate`][use-invalidate] hook and then fetch the record whose resource is "post" and whose id is "1".
+Clicking the button will trigger the [`useInvalidate`][use-invalidate] hook and then fetch the record whose resource is "post" and whose id is "123".
### resource
`resource` allows us to manage which resource is going to be refreshed. By default, the `resource` is inferred from the route params.
-```tsx live disableScroll previewHeight=120px
+```tsx live previewHeight=120px
+setInitialRoutes(["/categories"]);
+
// visible-block-start
import { RefreshButton } from "@refinedev/antd";
@@ -121,25 +150,38 @@ const MyRefreshComponent = () => {
// highlight-next-line
resource="categories"
// highlight-next-line
- recordItemId="2"
+ recordItemId="123"
/>
);
};
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
@@ -153,7 +195,9 @@ If you have multiple resources with the same name, you can pass the `identifier`
`hideText` is used to hide the text of the button. When its `true`, only the button icon will be visible.
-```tsx live disableScroll previewHeight=120px
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { RefreshButton } from "@refinedev/antd";
@@ -168,15 +212,29 @@ const MyRefreshComponent = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/save-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/save-button/index.md
index 60cd1b38f20d..96f9ddbf4995 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/save-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/save-button/index.md
@@ -15,7 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's add logic to the `` component with the `saveButtonProps` returned by the [`useForm`](/docs/ui-integrations/ant-design/hooks/use-form) hook:
-```tsx live url=http://localhost:3000/posts/edit/123
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts/edit/123"]);
+
// visible-block-start
import { Edit, useForm } from "@refinedev/antd";
import { Form, Input } from "antd";
@@ -51,22 +53,31 @@ interface IPost {
// visible-block-end
render(
- {
- return (
-
- Your list page here
-
- );
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ List page here...} />
+ } />
+
+
+
+ ,
);
```
@@ -78,7 +89,9 @@ The [`useForm`](/docs/ui-integrations/ant-design/hooks/use-form) hook exposes `s
`hideText` is used to hide the text of the button. When its `true`, only the button icon will be visible.
-```tsx live disableScroll previewHeight=120px
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { SaveButton } from "@refinedev/antd";
@@ -93,15 +106,29 @@ const MySaveComponent = () => {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/buttons/show-button/index.md b/documentation/docs/ui-integrations/ant-design/components/buttons/show-button/index.md
index 7dc4d99aa59d..613838680956 100644
--- a/documentation/docs/ui-integrations/ant-design/components/buttons/show-button/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/buttons/show-button/index.md
@@ -15,8 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live previewHeight=300px
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=360px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
@@ -55,20 +56,36 @@ interface IPost {
// visible-block-end
const PostShow = () => {
- const params = useRouterContext().useParams();
- return {JSON.stringify(params)}
;
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
};
render(
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -78,8 +95,9 @@ render(
`recordItemId` is used to append the record id to the end of the route path. By default, the `recordItemId` is inferred from the route params.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { ShowButton } from "@refinedev/antd";
@@ -95,22 +113,37 @@ const MyShowComponent = () => {
// visible-block-end
+const PostShow = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
+};
+
render(
- {
- return List page here... ;
- },
- show: () => {
- return Show page here... ;
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -120,8 +153,8 @@ Clicking the button will trigger the `show` method of [`useNavigation`](/docs/ro
The redirection endpoint is defined by the `resource`'s `show` action path. By default, `` uses the inferred resource from the route.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/categories"]);
// visible-block-start
import { ShowButton } from "@refinedev/antd";
@@ -138,31 +171,45 @@ const MyShowComponent = () => {
// visible-block-end
+const CategoryShow = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
+};
+
render(
- {
- return List page here... ;
+
+ {
- return Show page here... ;
+ {
+ name: "categories",
+ list: "/categories",
+ show: "/categories/show/:id",
},
- },
- {
- name: "categories",
- list: () => {
- return List page here... ;
- },
- show: () => {
- return Show page here... ;
- },
- },
- ]}
- DashboardPage={MyShowComponent}
- />,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ }
+ />
+
+
+
+ ,
);
```
@@ -188,8 +235,8 @@ const MyComponent = () => {
`hideText` is used to hide the text of the button. When its `true`, only the button icon will be visible.
-```tsx live disableScroll previewHeight=150px disableScroll
-const { useRouterContext } = RefineCore;
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ShowButton } from "@refinedev/antd";
@@ -197,28 +244,47 @@ import { ShowButton } from "@refinedev/antd";
const MyShowComponent = () => {
return (
);
};
// visible-block-end
+const PostShow = () => {
+ const parsed = RefineCore.useParsed();
+ return {JSON.stringify(parsed, null, 2)} ;
+};
+
render(
- {
- return Show page here... ;
+
+ ,
+ ]}
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -232,12 +298,10 @@ import { ShowButton } from "@refinedev/antd";
export const MyListComponent = () => {
return (
);
};
@@ -255,6 +319,6 @@ Use `resource` prop instead.
:::simple External Props
-`` also accepts all props of Ant Design's [Button](https://ant.design/components/button/#API) component.
+It also accepts all props of Ant Design [Button](https://ant.design/components/button/#API).
:::
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/boolean-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/boolean-field/index.md
index b0fff496c28b..9d59442d66b0 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/boolean-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/boolean-field/index.md
@@ -15,14 +15,15 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` with the example in the post list:
-```tsx live
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
useTable,
- // highlight-start
+ // highlight-next-line
BooleanField,
- // highlight-end
} from "@refinedev/antd";
import { Table } from "antd";
@@ -30,14 +31,13 @@ const PostList: React.FC = () => {
const { tableProps } = useTable();
const TrueIcon = () => ✅ ;
-
const FalseIcon = () => ❌ ;
return (
-
+
{
/>
// highlight-end
)}
- width="50%"
/>
@@ -67,14 +66,27 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/date-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/date-field/index.md
index 216ee5f79fac..9684e4d57c3f 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/date-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/date-field/index.md
@@ -15,15 +15,11 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` with the example in the post list:
-```tsx live url=http://localhost:3000/posts previewHeight=340px
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
-import {
- List,
- useTable,
- // highlight-start
- DateField,
- // highlight-end
-} from "@refinedev/antd";
+import { List, useTable, DateField } from "@refinedev/antd";
import { Table } from "antd";
const PostList: React.FC = () => {
@@ -33,16 +29,12 @@ const PostList: React.FC = () => {
-
+
(
- // highlight-start
-
- // highlight-end
- )}
- width="50%"
+ // highlight-next-line
+ render={(value) => }
/>
@@ -57,14 +49,27 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/email-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/email-field/index.md
index 18ecd5456a18..f233b342571e 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/email-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/email-field/index.md
@@ -15,7 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` with the example in the user list:
-```tsx live
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/users"]);
+
// visible-block-start
import {
List,
@@ -39,7 +41,6 @@ const UserList: React.FC = () => {
render={(value: string) => }
width="100%"
/>
- ...
);
@@ -52,14 +53,27 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/file-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/file-field/index.md
index bbf8e83d47db..e47ae89f39b1 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/file-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/file-field/index.md
@@ -15,7 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` with the example in the edit page:
-```tsx live
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
@@ -32,7 +34,7 @@ const PostList: React.FC = () => {
-
+
title="Image"
dataIndex="image"
@@ -40,7 +42,6 @@ const PostList: React.FC = () => {
// highlight-next-line
)}
- width="50%"
/>
@@ -59,14 +60,27 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/image-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/image-field/index.md
index 1a03e18d1ef6..b85bc440399c 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/image-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/image-field/index.md
@@ -15,7 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` with the example in the edit page:
-```tsx live
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
@@ -32,7 +34,7 @@ const PostList: React.FC = () => {
-
+
title="Image"
dataIndex="image"
@@ -58,21 +60,33 @@ interface IPost {
image: [
{
url: string;
- name: string;
},
];
}
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/markdown-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/markdown-field/index.md
index 2c9101305b81..536c984ebedd 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/markdown-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/markdown-field/index.md
@@ -15,7 +15,10 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` in a show page:
-```tsx live
+```tsx live previewHeight=280px url=http://localhost:3000/samples/show/123
+setInitialRoutes(["/samples", "/samples/show/123"]);
+
+// visible-block-start
import { useShow } from "@refinedev/core";
import {
Show,
@@ -46,29 +49,46 @@ const SampleShow: React.FC = () => {
interface IPost {
id: number;
- title: string;
content: string;
}
// visible-block-end
render(
- (
-
-
This page is empty.
-
- Show Item 123
-
-
- ),
- show: SampleShow,
- },
- ]}
- />,
+
+
+
+
+
+
This page is empty.
+
+ Show Item 123
+
+
+
+ }
+ />
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/number-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/number-field/index.md
index 0a4431586d1f..c0a206e3b735 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/number-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/number-field/index.md
@@ -17,7 +17,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
If Intl is not available, `` outputs numbers as is (and ignores the locales and options props).
-```tsx live
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import {
List,
@@ -34,7 +36,7 @@ const PostList: React.FC = () => {
-
+
key="hit"
title="Hit"
@@ -49,7 +51,6 @@ const PostList: React.FC = () => {
/>
// highlight-end
)}
- width="50%"
/>
@@ -64,14 +65,27 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/tag-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/tag-field/index.md
index b656c29079a7..ddf46d82d99d 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/tag-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/tag-field/index.md
@@ -15,14 +15,11 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use it in a basic list page:
-```tsx live
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
-import {
- List,
- // highlight-next-line
- TagField,
- useTable,
-} from "@refinedev/antd";
+import { List, TagField, useTable } from "@refinedev/antd";
import { Table } from "antd";
const PostList: React.FC = () => {
@@ -31,13 +28,11 @@ const PostList: React.FC = () => {
return (
@@ -52,14 +47,27 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/text-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/text-field/index.md
index 27ec4902858b..5fb465aa0106 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/text-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/text-field/index.md
@@ -15,7 +15,9 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how to use it in a basic list page:
-```tsx live
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
// visible-block-start
import { useMany } from "@refinedev/core";
import {
@@ -26,7 +28,7 @@ import {
} from "@refinedev/antd";
import { Table } from "antd";
-const PostList: React.FC = (props) => {
+const PostList: React.FC = () => {
const { tableProps } = useTable();
const categoryIds =
@@ -41,12 +43,12 @@ const PostList: React.FC = (props) => {
});
return (
-
+
-
+
{
// highlight-start
if (isLoading) {
@@ -63,7 +65,6 @@ const PostList: React.FC = (props) => {
);
// highlight-end
}}
- width="50%"
/>
@@ -83,14 +84,27 @@ interface IPost {
// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/ant-design/components/fields/url-field/index.md b/documentation/docs/ui-integrations/ant-design/components/fields/url-field/index.md
index 23145050b8b0..ab88f2f3b2fb 100644
--- a/documentation/docs/ui-integrations/ant-design/components/fields/url-field/index.md
+++ b/documentation/docs/ui-integrations/ant-design/components/fields/url-field/index.md
@@ -15,13 +15,10 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` with an example:
-```tsx live
-import {
- List,
- useTable,
- // highlight-next-line
- UrlField,
-} from "@refinedev/antd";
+```tsx live previewHeight=280px url=http://localhost:3000/posts
+setInitialRoutes(["/posts"]);
+
+import { List, UrlField, useTable } from "@refinedev/antd";
import { Table } from "antd";
const PostList: React.FC = () => {
@@ -30,14 +27,12 @@ const PostList: React.FC = () => {
return (
@@ -53,17 +48,29 @@ interface IPost {
interface IImage {
url: string;
}
-// visible-block-end
render(
- ,
+
+
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/basic-views/create/index.md b/documentation/docs/ui-integrations/chakra-ui/components/basic-views/create/index.md
index 2e085f4a02b6..41f8fcc49bc4 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/basic-views/create/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/basic-views/create/index.md
@@ -3,58 +3,19 @@ title: Create
swizzle: true
---
-```tsx live shared
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-
-const DummyListPage = () => (
-
- This page is empty.
-
-
-);
-
-interface ICategory {
- id: number;
- title: string;
-}
-
-interface IPost {
- id: number;
- title: string;
- content: string;
- status: "published" | "draft" | "rejected";
- category: { id: number };
-}
-```
-
`` provides us a layout to display the page. It does not contain any logic and just adds extra functionalities like action buttons and being able to give titles to the page.
We will show what `` does using properties with examples.
-```tsx live url=http://localhost:3000/posts/create previewHeight=420px hideCode
+```tsx live previewHeight=420px hideCode url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
import {
FormControl,
- FormErrorMessage,
FormLabel,
+ FormErrorMessage,
Input,
Select,
} from "@chakra-ui/react";
@@ -67,7 +28,7 @@ const PostCreate: React.FC = () => {
saveButtonProps,
register,
formState: { errors },
- } = useForm();
+ } = useForm();
const { options } = useSelect({
resource: "categories",
@@ -82,7 +43,7 @@ const PostCreate: React.FC = () => {
type="text"
{...register("title", { required: "Title is required" })}
/>
- {`${errors.title?.message}`}
+ {`${errors?.title?.message}`}
Status
@@ -97,14 +58,14 @@ const PostCreate: React.FC = () => {
draft
rejected
- {`${errors.status?.message}`}
+ {`${errors?.status?.message}`}
-
+
Category
@@ -114,30 +75,38 @@ const PostCreate: React.FC = () => {
))}
- {`${errors.categoryId?.message}`}
+ {`${errors?.category?.message}`}
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -151,12 +120,10 @@ You can swizzle this component with the [**Refine CLI**](/docs/packages/list-of-
### title
-`title` allows the addition of titles inside the `` component by passing title props. If you don't pass title props, however, it uses the "Create" prefix and the singular resource name by default. For example, for the `/posts/create` resource, it would be "Create post".
+`title` allows you to add a title inside the `` component. If you don't pass title props, it uses the "Create" prefix and the singular resource name by default. For example, for the "posts" resource, it will be "Create post".
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
@@ -172,34 +139,40 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
### saveButtonProps
-`saveButtonProps` can be used to customize the default button of the `` component that submits the form:
+The `` component has a save button that submits the form by default. If you want to customize this button you can use the `saveButtonProps` property:
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
@@ -214,125 +187,124 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`` documentation →](/docs/ui-integrations/chakra-ui/components/buttons/save-button)
-
### resource
The `` component reads the `resource` information from the route by default. If you want to use a custom resource for the `` component, you can use the `resource` prop.
-```tsx live url=http://localhost:3000/custom previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/custom
setInitialRoutes(["/custom"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import { Layout } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
const CustomPage: React.FC = () => {
return (
/* highlight-next-line */
-
+
Rest of your page here
);
};
// visible-block-end
-const App: React.FC = () => {
- return (
- ,
- path: "/custom",
- },
- ],
- // highlight-end
- }}
- Layout={Layout}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
-
render(
-
-
- ,
+
+
+
+ } />
+
+
+ ,
);
```
-If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
-
-> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
-
### goBack
-To customize the back button or to disable it, you can use the `goBack` property. You can pass `false` or `null` to hide the back button.
+To customize the back button or to disable it, you can use the `goBack` property.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
-setInitialRoutes(["/posts", "/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
-/* highlight-next-line */
import { IconMoodSmile } from "@tabler/icons-react";
const PostCreate: React.FC = () => {
return (
/* highlight-next-line */
}>
- Rest of your page here 2
+ Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -340,10 +312,8 @@ render(
To toggle the loading state of the ` ` component, you can use the `isLoading` property.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
@@ -358,34 +328,40 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-### breadcrumb
+### breadcrumb
To customize or disable the breadcrumb, you can use the `breadcrumb` property. By default it uses the `Breadcrumb` component from `@refinedev/chakra-ui` package.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create, Breadcrumb } from "@refinedev/chakra-ui";
@@ -408,36 +384,40 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Breadcrumb` documentation →](/docs/ui-integrations/chakra-ui/components/breadcrumb)
-
### wrapperProps
If you want to customize the wrapper of the ` ` component, you can use the `wrapperProps` property. For `@refinedev/chakra-ui` wrapper element is ``s and `wrapperProps` can get every attribute that `` can get.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
@@ -459,36 +439,40 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### headerProps
If you want to customize the header of the ` ` component, you can use the `headerProps` property.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
@@ -510,103 +494,54 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
-
- ,
-);
-```
-
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
-### contentProps
-
-If you want to customize the content of the ` ` component, you can use the `contentProps` property.
-
-```tsx live url=http://localhost:3000/posts/create previewHeight=320px
-setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
-
-// visible-block-start
-import { Create } from "@refinedev/chakra-ui";
-
-const PostCreate: React.FC = () => {
- return (
-
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### headerButtons
You can customize the buttons at the header by using the `headerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
-import { Button, Box } from "@chakra-ui/react";
+import { Button, HStack } from "@chakra-ui/react";
const PostCreate: React.FC = () => {
return (
(
-
+
{defaultButtons}
-
- Custom Button
-
-
+ Custom Button
+
)}
// highlight-end
>
@@ -616,23 +551,31 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -640,10 +583,8 @@ render(
You can customize the wrapper element of the buttons at the header by using the `headerButtonProps` property.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
@@ -657,9 +598,14 @@ const PostCreate: React.FC = () => {
borderColor: "blue",
borderStyle: "dashed",
borderWidth: "2px",
+ p: "2",
}}
// highlight-end
- headerButtons={Custom Button }
+ headerButtons={
+
+ Custom Button
+
+ }
>
Rest of your page here
@@ -667,38 +613,42 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### footerButtons
-By default, the ` ` component has a [``][save-button] at the header.
+By default, the ` ` component has a [``][save-button] at the footer.
You can customize the buttons at the footer by using the `footerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons, saveButtonProps }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
@@ -724,74 +674,31 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
-
- ,
-);
-```
-
-Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `saveButtonProps` to utilize the default values of the [``][save-button] component.
-
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
-setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton, SaveButton } from "@refinedev/chakra-ui";
-
-// visible-block-start
-import { Create } from "@refinedev/chakra-ui";
-import { Button, HStack } from "@chakra-ui/react";
-
-const PostCreate: React.FC = () => {
- return (
- (
-
-
-
- Custom Button
-
-
- )}
- // highlight-end
- >
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -799,10 +706,8 @@ render(
You can customize the wrapper element of the buttons at the footer by using the `footerButtonProps` property.
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/create
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/chakra-ui";
// visible-block-start
import { Create } from "@refinedev/chakra-ui";
@@ -826,32 +731,38 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+ Create Post
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
## API Reference
-### Props
+### Properties
-
+
[save-button]: /docs/ui-integrations/chakra-ui/components/buttons/save-button
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/basic-views/edit/index.md b/documentation/docs/ui-integrations/chakra-ui/components/basic-views/edit/index.md
index e6b5e573aaa0..07f1b6b5760e 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/basic-views/edit/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/basic-views/edit/index.md
@@ -3,174 +3,149 @@ title: Edit
swizzle: true
---
-```tsx live shared
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-
-const DummyListPage = () => (
-
- This page is empty.
-
- Edit Item 123
-
-
-);
-
-interface ICategory {
- id: number;
- title: string;
-}
-
-interface IPost {
- id: number;
- title: string;
- content: string;
- status: "published" | "draft" | "rejected";
- category: { id: number };
-}
-```
-
-`` provides us a layout for displaying the page. It does not contain any logic and just adds extra functionalities like a refresh button.
+`` provides us a layout for displaying the page. It does not contain any logic but adds extra functionalities like a refresh button.
We will show what `` does using properties with examples.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=420px hideCode
+```tsx live previewHeight=480px hideCode url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
+import React from "react";
import { Edit } from "@refinedev/chakra-ui";
import {
FormControl,
- FormErrorMessage,
FormLabel,
+ FormErrorMessage,
Input,
+ Box,
Select,
} from "@chakra-ui/react";
-import { useSelect } from "@refinedev/core";
import { useForm } from "@refinedev/react-hook-form";
+import { useSelect } from "@refinedev/core";
+import { Controller } from "react-hook-form";
const PostEdit: React.FC = () => {
const {
- refineCore: { formLoading, query },
saveButtonProps,
+ refineCore: { query },
register,
+ control,
formState: { errors },
- resetField,
- } = useForm();
+ } = useForm();
const { options } = useSelect({
resource: "categories",
-
- defaultValue: query?.data?.data.category.id,
- queryOptions: { enabled: !!query?.data?.data.category.id },
+ defaultValue: query?.data?.category?.id,
});
- useEffect(() => {
- resetField("category.id");
- }, [options]);
-
return (
-
-
- Title
-
- {`${errors.title?.message}`}
-
-
- Status
-
- published
- draft
- rejected
-
- {`${errors.status?.message}`}
-
-
- Category
-
- {options?.map((option) => (
-
- {option.label}
-
- ))}
-
- {`${errors.categoryId?.message}`}
-
+
+
+
+ Id
+
+ {`${errors?.id?.message}`}
+
+
+
+ Title
+
+ {`${errors?.title?.message}`}
+
+
+ Status
+
+ published
+ draft
+ rejected
+
+ {`${errors.status?.message}`}
+
+
+
+ Category
+ (
+
+ {options?.map((option) => (
+
+ {option.label}
+
+ ))}
+
+ )}
+ />
+ {`${errors?.category?.message}`}
+
+
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
:::simple Good to know
-
-You can swizzle this component to customize it with the [**Refine CLI**](/docs/packages/list-of-packages)
-
+You can swizzle this component with the [**Refine CLI**](/docs/packages/list-of-packages) to customize it.
:::
## Properties
### title
-`title` allows the addition of titles inside the `` component. if you don't pass title props it uses the "Edit" prefix and singular resource name by default. For example, for the "posts" resource, it would be "Edit post".
+`title` allows you to add a title inside the `` component. If you don't pass title props, it uses the "Edit" prefix and the singular resource name by default. For example, for the "posts" resource, it will be "Edit post".
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
@@ -186,257 +161,218 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-### saveButtonProps
+### resource
-`saveButtonProps` can be used to customize the default button of the `` component that submits the form:
+The `` component reads the `resource` information from the route by default. If you want to use a custom resource for the `` component, you can use the `resource` prop.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
-setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/custom/123
+setInitialRoutes(["/custom/123"]);
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
-const PostEdit: React.FC = () => {
+const CustomPage: React.FC = () => {
return (
/* highlight-next-line */
-
+
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`` documentation →](/docs/ui-integrations/chakra-ui/components/buttons/save-button)
+If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
-### canDelete and deleteButtonProps
+> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
-`canDelete` allows us to add the delete button inside the `` component that executes the `useDelete` method provided by the `dataProvider` when clicked on.
+### saveButtonProps
-If the resource has the `canDelete` property, Refine adds the delete button by default. If you want to customize this button, you can use the `deleteButtonProps` property like the code below.
+The `` component has a save button that submits the form by default. If you want to customize this button you can use the `saveButtonProps` property:
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
-import { usePermissions } from "@refinedev/core";
const PostEdit: React.FC = () => {
- const { data: permissionsData } = usePermissions();
return (
-
+ /* highlight-next-line */
+
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- return {
- data: {},
- };
- },
- };
-
- const authProvider = {
- login: async () => {
- return {
- success: true,
- redirectTo: "/",
- };
- },
- register: async () => {
- return {
- success: true,
- };
- },
- forgotPassword: async () => {
- return {
- success: true,
- };
- },
- updatePassword: async () => {
- return {
- success: true,
- };
- },
- logout: async () => {
- return {
- success: true,
- redirectTo: "/",
- };
- },
- check: async () => ({
- authenticated: true,
- }),
- onError: async (error) => {
- console.error(error);
- return { error };
- },
- getPermissions: async () => ["admin"],
- getIdentity: async () => null,
- };
-
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`` →](/docs/ui-integrations/chakra-ui/components/buttons/delete-button) and [`usePermission` →](/docs/authentication/hooks/use-permissions) documentations
+> For more information, refer to the [`` documentation →](/docs/ui-integrations/chakra-ui/components/buttons/save-button)
-### resource
+### canDelete and deleteButtonProps
-`` component reads the `resource` information from the route by default. If you want to use a custom resource for the `` component, you can use the `resource` prop.
+`canDelete` allows you to add a delete button inside the `` component. If the resource has the `canDelete` property, Refine adds the delete button by default. If you want to customize this button you can use the `deleteButtonProps` property like the code below.
-```tsx live url=http://localhost:3000/custom/23 previewHeight=280px
-setInitialRoutes(["/custom/23"]);
+When clicked on, the delete button executes the `useDelete` method provided by the `dataProvider`.
+
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
-import { Layout } from "@refinedev/chakra-ui";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
+import { usePermissions } from "@refinedev/core";
+
+const PostEdit: React.FC = () => {
+ const { data: permissionsData } = usePermissions();
-const CustomPage: React.FC = () => {
return (
- /* highlight-next-line */
-
+
Rest of your page here
);
};
// visible-block-end
-const App: React.FC = () => {
- return (
- ,
- path: "/custom/:id",
- },
- ],
- // highlight-end
- }}
- Layout={Layout}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
-
render(
-
-
- ,
+
+ Promise.resolve(["admin"]),
+ },
+ }}
+ >
+
+ } />
+
+
+ ,
);
```
-If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
-
-> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
-
### recordItemId
-The `` component reads the `id` information from the route by default. `recordItemId` is used when it cannot read from the URL(when used on a custom page, modal or drawer).
+The `` component reads the `id` information from the route by default. `recordItemId` is used when it cannot read from the URL (when used on a custom page, modal or drawer).
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=350px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
-import { useModalForm } from "@refinedev/react-hook-form";
import { Edit } from "@refinedev/chakra-ui";
+import { useModalForm } from "@refinedev/react-hook-form";
import {
Modal,
- Button,
ModalOverlay,
ModalContent,
ModalCloseButton,
ModalHeader,
ModalBody,
+ Button,
} from "@chakra-ui/react";
const PostEdit: React.FC = () => {
@@ -454,8 +390,7 @@ const PostEdit: React.FC = () => {
- Edit
-
+ Edit Post
{/* highlight-next-line */}
@@ -469,56 +404,39 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 23
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+ } />
+
+
+ ,
);
```
-:::simple Implementation Tips
-
-The `` component needs the `id` information for the `` to work properly.
-
-:::
-
### mutationMode
-`mutationMode` determines which mode the mutation will have while executing ``.
+Determines which mode mutation will have while executing `useDelete`.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
import {
- Input,
FormControl,
FormLabel,
FormErrorMessage,
+ Input,
} from "@chakra-ui/react";
import { useForm } from "@refinedev/react-hook-form";
@@ -527,7 +445,7 @@ const PostEdit: React.FC = () => {
saveButtonProps,
register,
formState: { errors },
- } = useForm();
+ } = useForm();
return (
{
type="text"
{...register("title", { required: "Title is required" })}
/>
- {`${errors.title?.message}`}
+ {`${errors?.title?.message}`}
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -579,9 +504,10 @@ If not specified, Refine will use the default data provider. If you have multipl
```tsx
import { Refine } from "@refinedev/core";
-import { Edit } from "@refinedev/chakra-ui";
import dataProvider from "@refinedev/simple-rest";
+import { Edit } from "@refinedev/chakra-ui";
+
// highlight-start
const PostEdit = () => {
return ... ;
@@ -608,46 +534,50 @@ export const App: React.FC = () => {
To customize the back button or to disable it, you can use the `goBack` property. You can pass `false` or `null` to hide the back button.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
-setInitialRoutes(["/posts", "/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
+setInitialRoutes(["/posts/edit/123"]);
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
-/* highlight-next-line */
import { IconMoodSmile } from "@tabler/icons-react";
const PostEdit: React.FC = () => {
return (
/* highlight-next-line */
}>
- Rest of your page here 2
+ Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -655,12 +585,8 @@ render(
To toggle the loading state of the ` ` component, you can use the `isLoading` property.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
@@ -675,37 +601,31 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+ } />
+
+
+ ,
);
```
-### breadcrumb
+### breadcrumb
To customize or disable the breadcrumb, you can use the `breadcrumb` property. By default it uses the `Breadcrumb` component from `@refinedev/chakra-ui` package.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit, Breadcrumb } from "@refinedev/chakra-ui";
@@ -728,94 +648,42 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
-
- ,
-);
-```
-
-> For more information, refer to the [`Breadcrumb` documentation →](/docs/ui-integrations/chakra-ui/components/breadcrumb)
-
-### wrapperProps
-
-If you want to customize the wrapper of the ` ` component, you can use the `wrapperProps` property. For `@refinedev/chakra-ui` wrapper element is ``s and `wrapperProps` can get every attribute that `` can get.
-
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
-setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
-
-// visible-block-start
-import { Edit } from "@refinedev/chakra-ui";
-
-const PostEdit: React.FC = () => {
- return (
-
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### headerProps
If you want to customize the header of the ` ` component, you can use the `headerProps` property.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
@@ -837,84 +705,25 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
-
- ,
-);
-```
-
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
-### contentProps
-
-If you want to customize the content of the ` ` component, you can use the `contentProps` property.
-
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
-setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
-
-// visible-block-start
-import { Edit } from "@refinedev/chakra-ui";
-
-const PostEdit: React.FC = () => {
- return (
-
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### headerButtons
By default, the ` ` component has a [``][list-button] and a [``][refresh-button] at the header.
@@ -922,21 +731,15 @@ By default, the ` ` component has a [``][list-button] and a [`
You can customize the buttons at the header by using the `headerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons, refreshButtonProps, listButtonProps }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
:::simple Implementation Tips
-
-If the "list" resource is not defined, the [``][list-button] will not render and `listButtonProps` will be `undefined`.
-
+If "list" resource is not defined, the [``][list-button] will not render and `listButtonProps` will be `undefined`.
:::
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
-import { Button, HStack, Box } from "@chakra-ui/react";
+import { Button, HStack } from "@chakra-ui/react";
const PostEdit: React.FC = () => {
return (
@@ -956,79 +759,33 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
-
- ,
-);
-```
-
-Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `refreshButtonProps` and `listButtonProps` to utilize the default values of the [``][list-button] and [``][refresh-button] components.
-
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
-setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton, RefreshButton, ListButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
-
-// visible-block-start
-import { Edit } from "@refinedev/chakra-ui";
-import { Button, HStack, Box } from "@chakra-ui/react";
-
-const PostEdit: React.FC = () => {
- return (
- (
-
-
- {listButtonProps && (
-
- )}
- Custom Button
-
- )}
- // highlight-end
- >
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -1036,12 +793,8 @@ render(
You can customize the wrapper element of the buttons at the header by using the `headerButtonProps` property.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
@@ -1059,7 +812,7 @@ const PostEdit: React.FC = () => {
}}
// highlight-end
headerButtons={
-
+
Custom Button
}
@@ -1070,29 +823,36 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### footerButtons
By default, the ` ` component has a [``][save-button] and a [``][delete-button] at the footer.
@@ -1100,17 +860,11 @@ By default, the ` ` component has a [``][save-button] and a [`
You can customize the buttons at the footer by using the `footerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons, saveButtonProps, deleteButtonProps }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
:::simple Implementation Tips
-
If [`canDelete`](#candelete-and-deletebuttonprops) is `false`, the [``][delete-button] will not render and `deleteButtonProps` will be `undefined`.
-
:::
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
@@ -1136,81 +890,33 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
-
- ,
-);
-```
-
-Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `saveButtonProps` and `deleteButtonProps` to utilize the default values of the [``][save-button] and [``][delete-button] components.
-
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
-setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton, SaveButton, DeleteButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
-
-// visible-block-start
-import { Edit } from "@refinedev/chakra-ui";
-import { Button, HStack } from "@chakra-ui/react";
-
-const PostEdit: React.FC = () => {
- return (
- (
-
-
- {deleteButtonProps && (
-
- )}
-
- Custom Button
-
-
- )}
- // highlight-end
- >
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -1218,12 +924,8 @@ render(
You can customize the wrapper element of the buttons at the footer by using the `footerButtonProps` property.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
@@ -1247,51 +949,55 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### autoSaveProps
You can use the auto save feature of the ` ` component by using the `autoSaveProps` property.
-```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=420px
+```tsx live disableScroll previewHeight=420px url=http://localhost:3000/posts/edit/123
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
+// visible-block-start
import { Edit } from "@refinedev/chakra-ui";
import {
FormControl,
- FormErrorMessage,
FormLabel,
+ FormErrorMessage,
Input,
Select,
} from "@chakra-ui/react";
-import { useSelect } from "@refinedev/core";
import { useForm } from "@refinedev/react-hook-form";
+import { useSelect } from "@refinedev/core";
-// visible-block-start
const PostEdit: React.FC = () => {
const {
refineCore: {
@@ -1316,9 +1022,7 @@ const PostEdit: React.FC = () => {
const { options } = useSelect({
resource: "categories",
-
- defaultValue: query?.data?.data.category.id,
- queryOptions: { enabled: !!query?.data?.data.category.id },
+ defaultValue: query?.data?.category?.id,
});
useEffect(() => {
@@ -1339,7 +1043,7 @@ const PostEdit: React.FC = () => {
type="text"
{...register("title", { required: "Title is required" })}
/>
- {`${errors.title?.message}`}
+ {`${errors?.title?.message}`}
Status
@@ -1354,57 +1058,48 @@ const PostEdit: React.FC = () => {
draft
rejected
- {`${errors.status?.message}`}
-
-
- Category
-
- {options?.map((option) => (
-
- {option.label}
-
- ))}
-
- {`${errors.categoryId?.message}`}
+ {`${errors?.status?.message}`}
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
## API Reference
-### Props
+### Properties
-
+
[list-button]: /docs/ui-integrations/chakra-ui/components/buttons/list-button
[refresh-button]: /docs/ui-integrations/chakra-ui/components/buttons/refresh-button
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/basic-views/list/index.md b/documentation/docs/ui-integrations/chakra-ui/components/basic-views/list/index.md
index 1f67446d7345..446f2b9398b9 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/basic-views/list/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/basic-views/list/index.md
@@ -3,44 +3,12 @@ title: List
swizzle: true
---
-```tsx live shared
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-
-interface ICategory {
- id: number;
- title: string;
-}
-
-interface IPost {
- id: number;
- title: string;
- content: string;
- status: "published" | "draft" | "rejected";
- category: { id: number };
-}
-```
-
`` provides us a layout to display the page. It does not contain any logic and just adds extra functionalities like a create button or giving the page titles.
We will show what `` does using properties with examples.
```tsx live url=http://localhost:3000/posts previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { List, DateField } from "@refinedev/chakra-ui";
@@ -140,24 +108,21 @@ const PostList: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+ } />
+
+
+ ,
);
```
@@ -192,23 +157,22 @@ const PostList: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+ } />
+
+
+ ,
);
```
@@ -219,16 +183,11 @@ render(
```tsx live url=http://localhost:3000/custom previewHeight=280px
setInitialRoutes(["/custom"]);
-import { Refine } from "@refinedev/core";
-import { Layout } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { List } from "@refinedev/chakra-ui";
const CustomPage: React.FC = () => {
return (
- /* highlight-next-line */
Rest of your page here
@@ -236,30 +195,21 @@ const CustomPage: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
- ,
- path: "/custom",
- },
- ],
- // highlight-end
- }}
- Layout={Layout}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
render(
-
-
- ,
+
+
+
+ } />
+
+
+ ,
);
```
@@ -351,23 +301,26 @@ const App = () => {
};
return (
-
+
+
+
+ } />
+
+
+
);
};
-render(
-
-
- ,
-);
+render( );
```
### breadcrumb
@@ -406,22 +359,24 @@ const PostList: React.FC = () => {
const App = () => {
return (
-
+
+
+
+ } />
+
+
+
);
};
-render(
-
-
- ,
-);
+render( );
```
> For more information, refer to the [`Breadcrumb` documentation →](/docs/ui-integrations/chakra-ui/components/breadcrumb)
@@ -458,22 +413,24 @@ const PostList: React.FC = () => {
const App = () => {
return (
-
+
+
+
+ } />
+
+
+
);
};
-render(
-
-
- ,
-);
+render( );
```
> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
@@ -510,22 +467,24 @@ const PostList: React.FC = () => {
const App = () => {
return (
-
+
+
+
+ } />
+
+
+
);
};
-render(
-
-
- ,
-);
+render( );
```
> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
@@ -562,22 +521,24 @@ const PostList: React.FC = () => {
const App = () => {
return (
-
+
+
+
+ } />
+
+
+
);
};
-render(
-
-
- ,
-);
+render( );
```
> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
@@ -625,22 +586,24 @@ const PostList: React.FC = () => {
const App = () => {
return (
-
+
+
+
+ } />
+
+
+
);
};
-render(
-
-
- ,
-);
+render( );
```
Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `createButtonProps` to utilize the default values of the [``][create-button] component.
@@ -678,22 +641,24 @@ const PostList: React.FC = () => {
const App = () => {
return (
-
+
+
+
+ } />
+
+
+
);
};
-render(
-
-
- ,
-);
+render( );
```
### headerButtonProps
@@ -734,22 +699,24 @@ const PostList: React.FC = () => {
const App = () => {
return (
-
+
+
+
+ } />
+
+
+
);
};
-render(
-
-
- ,
-);
+render( );
```
> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/basic-views/show/index.md b/documentation/docs/ui-integrations/chakra-ui/components/basic-views/show/index.md
index 1ae8b54fc603..81de6ea46a41 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/basic-views/show/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/basic-views/show/index.md
@@ -3,60 +3,17 @@ title: Show
swizzle: true
---
-```tsx live shared
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-
-const DummyListPage = () => (
-
- This page is empty.
-
- Show Item 123
-
-
-);
-
-interface ICategory {
- id: number;
- title: string;
-}
-
-interface IPost {
- id: number;
- title: string;
- content: string;
- status: "published" | "draft" | "rejected";
- category: { id: number };
-}
-```
-
-`` provides us a layout for displaying the page. It does not contain any logic and just adds extra functionalities like a refresh button or giving title to the page.
+`` provides us a layout for displaying the page. It does not contain any logic but adds extra functionalities like a refresh button.
We will show what `` does using properties with examples.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=420px hideCode
+```tsx live previewHeight=420px hideCode url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { useShow, useOne } from "@refinedev/core";
import { Show, MarkdownField } from "@refinedev/chakra-ui";
-import { Heading, Text, Spacer } from "@chakra-ui/react";
+import { Heading, Text } from "@chakra-ui/react";
const PostShow: React.FC = () => {
const { queryResult } = useShow();
@@ -65,9 +22,9 @@ const PostShow: React.FC = () => {
const { data: categoryData } = useOne({
resource: "categories",
- id: record?.category.id || "",
+ id: record?.category?.id || "",
queryOptions: {
- enabled: !!record?.category.id,
+ enabled: !!record?.category?.id,
},
});
@@ -83,11 +40,6 @@ const PostShow: React.FC = () => {
{record?.title}
-
- Status
-
- {record?.status}
-
Category
@@ -96,53 +48,48 @@ const PostShow: React.FC = () => {
Content
-
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-:::simple Good to know
-
-You can swizzle this component with the [**Refine CLI**](/docs/packages/list-of-packages) to customize it.
-
-:::
-
-## Properties
-
### title
-`title` allows the addition of titles inside the `` component. If you don't pass title props it uses the "Show" prefix and the singular resource name by default. For example, for the "posts" resource, it will be "Show post".
+`title` allows you to add a title inside the `` component. If you don't pass title props, it uses the "Show" prefix and the singular resource name by default. For example, for the "posts" resource, it will be "Show post".
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=420px hideCode
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
@@ -158,24 +105,33 @@ const PostShow: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -183,504 +139,340 @@ render(
The `` component reads the `resource` information from the route by default. If you want to use a custom resource for the `` component, you can use the `resource` prop.
-```tsx live url=http://localhost:3000/custom/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/custom/123
setInitialRoutes(["/custom/123"]);
-import { Refine } from "@refinedev/core";
-import { Layout } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
const CustomPage: React.FC = () => {
return (
/* highlight-next-line */
-
+
Rest of your page here
);
};
// visible-block-end
-const App: React.FC = () => {
- return (
- ,
- path: "/custom/:id",
- },
- ],
- // highlight-end
- }}
- Layout={Layout}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
-
render(
-
-
- ,
-);
-```
-
-If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
-
-> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
-
-### canDelete and canEdit
-
-`canDelete` and `canEdit` allows us to add the delete and edit buttons inside the `` component. If the resource has `canDelete` or `canEdit` property Refine adds the buttons by default.
-
-When clicked on, delete button executes the `useDelete` method provided by the [`dataProvider`](/docs/data/data-provider) and the edit button redirects the user to the record edit page.
-
-Refer to the [``](/docs/ui-integrations/chakra-ui/components/buttons/delete-button) and the [``](/docs/ui-integrations/chakra-ui/components/buttons/edit-button) documentation for detailed usage.
-
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=420px hideCode
-setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
-
-// visible-block-start
-import { Show } from "@refinedev/chakra-ui";
-import { usePermissions } from "@refinedev/core";
-
-const PostShow: React.FC = () => {
- const { data: permissionsData } = usePermissions();
-
- return (
-
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- return {
- data: {},
- };
- },
- };
-
- const authProvider = {
- login: async () => {
- return {
- success: true,
- redirectTo: "/",
- };
- },
- register: async () => {
- return {
- success: true,
- };
- },
- forgotPassword: async () => {
- return {
- success: true,
- };
- },
- updatePassword: async () => {
- return {
- success: true,
- };
- },
- logout: async () => {
- return {
- success: true,
- redirectTo: "/",
- };
- },
- check: async () => ({
- authenticated: true,
- }),
- onError: async (error) => {
- console.error(error);
- return { error };
- },
- getPermissions: async () => ["admin"],
- getIdentity: async () => null,
- };
-
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`usePermission` documentation →](/docs/authentication/hooks/use-permissions)
-
### recordItemId
-`` component reads the `id` information from the route by default. `recordItemId` is used when it cannot read from the URL (when used on a custom page, modal or drawer).
+The `` component reads the `id` information from the route by default. If you want to use a custom `id` value, you can use the `recordItemId` prop.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=350px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
-import { useModalForm } from "@refinedev/react-hook-form";
import { Show } from "@refinedev/chakra-ui";
-import {
- Modal,
- Button,
- ModalOverlay,
- ModalContent,
- ModalCloseButton,
- ModalHeader,
- ModalBody,
-} from "@chakra-ui/react";
const PostShow: React.FC = () => {
- const {
- modal: { visible, close, show },
- id,
- } = useModalForm({
- refineCoreProps: { action: "show" },
- });
-
return (
-
-
show()}>Edit Button
-
-
-
-
- Show
-
-
- {/* highlight-next-line */}
-
- Rest of your page here
-
-
-
-
-
+ /* highlight-next-line */
+
+ Rest of your page here
+
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
-);
-```
-
-:::simple Implementation Tips
-
-The `` component needs the `id` information for the `` to work properly.
-
-:::
-
-### dataProviderName
-
-If not specified, Refine will use the default data provider. If you have multiple data providers and want to use a different one, you can use the `dataProviderName` property.
-
-```tsx
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
-
-import { Show } from "@refinedev/chakra-ui";
-
-// highlight-start
-const PostShow = () => {
- return ... ;
-};
-// highlight-end
-
-export const App: React.FC = () => {
- return (
-
- {/* ... */}
-
- );
-};
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
+);
```
-### goBack
+### canEdit and editButtonProps
-To customize the back button or to disable it, you can use the `goBack` property. You can pass `false` or `null` to hide the back button.
+`canEdit` allows you to add an edit button inside the `` component. If the resource has the `canEdit` property, Refine adds the edit button by default. If you want to customize this button you can use the `editButtonProps` property.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
-setInitialRoutes(["/posts", "/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
+setInitialRoutes(["/posts/show/123"]);
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
-/* highlight-next-line */
-import { IconMoodSmile } from "@tabler/icons-react";
+import { usePermissions } from "@refinedev/core";
const PostShow: React.FC = () => {
+ const { data: permissionsData } = usePermissions();
return (
- /* highlight-next-line */
- }>
+
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ options={{
+ auth: {
+ getPermissions: () => Promise.resolve(["admin"]),
+ },
+ }}
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-### isLoading
+### canDelete and deleteButtonProps
-To toggle the loading state of the ` ` component, you can use the `isLoading` property.
+`canDelete` allows you to add a delete button inside the `` component. If the resource has the `canDelete` property, Refine adds the delete button by default. If you want to customize this button you can use the `deleteButtonProps` property.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
+import { usePermissions } from "@refinedev/core";
const PostShow: React.FC = () => {
+ const { data: permissionsData } = usePermissions();
return (
- /* highlight-next-line */
-
+
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ options={{
+ auth: {
+ getPermissions: () => Promise.resolve(["admin"]),
+ },
+ }}
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-### breadcrumb
+### goBack
-To customize or disable the breadcrumb, you can use the `breadcrumb` property. By default it uses the `Breadcrumb` component from `@refinedev/chakra-ui` package.
+To customize the back button or to disable it, you can use the `goBack` property.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
-import { Show, Breadcrumb } from "@refinedev/chakra-ui";
-import { Box } from "@chakra-ui/react";
-
-const CustomBreadcrumb: React.FC = () => {
- return (
-
-
-
- );
-};
+import { Show } from "@refinedev/chakra-ui";
+import { IconMoodSmile } from "@tabler/icons-react";
const PostShow: React.FC = () => {
return (
- }
- // highlight-end
- >
+ /* highlight-next-line */
+ }>
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Breadcrumb` documentation →](/docs/ui-integrations/chakra-ui/components/breadcrumb)
-
-### wrapperProps
+### isLoading
-If you want to customize the wrapper of the ` ` component, you can use the `wrapperProps` property. For `@refinedev/chakra-ui` wrapper element is ``s and `wrapperProps` can get every attribute that `` can get.
+To toggle the loading state of the ` ` component, you can use the `isLoading` property.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
const PostShow: React.FC = () => {
return (
-
+ /* highlight-next-line */
+
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI #8594](https://www.chakra-ui.com/docs/components/box#usage)
+### breadcrumb
-### headerProps
-
-If you want to customize the header of the ` ` component, you can use the `headerProps` property.
+To customize or disable the breadcrumb, you can use the `breadcrumb` property. By default it uses the `Breadcrumb` component from `@refinedev/chakra-ui` package.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
-import { Show } from "@refinedev/chakra-ui";
+import { Show, Breadcrumb } from "@refinedev/chakra-ui";
+import { Box } from "@chakra-ui/react";
const PostShow: React.FC = () => {
return (
+
+
+ }
// highlight-end
>
Rest of your page here
@@ -689,38 +481,42 @@ const PostShow: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
-### contentProps
+### headerProps
-If you want to customize the content of the ` ` component, you can use the `contentProps` property.
+If you want to customize the header of the ` ` component, you can use the `headerProps` property.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
@@ -729,11 +525,10 @@ const PostShow: React.FC = () => {
return (
@@ -743,54 +538,46 @@ const PostShow: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### headerButtons
-By default, the ` ` component has a [``][list-button], [``][edit-button], [``][delete-button], and a[``][refresh-button] at the header.
-
-You can customize the buttons at the header by using the `headerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons, deleteButtonProps, editButtonProps, listButtonProps, refreshButtonProps }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
-
-:::simple Implementation Tips
+You can customize the buttons at the header by using the `headerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons, editButtonProps, deleteButtonProps }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
-- If the "list" resource is not defined, the [``][list-button] will not render and `listButtonProps` will be `undefined`.
-
-- If [`canDelete`](#candelete-and-canedit) is `false`, the [``][delete-button] will not render and `deleteButtonProps` will be `undefined`.
-
-- If [`canEdit`](#candelete-and-canedit) is `false`, [``][edit-button] will not render and `editButtonProps` will be `undefined`.
-
-:::
-
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
-import { Button, HStack, Box } from "@chakra-ui/react";
+import { Button, HStack } from "@chakra-ui/react";
const PostShow: React.FC = () => {
return (
@@ -810,95 +597,33 @@ const PostShow: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
-
- ,
-);
-```
-
-Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `createButtonProps` to utilize the default values of the [``][list-button], [``][edit-button], [``][delete-button], and, [``][refresh-button] components.
-
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
-setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
-
-// visible-block-start
-import {
- Show,
- ListButton,
- EditButton,
- DeleteButton,
- RefreshButton,
-} from "@refinedev/chakra-ui";
-import { Button, HStack, Box } from "@chakra-ui/react";
-
-const PostShow: React.FC = () => {
- return (
- (
-
- {listButtonProps && (
-
- )}
- {editButtonProps && (
-
- )}
- {deleteButtonProps && (
-
- )}
-
- Custom Button
-
- )}
- // highlight-end
- >
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -906,11 +631,8 @@ render(
You can customize the wrapper element of the buttons at the header by using the `headerButtonProps` property.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
@@ -928,7 +650,7 @@ const PostShow: React.FC = () => {
}}
// highlight-end
headerButtons={
-
+
Custom Button
}
@@ -939,38 +661,42 @@ const PostShow: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
### footerButtons
You can customize the buttons at the footer by using the `footerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
@@ -996,24 +722,33 @@ const PostShow: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
@@ -1021,11 +756,8 @@ render(
You can customize the wrapper element of the buttons at the footer by using the `footerButtonProps` property.
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=280px
+```tsx live disableScroll previewHeight=280px url=http://localhost:3000/posts/show/123
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Show } from "@refinedev/chakra-ui";
@@ -1053,34 +785,41 @@ const PostShow: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+ This page is empty.
+
+ Show Post 123
+
+
+ }
+ />
+ } />
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Chakra UI →](https://www.chakra-ui.com/docs/components/box#usage)
-
## API Reference
-### Props
+### Properties
-
+
[list-button]: /docs/ui-integrations/chakra-ui/components/buttons/list-button
[refresh-button]: /docs/ui-integrations/chakra-ui/components/buttons/refresh-button
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/clone-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/clone-button/index.md
index 4e349fde50ae..4eaf7ff58cf8 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/clone-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/clone-button/index.md
@@ -3,35 +3,25 @@ title: Clone
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
+`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component. It uses the `clone` method from [useNavigation](/docs/routing/hooks/use-navigation) under the hood.
+
+:::simple Good to know
+You can swizzle this component to customize it with the [**Refine CLI**](/docs/packages/list-of-packages)
+
+:::
+
+```tsx live shared
const ClonePage = () => {
const { list } = RefineCore.useNavigation();
- const params = RefineCore.useRouterContext().useParams();
+ const params = RefineCore.useParsed();
return (
URL Parameters:
- {JSON.stringify(params)}
+ {JSON.stringify(params, null, 2)}
{
};
```
-`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component. It uses the `clone` method from [useNavigation](/docs/routing/hooks/use-navigation) under the hood.
-
-:::simple Good to know
-
-You can swizzle this component to customize it with the [**Refine CLI**](/docs/packages/list-of-packages)
-
-:::
-
## Usage
```tsx live url=http://localhost:3000 previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
-import routerProvider from "@refinedev/react-router-v6/legacy";
+
+//hide-start
+List.defaultProps = {
+ headerButtons: <>>,
+};
+//hide-end
// visible-block-start
import {
List,
- // highlight-next-line
+ //highlight-next-line
CloneButton,
} from "@refinedev/chakra-ui";
import {
@@ -97,9 +83,9 @@ const PostList: React.FC = () => {
accessorKey: "id",
cell: function render({ getValue }) {
return (
- // highlight-start
+ //highlight-start
- // highlight-end
+ //highlight-end
);
},
},
@@ -111,50 +97,35 @@ const PostList: React.FC = () => {
columns,
});
- //hide-start
- List.defaultProps = {
- headerButtons: <>>,
- };
- //hide-end
-
return (
-
-
+
+
{getHeaderGroups().map((headerGroup) => (
- {headerGroup.headers.map((header) => {
- return (
-
- {!header.isPlaceholder &&
- flexRender(
- header.column.columnDef.header,
- header.getContext(),
- )}
-
- );
- })}
+ {headerGroup.headers.map((header) => (
+
+ {!header.isPlaceholder &&
+ flexRender(
+ header.column.columnDef.header,
+ header.getContext(),
+ )}
+
+ ))}
))}
- {getRowModel().rows.map((row) => {
- return (
-
- {row.getVisibleCells().map((cell) => {
- return (
-
- {flexRender(
- cell.column.columnDef.cell,
- cell.getContext(),
- )}
-
- );
- })}
-
- );
- })}
+ {getRowModel().rows.map((row) => (
+
+ {row.getVisibleCells().map((cell) => (
+
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+
+ ))}
+
+ ))}
@@ -168,25 +139,34 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -197,35 +177,43 @@ render(
`recordItemId` is used to append the record id to the end of the route path.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { CloneButton } from "@refinedev/chakra-ui";
const MyCloneComponent = () => {
+ //highlight-next-line
return ;
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -242,46 +230,65 @@ Clicking the button will trigger the `clone` method of [`useNavigation`](/docs/r
`resource` is used to redirect the app to the `clone` action of the given resource name. By default, the app redirects to the inferred resource's `clone` action path.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { CloneButton } from "@refinedev/chakra-ui";
const MyCloneComponent = () => {
+ //highlight-next-line
return (
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+
+ }
+ />
+
+
+ ,
);
```
-Clicking the button will trigger the `clone` method of [`useNavigation`](/docs/routing/hooks/use-navigation) and then redirect the app to the `clone` action path of the resource, filling the necessary parameters in the route.
-
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
@@ -294,45 +301,52 @@ If the `clone` action route is defined by the pattern: `/posts/:authorId/clone/:
```tsx
const MyComponent = () => {
+ //highlight-next-line
return ;
};
```
### hideText
-`hideText` is used to show and not show the text of the button. When `true`, only the button icon is visible.
+It is used to show and not show the text of the button. When `true`, only the button icon is visible.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { CloneButton } from "@refinedev/chakra-ui";
const MyCloneComponent = () => {
- return ;
+ //highlight-next-line
+ return ;
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -344,6 +358,7 @@ The `accessControl` prop can be used to skip the access control check with its `
import { CloneButton } from "@refinedev/chakra-ui";
export const MyListComponent = () => {
+ //highlight-next-line
return (
);
@@ -359,3 +374,9 @@ Use `resource` prop instead.
### Properties
+
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/create-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/create-button/index.md
index 33e48f42eb6d..73a21f90d26c 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/create-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/create-button/index.md
@@ -3,48 +3,6 @@ title: Create
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-
-const CreatePage = () => {
- const { list } = RefineCore.useNavigation();
- const params = RefineCore.useRouterContext().useParams();
-
- return (
-
-
- URL Parameters:
-
- {JSON.stringify(params)}
-
- list("posts")}
- colorScheme="green"
- >
- Go back
-
-
- );
-};
-```
-
`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component. It uses the `create` method from [`useNavigation`](/docs/routing/hooks/use-navigation) under the hood. It can be useful to redirect the app to the create page route of resource.
:::simple Good to know
@@ -55,9 +13,8 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live previewHeight=360px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
import {
@@ -150,24 +107,53 @@ interface IPost {
}
// visible-block-end
-const App = () => {
+const CreatePage = () => {
+ const { list } = RefineCore.useNavigation();
+ const parsed = RefineCore.useParsed();
return (
-
+
+ URL Parameters:
+
+ {JSON.stringify(parsed, null, 2)}
+
+ list("posts")}
+ colorScheme="green"
+ >
+ Go back
+
+
+ );
+};
+
+render(
+
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -177,40 +163,69 @@ render(
`resource` is used to redirect the app to the `create` action path of the given resource name. By default, the app redirects to the inferred resource's `create` action path.
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+```tsx live previewHeight=160px
+setInitialRoutes(["/categories"]);
// visible-block-start
import { CreateButton } from "@refinedev/chakra-ui";
const MyCreateComponent = () => {
- return ;
+ return ;
};
// visible-block-end
-const App = () => {
+const CategoryCreate = () => {
+ const { list } = RefineCore.useNavigation();
+ const parsed = RefineCore.useParsed();
return (
-
+
+ URL Parameters:
+
+ {JSON.stringify(parsed, null, 2)}
+
+ list("categories")}
+ colorScheme="green"
+ >
+ Go back
+
+
+ );
+};
+
+render(
+
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -218,7 +233,7 @@ Clicking the button will trigger the `create` method of [`useNavigation`](/docs/
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
-> For more information, refer to the [`identifier` of the ` ` component documentation →](/docs/core/refine-component#identifier)
+> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
### meta
@@ -234,52 +249,89 @@ const MyComponent = () => {
### hideText
-`hideText` is used to show and not show the text of the button. When `true`, only the button icon is visible.
-
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
+It is used to show and not show the text of the button. When `true`, only the button icon is visible.
-import { Refine } from "@refinedev/core";
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { CreateButton } from "@refinedev/chakra-ui";
const MyCreateComponent = () => {
- return ;
+ return (
+
+ );
};
// visible-block-end
-const App = () => {
+const CreatePage = () => {
+ const { list } = RefineCore.useNavigation();
+ const parsed = RefineCore.useParsed();
return (
-
+
+ URL Parameters:
+
+ {JSON.stringify(parsed, null, 2)}
+
+ list("posts")}
+ colorScheme="green"
+ >
+ Go back
+
+
+ );
+};
+
+render(
+
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
### accessControl
-The `accessControl` prop can be used to skip the access control check with its `enabled` property or to hide the button when the user does not have the permission to access the resource with `hideIfUnauthorized` property. This is relevant only when an [`accessControlProvider`](/docs/authorization/access-control-provider) is provided to [` `](/docs/core/refine-component)
+This prop can be used to skip access control check with its `enabled` property or to hide the button when the user does not have the permission to access the resource with `hideIfUnauthorized` property. This is relevant only when an [`accessControlProvider`](/docs/authorization/access-control-provider) is provided to [` `](/docs/core/refine-component)
```tsx
import { CreateButton } from "@refinedev/chakra-ui";
export const MyListComponent = () => {
return (
-
+
);
};
```
@@ -292,4 +344,10 @@ Use `resource` prop instead.
### Properties
-
+
+
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/delete-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/delete-button/index.md
index 1a9c04a76163..8e29da9a29c2 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/delete-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/delete-button/index.md
@@ -3,24 +3,6 @@ title: Delete
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) and [``](https://www.chakra-ui.com/docs/components/popover#usage) components.
When you try to delete something, a pop-up shows up and asks for confirmation. When confirmed it executes the [`useDelete`](/docs/data/hooks/use-delete) method provided by your [`dataProvider`](/docs/data/data-provider).
@@ -32,10 +14,8 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live previewHeight=360px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import {
@@ -139,24 +119,30 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -164,119 +150,101 @@ render(
### recordItemId
-`recordItemId` allows us to manage which record will be deleted. By default, it will be read from the URL.
+`recordItemId` allows us to manage which record will be deleted. By default, the `recordItemId` is inferred from the route params.
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
+```tsx live previewHeight=160px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { DeleteButton } from "@refinedev/chakra-ui";
const MyDeleteComponent = () => {
- return ;
+ return (
+
+ );
};
// visible-block-end
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- await new Promise((resolve) => setTimeout(resolve, 500));
-
- return {
- data: {},
- };
- },
- };
-
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
-Clicking the button will trigger the [`useDelete`](/docs/data/hooks/use-delete) method and then the record whose resource is "post" and whose id is "123" gets deleted.
+Clicking the button will trigger the [`useDelete`](/docs/data/hooks/use-delete) method and then the record whose resource is "posts" and whose id is "123" will be deleted.
### resource
-`resource` allows us to manage which resource's record is going to be deleted. By default, it will be read from the URL.
+`resource` allows us to manage which resource's record is going to be deleted. By default, the `resource` is inferred from the route params.
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
+```tsx live previewHeight=160px
+setInitialRoutes(["/categories"]);
// visible-block-start
import { DeleteButton } from "@refinedev/chakra-ui";
const MyDeleteComponent = () => {
- return ;
+ return ;
};
// visible-block-end
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- await new Promise((resolve) => setTimeout(resolve, 500));
-
- return {
- data: {},
- };
- },
- };
-
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
-Clicking the button will trigger the [`useDelete`](/docs/data/hooks/use-delete) method and then the record whose resource is "categories" and whose id is "2" gets deleted.
+Clicking the button will trigger the [`useDelete`](/docs/data/hooks/use-delete) method and then the record whose resource is "categories" and whose id is "123" will be deleted.
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
@@ -284,14 +252,12 @@ If you have multiple resources with the same name, you can pass the `identifier`
### onSuccess
-`onSuccess` can be used if you want to do anything based on the result returned after the delete request.
+`onSuccess` can be used if you want to do something based on the results returned after the delete request.
For example, let's `console.log` after deletion:
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
+```tsx live previewHeight=160px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { DeleteButton } from "@refinedev/chakra-ui";
@@ -299,7 +265,7 @@ import { DeleteButton } from "@refinedev/chakra-ui";
const MyDeleteComponent = () => {
return (
{
console.log(value);
@@ -309,164 +275,95 @@ const MyDeleteComponent = () => {
};
// visible-block-end
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- await new Promise((resolve) => setTimeout(resolve, 500));
-
- return {
- message: "You have successfully deleted the record",
- };
- },
- };
-
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
-### mutationMode
+### hideText
-Determines which mode mutation will have while executing ``.
+It is used to show and not show the text of the button. When `true`, only the button icon is visible.
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
+```tsx live previewHeight=160px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { DeleteButton } from "@refinedev/chakra-ui";
const MyDeleteComponent = () => {
- return ;
-};
-// visible-block-end
-
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- await new Promise((resolve) => setTimeout(resolve, 500));
-
- return {
- data: {},
- };
- },
- };
-
return (
-
);
};
-
-render(
-
-
- ,
-);
-```
-
-> For more information, refer to the [mutation mode docsumentation →](/advanced-tutorials/mutation-mode.md)
-
-### hideText
-
-`hideText` is used to show and not show the text of the button. When `true`, only the button icon is visible.
-
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
-
-// visible-block-start
-import { DeleteButton } from "@refinedev/chakra-ui";
-
-const MyDeleteComponent = () => {
- return ;
-};
// visible-block-end
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- await new Promise((resolve) => setTimeout(resolve, 500));
-
- return {
- data: {},
- };
- },
- };
-
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
### accessControl
-The `accessControl` prop can be used to skip the access control check with its `enabled` property or to hide the button when the user does not have the permission to access the resource with `hideIfUnauthorized` property. This is relevant only when an [`accessControlProvider`](/docs/authorization/access-control-provider) is provided to [` `](/docs/core/refine-component)
+This prop can be used to skip access control check with its `enabled` property or to hide the button when the user does not have the permission to access the resource with `hideIfUnauthorized` property. This is relevant only when an [`accessControlProvider`](/docs/authorization/access-control-provider) is provided to [` `](/docs/core/refine-component)
```tsx
import { DeleteButton } from "@refinedev/chakra-ui";
export const MyListComponent = () => {
return (
-
+
);
};
```
@@ -475,72 +372,14 @@ export const MyListComponent = () => {
Use `resource` prop instead.
-## How to override confirm texts?
-
-You can change the text that appears when you confirm a transaction with `confirmTitle` prop, as well as what 'ok' and 'cancel' buttons text look like with the `confirmOkText` and `confirmCancelText` props.
-
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
-
-// visible-block-start
-import { DeleteButton } from "@refinedev/chakra-ui";
-
-const MyDeleteComponent = () => {
- return (
-
- );
-};
-// visible-block-end
-
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- console.log("girdi");
- await new Promise((resolve) => setTimeout(resolve, 500));
-
- return {
- data: {},
- };
- },
- };
-
- return (
-
- );
-};
-
-render(
-
-
- ,
-);
-```
-
## API Reference
### Properties
+
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/edit-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/edit-button/index.md
index 46fb3fdb69c9..73b0056e17ed 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/edit-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/edit-button/index.md
@@ -3,48 +3,6 @@ title: Edit
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-
-const EditPage = () => {
- const { list } = RefineCore.useNavigation();
- const params = RefineCore.useRouterContext().useParams();
-
- return (
-
-
- URL Parameters:
-
- {JSON.stringify(params)}
-
- list("posts")}
- colorScheme="green"
- >
- Go back
-
-
- );
-};
-```
-
`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component. It uses the `edit` method from [`useNavigation`](/docs/routing/hooks/use-navigation) under the hood. It can be useful when redirecting the app to the edit page with the record id route of resource.
:::simple Good to know
@@ -55,14 +13,12 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live previewHeight=360px hideCode
setInitialRoutes(["/posts"]);
-import { Refine, useNavigation, useRouterContext } from "@refinedev/core";
// visible-block-start
import {
List,
-
// highlight-next-line
EditButton,
} from "@refinedev/chakra-ui";
@@ -107,11 +63,7 @@ const PostList: React.FC = () => {
[],
);
- const {
- getHeaderGroups,
- getRowModel,
- refineCore: { setCurrent, pageCount, current },
- } = useTable({
+ const { getHeaderGroups, getRowModel } = useTable({
columns,
});
@@ -166,24 +118,53 @@ interface IPost {
}
// visible-block-end
-const App = () => {
+const EditPage = () => {
+ const { list } = RefineCore.useNavigation();
+ const parsed = RefineCore.useParsed();
return (
-
+
+ URL Parameters:
+
+ {JSON.stringify(parsed, null, 2)}
+
+ list("posts")}
+ colorScheme="green"
+ >
+ Go back
+
+
+ );
+};
+
+render(
+
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -193,80 +174,134 @@ render(
`recordItemId` is used to append the record id to the end of the route path.
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+```tsx live previewHeight=160px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { EditButton } from "@refinedev/chakra-ui";
const MyEditComponent = () => {
- return ;
+ return ;
};
// visible-block-end
-const App = () => {
+const EditPage = () => {
+ const { list } = RefineCore.useNavigation();
+ const parsed = RefineCore.useParsed();
return (
-
+
+ URL Parameters:
+
+ {JSON.stringify(parsed, null, 2)}
+
+ list("posts")}
+ colorScheme="green"
+ >
+ Go back
+
+
+ );
+};
+
+render(
+
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
### resource
-Redirection endpoint is defined by the `resource` property and its `edit` action path. By default, `` uses the inferred resource from the route.
-
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
+`resource` is used to redirect the app to the `edit` action path of the given resource name. By default, the app redirects to the inferred resource's `edit` action path.
-import { Refine } from "@refinedev/core";
+```tsx live previewHeight=160px
+setInitialRoutes(["/categories"]);
// visible-block-start
import { EditButton } from "@refinedev/chakra-ui";
const MyEditComponent = () => {
- return (
-
- );
+ return ;
};
// visible-block-end
-const App = () => {
+const CategoryEdit = () => {
+ const { list } = RefineCore.useNavigation();
+ const parsed = RefineCore.useParsed();
return (
-
+
+ URL Parameters:
+
+ {JSON.stringify(parsed, null, 2)}
+
+ list("categories")}
+ colorScheme="green"
+ >
+ Go back
+
+
+ );
+};
+
+render(
+
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
@@ -274,7 +309,7 @@ Clicking the button will trigger the `edit` method of [`useNavigation`](/docs/ro
If you have multiple resources with the same name, you can pass the `identifier` instead of the `name` of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the `name` of the resource defined in the ` ` component.
-> For more information, refer to the [`identifier` of the ` ` component documentation →](/docs/core/refine-component#identifier)
+> For more information, refer to the [`identifier` section of the ` ` component documentation →](/docs/core/refine-component#identifier)
### meta
@@ -292,50 +327,88 @@ const MyComponent = () => {
It is used to show and not show the text of the button. When `true`, only the button icon is visible.
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+```tsx live previewHeight=160px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { EditButton } from "@refinedev/chakra-ui";
const MyEditComponent = () => {
- return ;
+ return (
+
+ );
};
// visible-block-end
-const App = () => {
+const EditPage = () => {
+ const { list } = RefineCore.useNavigation();
+ const parsed = RefineCore.useParsed();
return (
-
+
+ URL Parameters:
+
+ {JSON.stringify(parsed, null, 2)}
+
+ list("posts")}
+ colorScheme="green"
+ >
+ Go back
+
+
+ );
+};
+
+render(
+
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+ } />
+
+
+
+ ,
);
```
### accessControl
-The `accessControl` prop can be used to skip the access control check with its `enabled` property or to hide the button when the user does not have the permission to access the resource with `hideIfUnauthorized` property. This is relevant only when an [`accessControlProvider`](/docs/authorization/access-control-provider) is provided to [` `](/docs/core/refine-component)
+This prop can be used to skip access control check with its `enabled` property or to hide the button when the user does not have the permission to access the resource with `hideIfUnauthorized` property. This is relevant only when an [`accessControlProvider`](/docs/authorization/access-control-provider) is provided to [` `](/docs/core/refine-component)
```tsx
import { EditButton } from "@refinedev/chakra-ui";
export const MyListComponent = () => {
return (
-
+
);
};
```
@@ -349,3 +422,9 @@ Use `resource` prop instead.
### Properties
+
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/export-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/export-button/index.md
index df661a102173..cbd630c50d08 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/export-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/export-button/index.md
@@ -3,40 +3,14 @@ title: Export
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
`` is an Chakra UI [``](https://www.chakra-ui.com/docs/components/button#usage) with a default export icon and a default text with "Export". It only has presentational value.
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live previewHeight=360px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
-//highlight-next-line
import { useExport } from "@refinedev/core";
-import {
- List,
- //highlight-next-line
- ExportButton,
-} from "@refinedev/chakra-ui";
+import { List, ExportButton } from "@refinedev/chakra-ui";
import {
TableContainer,
Table,
@@ -45,6 +19,8 @@ import {
Th,
Tbody,
Td,
+ Box,
+ Text,
} from "@chakra-ui/react";
import { useTable } from "@refinedev/react-table";
import { ColumnDef, flexRender } from "@tanstack/react-table";
@@ -66,15 +42,10 @@ const PostList: React.FC = () => {
[],
);
- const {
- getHeaderGroups,
- getRowModel,
- refineCore: { setCurrent, pageCount, current },
- } = useTable({
+ const { getHeaderGroups, getRowModel } = useTable({
columns,
});
- //highlight-start
const { triggerExport, isLoading: exportLoading } = useExport({
mapData: (item) => {
return {
@@ -85,22 +56,20 @@ const PostList: React.FC = () => {
pageSize: 10,
maxItemCount: 50,
});
- //highlight-end
return (
}
>
-
-
-
- {getHeaderGroups().map((headerGroup) => (
-
- {headerGroup.headers.map((header) => {
- return (
+
+
+
+
+ {getHeaderGroups().map((headerGroup) => (
+
+ {headerGroup.headers.map((header) => (
{!header.isPlaceholder &&
flexRender(
@@ -108,31 +77,27 @@ const PostList: React.FC = () => {
header.getContext(),
)}
- );
- })}
-
- ))}
-
-
- {getRowModel().rows.map((row) => {
- return (
+ ))}
+
+ ))}
+
+
+ {getRowModel().rows.map((row) => (
- {row.getVisibleCells().map((cell) => {
- return (
-
- {flexRender(
- cell.column.columnDef.cell,
- cell.getContext(),
- )}
-
- );
- })}
+ {row.getVisibleCells().map((cell) => (
+
+ {flexRender(
+ cell.column.columnDef.cell,
+ cell.getContext(),
+ )}
+
+ ))}
- );
- })}
-
-
-
+ ))}
+
+
+
+
);
};
@@ -143,23 +108,30 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -171,40 +143,120 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Properties
-### hideText
-
-`hideText` is used to show and not show the text of the button. When `true`, only the button icon is visible.
+### `hideText`
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
+It is used to show and hide the text of the button. When `true`, only the button icon is shown.
-import { Refine } from "@refinedev/core";
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ExportButton } from "@refinedev/chakra-ui";
+import { useExport } from "@refinedev/core";
const MyExportComponent = () => {
- return ;
+ const { triggerExport, isLoading } = useExport({
+ mapData: (item) => {
+ return {
+ id: item.id,
+ title: item.title,
+ };
+ },
+ });
+
+ return (
+
+ );
};
// visible-block-end
-const App = () => {
- return (
-
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
+);
+```
+
+### `loading`
+
+It is used to show a loading state on the button when the export process is in progress.
+
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
+
+// visible-block-start
+import { ExportButton } from "@refinedev/chakra-ui";
+import { useExport } from "@refinedev/core";
+
+const MyExportComponent = () => {
+ const { triggerExport, isLoading } = useExport({
+ mapData: (item) => {
+ return {
+ id: item.id,
+ title: item.title,
+ };
+ },
+ });
+
+ return (
+
);
};
+// visible-block-end
render(
-
-
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -213,3 +265,9 @@ render(
### Properties
+
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/import-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/import-button/index.md
index a3868027af5b..5d3c3496ba47 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/import-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/import-button/index.md
@@ -3,42 +3,16 @@ title: Import
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
`` is compatible with the [`useImport`][useimport] hook and is meant to be used as it's upload button.
It uses Chakra UI's [``][button] component and native html [` `][input] element. It wraps a [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label) with a [``][button] component and [` `][input] element and accepts its own properties separately.
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live previewHeight=360px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
-//highlight-next-line
import { useImport, useNotification } from "@refinedev/core";
-import {
- List,
- //highlight-next-line
- ImportButton,
-} from "@refinedev/chakra-ui";
+import { List, ImportButton } from "@refinedev/chakra-ui";
import {
TableContainer,
Table,
@@ -47,6 +21,8 @@ import {
Th,
Tbody,
Td,
+ Box,
+ Text,
} from "@chakra-ui/react";
import { useTable } from "@refinedev/react-table";
import { ColumnDef, flexRender } from "@tanstack/react-table";
@@ -68,15 +44,10 @@ const PostList: React.FC = () => {
[],
);
- const {
- getHeaderGroups,
- getRowModel,
- refineCore: { setCurrent, pageCount, current },
- } = useTable({
+ const { getHeaderGroups, getRowModel } = useTable({
columns,
});
- //highlight-start
const { open } = useNotification();
const { inputProps, isLoading } = useImport({
@@ -87,22 +58,20 @@ const PostList: React.FC = () => {
});
},
});
- //highlight-end
return (
}
>
-
-
-
- {getHeaderGroups().map((headerGroup) => (
-
- {headerGroup.headers.map((header) => {
- return (
+
+
+
+
+ {getHeaderGroups().map((headerGroup) => (
+
+ {headerGroup.headers.map((header) => (
{!header.isPlaceholder &&
flexRender(
@@ -110,31 +79,47 @@ const PostList: React.FC = () => {
header.getContext(),
)}
- );
- })}
-
- ))}
-
-
- {getRowModel().rows.map((row) => {
- return (
+ ))}
+
+ ))}
+
+
+ {getRowModel().rows.map((row) => (
- {row.getVisibleCells().map((cell) => {
- return (
-
- {flexRender(
- cell.column.columnDef.cell,
- cell.getContext(),
- )}
-
- );
- })}
+ {row.getVisibleCells().map((cell) => (
+
+ {flexRender(
+ cell.column.columnDef.cell,
+ cell.getContext(),
+ )}
+
+ ))}
- );
- })}
-
-
-
+ ))}
+
+
+
+
+
+ ✨ Live Preview
+
+
);
};
@@ -145,23 +130,30 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -173,40 +165,114 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Properties
-### hideText
+### `hideText`
`hideText` is used to show and not show the text of the button. When `true`, only the button icon is visible.
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ImportButton } from "@refinedev/chakra-ui";
+import { useImport } from "@refinedev/core";
const MyImportComponent = () => {
- return ;
+ const { inputProps, isLoading } = useImport({
+ onFinish: () => {
+ console.log("Import completed");
+ },
+ });
+
+ return (
+
+ );
};
// visible-block-end
-const App = () => {
- return (
-
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
+);
+```
+
+### `loading`
+
+It is used to show a loading state on the button when the import process is in progress.
+
+```tsx live previewHeight=120px
+setInitialRoutes(["/posts"]);
+
+// visible-block-start
+import { ImportButton } from "@refinedev/chakra-ui";
+import { useImport } from "@refinedev/core";
+
+const MyImportComponent = () => {
+ const { inputProps, isLoading } = useImport({
+ onFinish: () => {
+ console.log("Import completed");
+ },
+ });
+
+ return (
+
);
};
+// visible-block-end
render(
-
-
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -216,6 +282,12 @@ render(
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
+
[useimport]: /docs/core/hooks/utilities/use-import
[button]: https://www.chakra-ui.com/docs/components/button#usage
[input]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/list-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/list-button/index.md
index 70b8e57839fb..9a18a06c2a4f 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/list-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/list-button/index.md
@@ -3,26 +3,6 @@ title: List
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
`` is using Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component. It uses the `list` method from [`useNavigation`](/docs/routing/hooks/use-navigation) under the hood. It can be useful when redirecting the app to the list page route of resource.
:::simple Good to know
@@ -33,9 +13,10 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=420px hideCode
+```tsx live url=http://localhost:3000/posts/show/123 previewHeight=360px hideCode
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
+
+import { VStack } from "@chakra-ui/react";
import { ShowButton } from "@refinedev/chakra-ui";
// visible-block-start
@@ -43,7 +24,7 @@ import { useShow } from "@refinedev/core";
import {
Show,
MarkdownField,
- //highlight-next-line
+ // highlight-next-line
ListButton,
} from "@refinedev/chakra-ui";
import { Heading, Text, Spacer } from "@chakra-ui/react";
@@ -54,8 +35,11 @@ const PostShow: React.FC = () => {
const record = data?.data;
return (
- // highlight-next-line
- } isLoading={isLoading}>
+ }
+ isLoading={isLoading}
+ >
Id
@@ -74,33 +58,50 @@ const PostShow: React.FC = () => {
);
};
+
+interface IPost {
+ id: number;
+ title: string;
+ content: string;
+}
// visible-block-end
-const App = () => {
- return (
-
+ (
-
- This page is empty.
-
- Show Item 123
-
-
- ),
+ list: "/posts",
+ show: "/posts/show/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This is the list page of posts.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -113,8 +114,10 @@ The button text is defined automatically by Refine, based on the `resource` defi
Redirection endpoint is defined by the `resource`'s `list` action path. By default, `` uses the inferred resource from the route.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/categories/show/123"]);
+
+import { VStack, Text } from "@chakra-ui/react";
+import { ShowButton } from "@refinedev/chakra-ui";
// visible-block-start
import { ListButton } from "@refinedev/chakra-ui";
@@ -124,49 +127,57 @@ const MyListComponent = () => {
};
// visible-block-end
-const ListPage = () => {
- const { list } = RefineCore.useNavigation();
- const params = RefineCore.useRouterContext().useParams();
-
- return (
-
-
- URL Parameters:
-
- {JSON.stringify(params)}
-
- list("posts")}
- colorScheme="green"
- >
- Go back
-
-
- );
-};
-
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This is the list page of categories.
+
+ Go back
+
+
+ }
+ />
+ }
+ />
+
+
+
+ ,
);
```
@@ -192,10 +203,8 @@ const MyComponent = () => {
It is used to show and not show the text of the button. When `true`, only the button icon is visible.
-```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+```tsx live url=http://localhost:3000 previewHeight=120px
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ListButton } from "@refinedev/chakra-ui";
@@ -205,23 +214,30 @@ const MyListComponent = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -248,3 +264,9 @@ Use `resource` prop instead.
### Properties
+
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/refresh-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/refresh-button/index.md
index 2f0db52e83a5..fc1491980794 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/refresh-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/refresh-button/index.md
@@ -3,26 +3,6 @@ title: Refresh
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component to update the data shown on the page via the [`useInvalidate`][use-invalidate] hook.
:::simple Good to know
@@ -33,9 +13,10 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
## Usage
-```tsx live url=http://localhost:3000/posts/show/123 previewHeight=420px hideCode
+```tsx live url=http://localhost:3000/posts/show/123 previewHeight=360px hideCode
setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
+
+import { VStack } from "@chakra-ui/react";
import { ShowButton } from "@refinedev/chakra-ui";
// visible-block-start
@@ -54,7 +35,7 @@ const PostShow: React.FC = () => {
const record = data?.data;
return (
- // highlight-next-line
+ //highlight-next-line
} isLoading={isLoading}>
Id
@@ -74,33 +55,50 @@ const PostShow: React.FC = () => {
);
};
+
+interface IPost {
+ id: number;
+ title: string;
+ content: string;
+}
// visible-block-end
-const App = () => {
- return (
-
+ (
-
- This page is empty.
-
- Show Item 123
-
-
- ),
+ list: "/posts",
+ show: "/posts/show/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -111,34 +109,44 @@ render(
`recordItemId` allows us to manage which data is going to be refreshed. By default it will read the id information from the route.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { RefreshButton } from "@refinedev/chakra-ui";
const MyRefreshComponent = () => {
- return ;
+ //highlight-next-line
+ return (
+
+ );
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -149,37 +157,49 @@ Clicking the button will trigger the [`useInvalidate`][use-invalidate] hook and
`resource` allows us to manage which resource is going to be refreshed. By default it will read the id information from the route.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { RefreshButton } from "@refinedev/chakra-ui";
const MyRefreshComponent = () => {
+ //highlight-next-line
return (
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -194,35 +214,41 @@ If you have multiple resources with the same name, you can pass the `identifier`
`hideText` is used to show and not show the text of the button. When `true`, only the button icon is visible.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { RefreshButton } from "@refinedev/chakra-ui";
const MyRefreshComponent = () => {
+ //highlight-next-line
return ;
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -236,4 +262,10 @@ Use `resource` prop instead.
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
+
[use-invalidate]: /docs/data/hooks/use-invalidate
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/save-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/save-button/index.md
index f3d2b35ac510..5077a7640548 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/save-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/save-button/index.md
@@ -3,27 +3,7 @@ title: Save
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
-`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component. It uses it for presantation purposes only. Some of the hooks that Refine has adds features to this button.
+`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component. It uses it for presentation purposes only. Some of the hooks that Refine has adds features to this button.
:::simple Good to know
@@ -37,7 +17,7 @@ For example, lets add logic to the `` component with the `saveButton
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=420px hideCode
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
+
import { EditButton } from "@refinedev/chakra-ui";
// visible-block-start
@@ -48,6 +28,8 @@ import {
FormLabel,
Input,
Select,
+ VStack,
+ Text,
} from "@chakra-ui/react";
import { useSelect } from "@refinedev/core";
import { useForm } from "@refinedev/react-hook-form";
@@ -55,7 +37,7 @@ import { useForm } from "@refinedev/react-hook-form";
const PostEdit: React.FC = () => {
const {
refineCore: { formLoading, query },
- // highlight-next-line
+ //highlight-next-line
saveButtonProps,
register,
formState: { errors },
@@ -73,7 +55,7 @@ const PostEdit: React.FC = () => {
}, [options]);
return (
- // highlight-next-line
+ //highlight-next-line
Title
@@ -119,34 +101,6 @@ const PostEdit: React.FC = () => {
);
};
-// visible-block-end
-
-const App = () => {
- return (
- (
-
- This page is empty.
-
- Edit Item 123
-
-
- ),
- },
- ]}
- />
- );
-};
-render(
-
-
- ,
-);
interface ICategory {
id: number;
@@ -159,6 +113,47 @@ interface IPost {
status: "published" | "draft" | "rejected";
category: { id: number };
}
+// visible-block-end
+
+render(
+
+
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
+);
```
## Properties
@@ -168,35 +163,41 @@ interface IPost {
`hideText` is used to show and not show the text of the button. When `true`, only the button icon is visible.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { SaveButton } from "@refinedev/chakra-ui";
const MySaveComponent = () => {
+ //highlight-next-line
return ;
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -205,3 +206,9 @@ render(
### Properties
+
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/buttons/show-button/index.md b/documentation/docs/ui-integrations/chakra-ui/components/buttons/show-button/index.md
index eb7c432fa2d9..0f2fdf5d065a 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/buttons/show-button/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/buttons/show-button/index.md
@@ -3,48 +3,6 @@ title: Show
swizzle: true
---
-```tsx live shared
-const { default: sharedRouterProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: sharedRouterProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
- catchAll: ,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-
-const ShowPage = () => {
- const { list } = RefineCore.useNavigation();
- const params = RefineCore.useRouterContext().useParams();
-
- return (
-
-
- URL Parameters:
-
- {JSON.stringify(params)}
-
- list("posts")}
- colorScheme="green"
- >
- Go back
-
-
- );
-};
-```
-
`` uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/button#usage) component. It uses the `show` method from [`useNavigation`](/docs/routing/hooks/use-navigation) under the hood. It can be useful when redirecting the app to the show page with the record id route of resource.
:::simple Good to know
@@ -57,13 +15,11 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
```tsx live url=http://localhost:3000 previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
import {
List,
-
- // highlight-next-line
+ //highlight-next-line
ShowButton,
} from "@refinedev/chakra-ui";
import {
@@ -97,9 +53,12 @@ const PostList: React.FC = () => {
accessorKey: "id",
cell: function render({ getValue }) {
return (
- // highlight-start
-
- // highlight-end
+ //highlight-start
+
+ //highlight-end
);
},
},
@@ -111,50 +70,35 @@ const PostList: React.FC = () => {
columns,
});
- //hide-start
- List.defaultProps = {
- headerButtons: <>>,
- };
- //hide-end
-
return (
-
-
+
+
{getHeaderGroups().map((headerGroup) => (
- {headerGroup.headers.map((header) => {
- return (
-
- {!header.isPlaceholder &&
- flexRender(
- header.column.columnDef.header,
- header.getContext(),
- )}
-
- );
- })}
+ {headerGroup.headers.map((header) => (
+
+ {!header.isPlaceholder &&
+ flexRender(
+ header.column.columnDef.header,
+ header.getContext(),
+ )}
+
+ ))}
))}
- {getRowModel().rows.map((row) => {
- return (
-
- {row.getVisibleCells().map((cell) => {
- return (
-
- {flexRender(
- cell.column.columnDef.cell,
- cell.getContext(),
- )}
-
- );
- })}
-
- );
- })}
+ {getRowModel().rows.map((row) => (
+
+ {row.getVisibleCells().map((cell) => (
+
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+
+ ))}
+
+ ))}
@@ -168,24 +112,33 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -196,35 +149,42 @@ render(
`recordItemId` is used to append the record id to the end of the route path. By default it will read the id information from the route.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ShowButton } from "@refinedev/chakra-ui";
const MyShowComponent = () => {
+ //highlight-next-line
return ;
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -235,41 +195,50 @@ Clicking the button will trigger the `show` method of [`useNavigation`](/docs/ro
Redirection endpoint is defined by the `resource`'s `show` action path. By default, `` uses the inferred resource from the route.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ShowButton } from "@refinedev/chakra-ui";
const MyShowComponent = () => {
+ //highlight-next-line
return (
);
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -287,6 +256,7 @@ If the `show` action route is defined by the pattern: `/posts/:authorId/show/:id
```tsx
const MyComponent = () => {
+ //highlight-next-line
return ;
};
```
@@ -296,36 +266,42 @@ const MyComponent = () => {
It is used to show and not show the text of the button. When `true`, only the button icon is visible.
```tsx live url=http://localhost:3000 previewHeight=200px
-setInitialRoutes(["/"]);
-
-import { Refine } from "@refinedev/core";
+setInitialRoutes(["/posts"]);
// visible-block-start
import { ShowButton } from "@refinedev/chakra-ui";
const MyShowComponent = () => {
- return ;
+ //highlight-next-line
+ return ;
};
// visible-block-end
-const App = () => {
- return (
-
+
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
@@ -337,6 +313,7 @@ The `accessControl` prop can be used to skip the access control check with its `
import { ShowButton } from "@refinedev/chakra-ui";
export const MyListComponent = () => {
+ //highlight-next-line
return (
);
@@ -352,3 +329,9 @@ Use `resource` prop instead.
### Properties
+
+:::simple External Props
+
+It also accepts all props of Chakra UI [Button](https://chakra-ui.com/docs/components/button#props).
+
+:::
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/boolean-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/boolean-field/index.md
index c592483e3e7d..31efef63d04b 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/boolean-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/boolean-field/index.md
@@ -4,15 +4,6 @@ swizzle: true
---
```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
const Wrapper = ({ children }) => {
return (
@@ -36,8 +27,6 @@ Let's see how we can use `` with the example in the post list.
```tsx live url=http://localhost:3000/posts previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import {
@@ -144,23 +133,31 @@ const PostList: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+
,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/date-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/date-field/index.md
index 564e2f2f0ed2..f12290ab7076 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/date-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/date-field/index.md
@@ -4,15 +4,6 @@ swizzle: true
---
```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
const Wrapper = ({ children }) => {
return (
@@ -36,8 +27,6 @@ Let's see how we can use `` with the example in the post list.
```tsx live url=http://localhost:3000/posts previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import {
@@ -135,23 +124,31 @@ const PostList: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
- );
-};
render(
-
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+
,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/email-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/email-field/index.md
index 41443138b4f8..4a4fcf276fc0 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/email-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/email-field/index.md
@@ -4,15 +4,6 @@ swizzle: true
---
```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
const Wrapper = ({ children }) => {
return (
@@ -36,7 +27,6 @@ Let's see how we can use `` with the example in the user list.
```tsx live url=http://localhost:3000/users previewHeight=420px hideCode
setInitialRoutes(["/users"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
import {
@@ -146,18 +136,31 @@ interface IUser {
}
// visible-block-end
-const App = () => {
- return (
-
- );
-};
-
render(
-
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+
,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/file-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/file-field/index.md
index 1450ca9c1d80..1d20356168d5 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/file-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/file-field/index.md
@@ -4,15 +4,6 @@ swizzle: true
---
```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
const Wrapper = ({ children }) => {
return (
@@ -34,9 +25,8 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` with the example in the list page.
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live url=http://localhost:3000/posts previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
import {
@@ -140,18 +130,31 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
- );
-};
-
render(
-
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+
,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/markdown-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/markdown-field/index.md
index 604515c5142c..e58b20bcea8b 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/markdown-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/markdown-field/index.md
@@ -3,25 +3,6 @@ title: Markdown
swizzle: true
---
-```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
This field lets you display markdown content. It supports [GitHub Flavored Markdown](https://github.github.com/gfm/).
:::simple Good to know
@@ -35,9 +16,7 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` in a show page.
```tsx live url=http://localhost:3000/posts/show/123 previewHeight=420px hideCode
-setInitialRoutes(["/samples", "/samples/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
+setInitialRoutes(["/posts", "/posts/show/123"]);
// visible-block-start
import { useShow } from "@refinedev/core";
@@ -48,7 +27,7 @@ import {
} from "@refinedev/chakra-ui";
import { Heading, Text } from "@chakra-ui/react";
-const SampleShow: React.FC = () => {
+const PostShow: React.FC = () => {
const { queryResult } = useShow();
const { data, isLoading } = queryResult;
const record = data?.data;
@@ -74,31 +53,42 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
+ (
-
- This page is empty.
-
- Show Item 123
-
-
- ),
+ name: "posts",
+ show: "/posts/show/:id",
+ list: "/posts",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/number-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/number-field/index.md
index d12b3ffff3df..ce29340f047a 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/number-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/number-field/index.md
@@ -3,25 +3,6 @@ title: Number
swizzle: true
---
-```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
This field is used to display a number formatted according to the browser locale, right aligned. and uses [`Intl`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) to display date format.
:::simple Good to know
@@ -36,9 +17,8 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
If Intl is not available, `` outputs numbers as is (and ignores the locales and options props).
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live url=http://localhost:3000/posts previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
import {
@@ -148,19 +128,30 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
- );
-};
-
render(
-
-
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/tag-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/tag-field/index.md
index aa374b1d3f42..242b6e0efe44 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/tag-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/tag-field/index.md
@@ -3,25 +3,6 @@ title: Tag
swizzle: true
---
-```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
This field lets you display a value in a tag. It uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/tag#usage) component.
:::simple Good to know
@@ -34,9 +15,8 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use it in a basic list page:
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live url=http://localhost:3000/posts previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
import {
@@ -140,19 +120,30 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
- );
-};
-
render(
-
-
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/text-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/text-field/index.md
index eb8e67a95b8e..093e895437d7 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/text-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/text-field/index.md
@@ -3,25 +3,6 @@ title: Text
swizzle: true
---
-```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
This field lets you show basic text. It uses Chakra UI's [``](https://www.chakra-ui.com/docs/components/text#usage) component.
:::simple Good to know
@@ -35,9 +16,7 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how to use it in a basic show page:
```tsx live url=http://localhost:3000/posts/show/123 previewHeight=420px hideCode
-setInitialRoutes(["/posts/show/123"]);
-import { Refine } from "@refinedev/core";
-import { ShowButton } from "@refinedev/chakra-ui";
+setInitialRoutes(["/posts", "/posts/show/123"]);
// visible-block-start
import { useShow } from "@refinedev/core";
@@ -58,12 +37,12 @@ const PostShow: React.FC = () => {
Id
- // highlight-next-line
+ {/* highlight-next-line */}
Title
- // highlight-next-line
+ {/* highlight-next-line */}
);
@@ -75,31 +54,42 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
+ (
-
- This page is empty.
-
- Show Item 123
-
-
- ),
+ show: "/posts/show/:id",
+ list: "/posts",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+ } />
+
+ This page is empty.
+
+ Show Item 123
+
+
+ }
+ />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/chakra-ui/components/fields/url-field/index.md b/documentation/docs/ui-integrations/chakra-ui/components/fields/url-field/index.md
index c42e2724112b..7d59cbc553ea 100644
--- a/documentation/docs/ui-integrations/chakra-ui/components/fields/url-field/index.md
+++ b/documentation/docs/ui-integrations/chakra-ui/components/fields/url-field/index.md
@@ -3,25 +3,6 @@ title: Url
swizzle: true
---
-```tsx live shared
-const { default: routerProvider } = LegacyRefineReactRouterV6;
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- legacyRouterProvider: routerProvider,
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- Layout: RefineChakra.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
- {children}
-
- );
-};
-```
-
This field lets you embed a link. It uses Chakra UI's [` `](https://www.chakra-ui.com/docs/components/link#usage) component. You can pass a URL in its `value` prop and you can show a text in its place by passing any `children`.
:::simple Good to know
@@ -34,9 +15,8 @@ You can swizzle this component to customize it with the [**Refine CLI**](/docs/p
Let's see how we can use `` with an example:
-```tsx live url=http://localhost:3000 previewHeight=420px hideCode
+```tsx live url=http://localhost:3000/posts previewHeight=420px hideCode
setInitialRoutes(["/posts"]);
-import { Refine } from "@refinedev/core";
// visible-block-start
import {
@@ -140,19 +120,30 @@ interface IPost {
}
// visible-block-end
-const App = () => {
- return (
-
- );
-};
-
render(
-
-
- ,
+
+
+
+
+
+
+ }
+ >
+ } />
+
+
+
+ ,
);
```
diff --git a/documentation/docs/ui-integrations/mantine/components/basic-views/create/index.md b/documentation/docs/ui-integrations/mantine/components/basic-views/create/index.md
index fac9d4b966c2..8188a3f4f850 100644
--- a/documentation/docs/ui-integrations/mantine/components/basic-views/create/index.md
+++ b/documentation/docs/ui-integrations/mantine/components/basic-views/create/index.md
@@ -4,13 +4,18 @@ swizzle: true
---
```tsx live shared
-const { default: simpleRest } = RefineSimpleRest;
-setRefineProps({
- dataProvider: simpleRest("https://api.fake-rest.refine.dev"),
- notificationProvider: RefineMantine.useNotificationProvider,
- Layout: RefineMantine.Layout,
- Sider: () => null,
-});
+interface ICategory {
+ id: number;
+ title: string;
+}
+
+interface IPost {
+ id: number;
+ title: string;
+ content: string;
+ status: "published" | "draft" | "rejected";
+ category: { id: number };
+}
const Wrapper = ({ children }) => {
return (
@@ -26,30 +31,14 @@ const Wrapper = ({ children }) => {
);
};
-
-interface ICategory {
- id: number;
- title: string;
-}
-
-interface IPost {
- id: number;
- title: string;
- content: string;
- status: "published" | "draft" | "rejected";
- category: { id: number };
-}
```
-`` provides us a layout to display the page. It does not contain any logic and just adds extra functionalities like action buttons and being able to give titles to the page.
+`` provides us a layout to display the page. It does not contain any logic but adds extra functionalities like action buttons and giving titles to the page.
We will show what `` does using properties with examples.
```tsx live url=http://localhost:3000/posts/create previewHeight=420px hideCode
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create, useForm, useSelect } from "@refinedev/mantine";
@@ -110,29 +99,40 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -150,9 +150,6 @@ You can swizzle this component with the [**Refine CLI**](/docs/packages/list-of-
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
@@ -160,37 +157,50 @@ import { Title } from "@mantine/core";
const PostCreate: React.FC = () => {
return (
- /* highlight-next-line */
- Custom Title}>
+ Custom Title}
+ >
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -200,46 +210,56 @@ render(
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
const PostCreate: React.FC = () => {
return (
- /* highlight-next-line */
-
+
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -252,48 +272,38 @@ The `` component reads the `resource` information from the route by defa
```tsx live url=http://localhost:3000/custom previewHeight=280px
setInitialRoutes(["/custom"]);
-import { Refine } from "@refinedev/core";
-import dataProvider from "@refinedev/simple-rest";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import { Layout } from "@refinedev/mantine";
// visible-block-start
import { Create } from "@refinedev/mantine";
const CustomPage: React.FC = () => {
return (
- /* highlight-next-line */
-
+
Rest of your page here
);
};
// visible-block-end
-const App: React.FC = () => {
- return (
- ,
- path: "/custom",
- },
- ],
- // highlight-end
- }}
- Layout={Layout}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
-
render(
-
-
- ,
+
+
+
+ } />
+
+
+ ,
);
```
@@ -306,47 +316,58 @@ If you have multiple resources with the same name, you can pass the `identifier`
To customize the back button or to disable it, you can use the `goBack` property. You can pass `false` or `null` to hide the back button.
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
-setInitialRoutes(["/posts", "/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
+setInitialRoutes(["/posts/create"]);
// visible-block-start
import { Create } from "@refinedev/mantine";
const PostCreate: React.FC = () => {
return (
- /* highlight-next-line */
-
- Rest of your page here 2
+
+ Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -356,58 +377,63 @@ To toggle the loading state of the ` ` component, you can use the `isLoa
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
const PostCreate: React.FC = () => {
return (
- /* highlight-next-line */
-
+
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
-### breadcrumb
-
-To customize or disable the breadcrumb, you can use the `breadcrumb` property. By default it uses the `Breadcrumb` component from `@refinedev/mantine` package.
+### breadcrumb
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create, Breadcrumb } from "@refinedev/mantine";
@@ -434,43 +460,49 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
-> For more information, refer to the [`Breadcrumb` documentation →](/docs/ui-integrations/mantine/components/breadcrumb)
-
### wrapperProps
If you want to customize the wrapper of the ` ` component, you can use the `wrapperProps` property. For `@refinedev/mantine` wrapper element is ``s and `wrapperProps` can get every attribute that `` can get.
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
@@ -493,29 +525,40 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -527,9 +570,6 @@ If you want to customize the header of the ` ` component, you can use th
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
@@ -552,29 +592,40 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -584,11 +635,8 @@ render(
If you want to customize the content of the ` ` component, you can use the `contentProps` property.
-```tsx live url=http://localhost:3000/posts/create previewHeight=320px
+```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
@@ -611,43 +659,47 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Mantine →](https://mantine.dev/core/box/)
-
### headerButtons
-You can customize the buttons at the header by using the `headerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
-
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
@@ -671,41 +723,51 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
+> For more information, refer to the [`Box` documentation from Mantine →](https://mantine.dev/core/box/)
+
### headerButtonProps
You can customize the wrapper element of the buttons at the header by using the `headerButtonProps` property.
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
@@ -721,8 +783,8 @@ const PostCreate: React.FC = () => {
padding: "16px",
},
}}
- // highlight-end
headerButtons={Custom Button }
+ // highlight-end
>
Rest of your page here
@@ -730,45 +792,47 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Mantine →](https://mantine.dev/core/group/)
-
### footerButtons
-By default, the ` ` component has a [``][save-button] at the header.
-
-You can customize the buttons at the footer by using the `footerButtons` property. It accepts `React.ReactNode` or a render function `({ defaultButtons, saveButtonProps }) => React.ReactNode` which you can use to keep the existing buttons and add your own.
-
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
@@ -792,100 +856,55 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
-);
-```
-
-Or, instead of using the `defaultButtons`, you can create your own buttons. If you want, you can use `saveButtonProps` to utilize the default values of the [``][save-button] component.
-
-```tsx live url=http://localhost:3000/posts/create previewHeight=280px
-setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-
-// visible-block-start
-import { Create, SaveButton } from "@refinedev/mantine";
-import { Button } from "@mantine/core";
-
-const PostCreate: React.FC = () => {
- return (
- (
- <>
-
- Custom Button
- >
- )}
- // highlight-end
>
- Rest of your page here
-
- );
-};
-// visible-block-end
-
-const App = () => {
- return (
- (
-
-
This page is empty.
-
+
+
+
- ),
- },
- ]}
- />
- );
-};
-render(
-
-
- ,
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
+> For more information, refer to the [`Group` documentation from Mantine →](https://mantine.dev/core/group/)
+
### footerButtonProps
You can customize the wrapper element of the buttons at the footer by using the `footerButtonProps` property.
```tsx live url=http://localhost:3000/posts/create previewHeight=280px
setInitialRoutes(["/posts/create"]);
-import { Refine } from "@refinedev/core";
-import { CreateButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
// visible-block-start
import { Create } from "@refinedev/mantine";
+import { Button } from "@mantine/core";
const PostCreate: React.FC = () => {
return (
@@ -909,33 +928,44 @@ const PostCreate: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
-
- ),
+ list: "/posts",
+ create: "/posts/create",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
-> For more information, refer to the [`Box` documentation from Mantine →](https://mantine.dev/core/group/)
+> For more information, refer to the [`Group` documentation from Mantine →](https://mantine.dev/core/group/)
## API Reference
@@ -943,4 +973,4 @@ render(
-[save-button]: /docs/ui-integrations/chakra-ui/components/buttons/save-button
+[save-button]: /docs/ui-integrations/mantine/components/buttons/save-button
diff --git a/documentation/docs/ui-integrations/mantine/components/basic-views/edit/index.md b/documentation/docs/ui-integrations/mantine/components/basic-views/edit/index.md
index d45b87f95064..b9dc5b265da4 100644
--- a/documentation/docs/ui-integrations/mantine/components/basic-views/edit/index.md
+++ b/documentation/docs/ui-integrations/mantine/components/basic-views/edit/index.md
@@ -3,55 +3,12 @@ title: Edit
swizzle: true
---
-```tsx live shared
-window.__refineAuthStatus = false;
-
-setRefineProps({
- notificationProvider: RefineMantine.useNotificationProvider,
- Layout: RefineMantine.Layout,
- Sider: () => null,
-});
-
-const Wrapper = ({ children }) => {
- return (
-
-
-
- {children}
-
-
- );
-};
-
-interface ICategory {
- id: number;
- title: string;
-}
-
-interface IPost {
- id: number;
- title: string;
- content: string;
- status: "published" | "draft" | "rejected";
- category: { id: number };
-}
-```
-
`` provides us a layout for displaying the page. It does not contain any logic and just adds extra functionalities like a refresh button.
We will show what `` does using properties with examples.
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=420px hideCode
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
-
// visible-block-start
import { Edit, useForm, useSelect } from "@refinedev/mantine";
import { Select, TextInput } from "@mantine/core";
@@ -78,10 +35,9 @@ const PostEdit: React.FC = () => {
},
});
- const postData = query?.data?.data;
const { selectProps } = useSelect({
resource: "categories",
- defaultValue: postData?.category.id,
+ defaultValue: query?.data?.data?.category?.id,
});
return (
@@ -115,39 +71,50 @@ const PostEdit: React.FC = () => {
);
};
+
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 123
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
:::simple Good to know
-
You can swizzle this component with the [**Refine CLI**](/docs/packages/list-of-packages) to customize it.
-
:::
## Properties
@@ -158,10 +125,6 @@ You can swizzle this component with the [**Refine CLI**](/docs/packages/list-of-
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/mantine";
@@ -169,38 +132,52 @@ import { Title } from "@mantine/core";
const PostEdit: React.FC = () => {
return (
- /* highlight-next-line */
- Custom Title}>
+ Custom Title}
+ >
Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 123
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -210,10 +187,6 @@ render(
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/mantine";
@@ -228,47 +201,55 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 123
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
-> For more information, refer to the [`` documentation →](/docs/ui-integrations/mantine/components/buttons/save-button)
+For more information, refer to the `` documentation →
### canDelete and deleteButtonProps
-`canDelete` allows us to add the delete button inside the `` component. If the resource has the `canDelete` property,Refine adds the delete button by default. If you want to customize this button you can use the `deleteButtonProps` property like the code below.
+`canDelete` allows us to add the delete button inside the `` component. If the resource has the `canDelete` property, Refine adds the delete button by default. If you want to customize this button you can use the `deleteButtonProps` property like the code below.
-When clicked on, the delete button executes the `useDelete` method provided by the `dataProvider`.
+When clicked on, the delete button executes the `useDelete` method provided by the dataProvider.
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/mantine";
@@ -290,87 +271,42 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- const simpleRestDataProvider = dataProvider(
- "https://api.fake-rest.refine.dev",
- );
-
- const customDataProvider = {
- ...simpleRestDataProvider,
- deleteOne: async ({ resource, id, variables }) => {
- return {
- data: {},
- };
- },
- };
-
- window.__refineAuthStatus = true;
-
- const authProvider = {
- login: async () => {
- return {
- success: true,
- redirectTo: "/",
- };
- },
- register: async () => {
- return {
- success: true,
- };
- },
- forgotPassword: async () => {
- return {
- success: true,
- };
- },
- updatePassword: async () => {
- return {
- success: true,
- };
- },
- logout: async () => {
- window.__refineAuthStatus = false;
- return {
- success: true,
- redirectTo: "/",
- };
- },
- check: async () => ({
- authenticated: window.__refineAuthStatus ? true : false,
- redirectTo: window.__refineAuthStatus ? undefined : "/login",
- }),
- onError: async (error) => {
- console.error(error);
- return { error };
- },
- getPermissions: async () => ["admin"],
- getIdentity: async () => null,
- };
-
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 123
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -383,10 +319,6 @@ render(
```tsx live url=http://localhost:3000/custom/23 previewHeight=280px
setInitialRoutes(["/custom/23"]);
-import { Refine } from "@refinedev/core";
-import { Layout } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/mantine";
@@ -400,31 +332,22 @@ const CustomPage: React.FC = () => {
};
// visible-block-end
-const App: React.FC = () => {
- return (
- ,
- path: "/custom/:id",
- },
- ],
- // highlight-end
- }}
- Layout={Layout}
- dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
- resources={[{ name: "posts" }]}
- />
- );
-};
-
render(
-
-
- ,
+
+
+
+ } />
+
+
+ ,
);
```
@@ -438,10 +361,6 @@ The `` component reads the `id` information from the route by default. `re
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=350px
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit, useModalForm } from "@refinedev/mantine";
@@ -476,30 +395,42 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 23
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 23
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -509,10 +440,6 @@ Determines which mode mutation will have while executing ``.
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit, useForm } from "@refinedev/mantine";
@@ -548,31 +475,42 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 123
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -588,21 +526,25 @@ import dataProvider from "@refinedev/simple-rest";
import { Edit } from "@refinedev/mantine";
-// highlight-start
const PostEdit = () => {
- return ... ;
+ return (
+
+ {/* ... */}
+
+ );
};
-// highlight-end
export const App: React.FC = () => {
return (
{/* ... */}
@@ -615,11 +557,7 @@ export const App: React.FC = () => {
To customize the back button or to disable it, you can use the `goBack` property. You can pass `false` or `null` to hide the back button.
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
-setInitialRoutes(["/posts", "/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
+setInitialRoutes(["/posts/edit/123"]);
// visible-block-start
import { Edit } from "@refinedev/mantine";
@@ -628,36 +566,48 @@ const PostEdit: React.FC = () => {
return (
/* highlight-next-line */
- Rest of your page here 2
+ Rest of your page here
);
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 123
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+ This page is empty.
+
+ Edit Item 123
+
+
+ }
+ />
+ } />
+
+
+
+ ,
);
```
@@ -667,10 +617,6 @@ To toggle the loading state of the ` ` component, you can use the `isLoadi
```tsx live url=http://localhost:3000/posts/edit/123 previewHeight=280px
setInitialRoutes(["/posts/edit/123"]);
-import { Refine } from "@refinedev/core";
-import { EditButton } from "@refinedev/mantine";
-import routerProvider from "@refinedev/react-router-v6/legacy";
-import dataProvider from "@refinedev/simple-rest";
// visible-block-start
import { Edit } from "@refinedev/mantine";
@@ -685,43 +631,51 @@ const PostEdit: React.FC = () => {
};
// visible-block-end
-const App = () => {
- return (
-
+ (
-
-
This page is empty.
-
Edit Item 123
-
- ),
+ list: "/posts",
+ edit: "/posts/edit/:id",
},
]}
- />
- );
-};
-render(
-
-
- ,
+ >
+
+
+
+
+ }
+ >
+
+