
Ant Design React projects start quickly because the library was built for React from day one. You install one package, import components by name and get consistent buttons, forms, tables and feedback messages without writing a design system from scratch. The setup steps below take a fresh project to a working screen.
The examples assume a modern toolchain with TypeScript, although plain JavaScript works the same way. Ant Design 6 requires React 18 or later, so confirm your React version before starting, especially when adding the library to an older codebase.
Create a React Project
Any React setup works, including Vite, Next.js and other frameworks. Vite is a lightweight choice for single-page applications and gives you a running development server within minutes.
npm create vite@latest my-app -- --template react-ts
cd my-app
npm install
Install antd and Icons
Add the component library and the icon package together so their versions stay aligned. With version 6, the migration notes require @ant-design/icons 6 as well.
npm install antd @ant-design/icons
No global stylesheet import is needed for components, because styles are generated at runtime. That removes a common setup step from older tutorials and avoids conflicts with your own CSS reset.
Build a First Screen
Import components from antd and compose them like any other React element. A small form is a good first test because it touches inputs, layout, validation and buttons at once.
import { Button, Form, Input } from 'antd';
export default function App() {
return (
<Form layout="vertical" onFinish={(v) => console.log(v)}>
<Form.Item label="Name" name="name"
rules={[{ required: true, message: 'Please input your name' }]}>
<Input />
</Form.Item>
<Button type="primary" htmlType="submit">Save</Button>
</Form>
);
}
Adding a data table
Tables take a columns array and a dataSource array, each row carrying a unique key. Sorting, filtering, pagination and row selection are switched on through props instead of custom code, which is why the component is popular for back-office screens.
Wrap the App with Providers
The ConfigProvider component sets global options such as locale, theme tokens and component size. The App component provides context for message, notification and modal calls, so they inherit theme settings correctly.
import { App as AntApp, ConfigProvider } from 'antd';
import enUS from 'antd/locale/en_US';
<ConfigProvider locale={enUS} theme={{ token: { colorPrimary: '#1677ff' } }}>
<AntApp>
<App />
</AntApp>
</ConfigProvider>
Useful Patterns for Real Projects
A few habits keep larger React codebases tidy as they grow. Most of them rely on features the library already provides, so there is little extra code to maintain.
- Use
App.useApp()to call message and modal helpers inside components. - Keep design changes in theme tokens instead of overriding class names.
- Use
Form.useForm()when you need to set or reset values programmatically. - Import only the icons you need from
@ant-design/icons. - Check the documentation for server-side rendering notes when using Next.js.
Common Problems and Fixes
Most issues come from version mismatches or copying code from older tutorials. Comparing your setup with the table below usually reveals the cause quickly.
| Symptom | Likely cause | Fix |
|---|---|---|
| Install fails with peer warnings | React version below 18 | Upgrade React or stay on an earlier antd line |
| Icons crash after upgrade | Icons still on version 5 | Install @ant-design/icons 6 |
| Message ignores theme | Static method called outside App context | Use App.useApp() instead |
| Styles look overridden | Global CSS targeting antd classes | Move changes into theme tokens |
After the first screen works, the theming article shows how to apply brand colors, and Ant Design Pro offers a complete admin layout when you need routing and access control.
Layout Components for Page Structure
Beyond individual controls, the library includes layout helpers that shape whole pages. Layout provides header, sider, content and footer regions, while Row and Col offer a responsive grid with breakpoint props for different screen widths.
The Flex and Space components handle smaller arrangements, such as aligning buttons in a toolbar or spacing tags evenly. Using these helpers instead of custom CSS keeps spacing aligned with the design tokens across the application.
Layoutfor page regions such as header and sidebar.RowandColfor responsive grids.FlexandSpacefor alignment and gaps.CardandDividerfor grouping content.
Feedback and Data Display
Applications constantly tell users what happened, and the library offers several feedback components for that. message shows brief confirmations, notification handles longer updates, Modal asks for decisions and Result presents full-page outcomes such as success or permission errors.
For presenting information, Descriptions lays out record details, Statistic highlights numbers, Tag labels statuses and Empty handles screens without data. Combining these with tables and forms covers most administrative interfaces.
Performance Tips for Larger Apps
Bundlers remove unused components automatically through tree shaking, so importing named components from the package root keeps builds lean. Heavy screens benefit from lazy loading with React.lazy, which delays rarely used pages until users open them.
Large tables deserve attention too. Pagination keeps the DOM small, and virtual scrolling options help when thousands of rows must remain visible. Measure with your browser's performance tools before optimizing, since many screens are already fast enough.
Accessibility Considerations
Components ship with keyboard handling and ARIA attributes for common patterns, but accessibility still depends on how you use them. Give every form field a visible label, keep color contrast high when changing tokens and write descriptive button text instead of relying on icons alone.
Working with Dates and Locales
Date components rely on Day.js for parsing and formatting, which keeps the bundle smaller than heavier date libraries. Values passed to DatePicker should be Day.js objects, and converting them to strings happens when you submit data to an API.
Locale settings affect both component text and date formats. Import the matching Day.js locale alongside the antd locale so month names, week starts and labels all agree for users in the same region.
- Pass Day.js objects as DatePicker values.
- Format dates only when sending data to the server.
- Load matching Day.js and antd locales together.
Organizing a Growing Codebase
Wrapping frequently used combinations in your own components keeps screens consistent. A shared PageHeader, a standard filter bar or a confirmed-delete button saves repetition and makes future design changes a single edit instead of dozens.
Conclusion
Ant Design React setup comes down to a short sequence: create a project on React 18 or later, install antd with matching icons, compose components, then wrap the app with ConfigProvider and App. Keep customizations in tokens, and the interface stays consistent as features grow.
Start small with one form or table, confirm everything renders as expected, then expand into layouts, feedback components and theming as the product grows. Consistent patterns from the first screen onward make later features faster to build.