2016-08-08 10:32:22 +08:00
---
order: 1
title: Getting Started
---
2018-10-06 17:18:36 +08:00
Ant Design React is dedicated to providing a **good development experience** for programmers. Make sure that you had installed [Node.js ](https://nodejs.org/ )(> 8.0.0) correctly.
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
> Before delving into Ant Design React, a good knowledge base of [React](https://reactjs.org) and [JavaScript ES2015](http://babeljs.io/docs/learn-es2015/) is needed.
2016-08-08 10:32:22 +08:00
2018-03-17 15:16:45 +08:00
---
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
## First Example
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
There is the simplest example to show usage of Ant Design React.
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
< iframe src = "https://codesandbox.io/embed/wk04r016q8?fontsize=14" style = "width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" sandbox = "allow-modals allow-forms allow-popups allow-scripts allow-same-origin" > < / iframe >
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
### 1. Create one codesandbox
2016-08-08 10:32:22 +08:00
2019-01-23 00:21:04 +08:00
Visit http://u.ant.design/codesandbox-repro to create a codesandbox, don't forget to press save button.
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
### 2. Using antd component
2016-08-08 10:32:22 +08:00
2016-09-18 17:47:58 +08:00
Replace the content of `index.js` with the following code.
2016-08-08 10:32:22 +08:00
As you can see, there is no difference between antd's components and usual React components.
```jsx
2019-01-22 19:06:11 +08:00
import React from "react";
import ReactDOM from "react-dom";
import { DatePicker, message } from "antd";
import "antd/dist/antd.css";
import "./index.css";
2016-08-08 10:32:22 +08:00
class App extends React.Component {
2019-01-22 19:06:11 +08:00
state = {
date: null,
};
handleChange = date => {
message.info(`Selected Date: ${date.format("YYYY-MM-DD")}`);
2016-08-08 10:32:22 +08:00
this.setState({ date });
2019-01-22 19:06:11 +08:00
};
2016-08-08 10:32:22 +08:00
render() {
2019-01-22 19:06:11 +08:00
const { date } = this.state;
2016-08-08 10:32:22 +08:00
return (
2019-01-22 19:06:11 +08:00
< div style = {{ width: 400 , margin: " 100px auto " } } >
< DatePicker onChange = {this.handleChange} / >
< div style = {{ marginTop: 20 } } >
Selected Date: {date ? date.format("YYYY-MM-DD") : "None"}
2017-09-26 23:12:47 +08:00
< / div >
2019-01-22 19:06:11 +08:00
< / div >
2016-08-08 10:32:22 +08:00
);
}
}
2019-01-22 19:06:11 +08:00
ReactDOM.render(< App / > , document.getElementById("root"));
2016-08-08 10:32:22 +08:00
```
2019-01-22 19:06:11 +08:00
### 3. Explore in more components
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
You can look up compnents in side menu, find one like [Alert ](/components/alert ). Plenty of examples are provided in component page,
API documentation too.
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
Click the corner icon at first example, there are source codes to use out of box. Now you are try import `Alert` in previous codesandbox:
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
```diff
- import { DatePicker, message } from 'antd';
+ import { DatePicker, message, Alert } from 'antd';
2016-08-08 10:32:22 +08:00
```
2019-01-22 19:06:11 +08:00
Add jsx part in `render` function.
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
```diff
< DatePicker onChange = {value = > this.handleChange(value)} />
< div style = {{ marginTop: 20 } } >
- Selected Date: {date ? date.format('YYYY-MM-DD') : 'None'}
+ < Alert message = {`Selected Date: $ { date ? date . format ( ' YYYY-MM-DD ' ) : ' None ' } ` } type = "success" / >
< / div >
2016-08-08 10:32:22 +08:00
```
2019-01-22 19:06:11 +08:00
Then you can see the result at preview section.
< img width = "420" src = "https://gw.alipayobjects.com/zos/antfincdn/QjCr7oLcpT/c7ce72d2-601e-4130-a33b-456d4652bb2d.png" alt = "codesandbox screenshot" / >
OK! Now you know how to use antd components in a clear way, welcome to explore more usages in this codesandbox.
We also strongly recommend to use codesandbox to provide a reproducible demo while reporting a bug.
### 4. Next Step
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
In real world you gonna need a whole package of `compile/build/deploy/lint/debug` development workflow
which you can read ariticles afterwards or try other scaffolds provided below:
- [Ant Design Pro ](http://pro.ant.design/ )
- [antd-admin ](https://github.com/zuiidea/antd-admin )
- [d2-admin ](https://github.com/d2-projects/d2-admin )
- more scaffolds at [Scaffold Market ](http://scaffold.ant.design/ )
2016-08-08 10:32:22 +08:00
## Compatibility
2016-09-28 00:07:31 +08:00
Ant Design React supports all the modern browsers and IE9+.
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" /> ](http://godban.github.io/browsers-support-badges/ )</ br > IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /> ](http://godban.github.io/browsers-support-badges/ )</ br > Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" /> ](http://godban.github.io/browsers-support-badges/ )</ br > Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" /> ](http://godban.github.io/browsers-support-badges/ )</ br > Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" /> ](http://godban.github.io/browsers-support-badges/ )</ br > Opera | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" /> ](http://godban.github.io/browsers-support-badges/ )</ br > Electron |
| --------- | --------- | --------- | --------- | --------- | --------- |
| IE9, IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions| last 2 versions
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
We offset very limit support for IE9/10, some styles and animation would be mininal under them, also we are using Flex layout in few components.
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
> Note, different with Ant Design, Ant Design Pro support to IE11+.
Polyfills are needed for IE browsers, we recommend [babel-preset-env ](https://babeljs.io/docs/en/babel-preset-env ) for it. You can set `targets` config if you are using [umi ](http://umijs.org/ ).
Ant Design 3.0 support both React 15 and 16 now though, we strongly suggest React 16 for better performance and few bugs.
2016-10-15 17:26:39 +08:00
2019-01-22 19:06:11 +08:00
#### IE8 note
2016-08-08 10:32:22 +08:00
2019-01-22 19:06:11 +08:00
> We don't support IE8 after `antd@2.0`.
2016-08-08 10:32:22 +08:00
## Customized Work Flow
2017-10-06 16:08:03 +08:00
If you want to customize your work flow, we recommend using [webpack ](http://webpack.github.io/ ) to build and debug code.
2016-08-08 10:32:22 +08:00
2017-10-06 16:08:03 +08:00
Also, you can use any [scaffold ](https://github.com/enaqx/awesome-react#boilerplates ) available in the React ecosystem. If you encounter problems, you can use our [webpack config ](https://github.com/ant-tool/atool-build/blob/master/src/getWebpackCommonConfig.js ) and [modify it ](http://ant-tool.github.io/webpack-config.html ).
2016-08-08 10:32:22 +08:00
2018-01-01 17:11:19 +08:00
If you are trying [parcel ](https://parceljs.org ), here is [a demo repository ](https://github.com/ant-design/parcel-antd ).
There are some [scaffolds ](http://scaffold.ant.design/ ) which have already integrated antd, so you can try and start with one of these, and even contribute.
2016-08-08 10:32:22 +08:00
## Import on Demand
2017-10-06 16:08:56 +08:00
If you see logs like below screenshot, you might be importing all components by writing `import { Button } from 'antd';` . This will affect your app's network performance.
2017-01-09 21:03:12 +08:00
2017-04-12 20:56:47 +08:00
```
You are using a whole package of antd, please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.
```
2018-05-21 23:42:57 +08:00
> ![console warning](https://zos.alipayobjects.com/rmsportal/GHIRszVcmjccgZRakJDQ.png)
2017-01-09 21:03:12 +08:00
2017-04-12 20:56:47 +08:00
However, we can import individual components on demand:
2016-08-08 10:32:22 +08:00
```jsx
import Button from 'antd/lib/button';
2017-02-22 14:04:40 +08:00
import 'antd/lib/button/style'; // or antd/lib/button/style/css for css format file
2016-08-08 10:32:22 +08:00
```
2018-08-05 13:35:54 +08:00
> `antd/es/button` to import es version module for tree shaking.
2017-10-06 16:08:03 +08:00
We strongly recommend using [babel-plugin-import ](https://github.com/ant-design/babel-plugin-import ), which can convert the following code to the 'antd/lib/xxx' way:
2016-08-08 10:32:22 +08:00
```jsx
import { Button } from 'antd';
```
2017-01-14 22:49:40 +08:00
And this plugin can load styles too, read [usage ](https://github.com/ant-design/babel-plugin-import#usage ) for more details.
2016-08-08 10:32:22 +08:00
2017-09-21 16:44:49 +08:00
> FYI, babel-plugin-import's `style` option will importing some global reset styles, don't use it if you don't need those styles. You can import styles manually via `import 'antd/dist/antd.css'` and override the global reset styles.
2016-08-08 10:32:22 +08:00
## Customization
2016-11-26 16:07:01 +08:00
- [Customize Theme ](/docs/react/customize-theme )
2016-08-08 10:32:22 +08:00
- [Local Iconfont ](https://github.com/ant-design/antd-init/tree/master/examples/local-iconfont )