logoNamu Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
1.0.0
  • Namu Design of React
  • Changelogv1.0.0
  • Basic Usage
    • Getting Started
    • Usage with create-react-app
    • Usage with Next.js
    • Usage with Umi
    • Usage with Vite
  • Advanced
    • Customize ThemeUpdated
    • CSS Compatible
    • Server Side RenderingNew
    • Use custom date library
    • Internationalization
  • Migration
    • V4 to V5
    • Less variables to Component Token
  • Other
    • Common Props
    • Third-Party Libraries
    • Contributing
    • FAQ
Install and Initialization
Import antd
Customize Theme

Usage with create-react-app

  • Getting StartedUsage with Next.js

    Resources

    Namu Design Charts
    Namu Design Pro
    Namu Design Pro Components
    Namu Design Mobile
    Namu Design Mini
    Namu Design Landing-Landing Templates
    Scaffolds-Scaffold Market
    Umi-React Application Framework
    dumi-Component doc generator
    qiankun-Micro-Frontends Framework
    ahooks-React Hooks Library
    Ant Motion-Motion Solution
    China Mirror 🇨🇳

    Community

    Awesome Namu Design
    Medium
    Twitter
    yuqueNamu Design in YuQue
    Namu Design in Zhihu
    Experience Cloud Blog
    seeconfSEE Conf-Experience Tech Conference

    Help

    GitHub
    Change Log
    FAQ
    Bug Report
    Issues
    Discussions
    StackOverflow
    SegmentFault

    Ant XTechMore Products

    yuqueYuQue-Document Collaboration Platform
    AntVAntV-Data Visualization
    EggEgg-Enterprise Node.js Framework
    kitchenKitchen-Sketch Toolkit
    xtechAnt Financial Experience Tech
    Theme Editor
    Made with ❤ by
    Ant Group and Namu Design Community

    create-react-app is one of the best React application development tools, This article will try to use create-react-app to create a TypeScript project, and introduce antd.

    We build antd based on latest stable version of TypeScript (>=5.0.0), please make sure your project dependency matches it.

    Install and Initialization

    Before all start, you may need install yarn or pnpm.

    npm
    yarn
    pnpm
    $ npx create-react-app antd-demo --template typescript

    The tool will create and initialize environment and dependencies automatically, please try config your proxy setting or use another npm registry if any network errors happen during it.

    Then we go inside project and start it.

    $ cd antd-demo
    $ npm run start

    Open the browser at http://localhost:3000/. It renders a header saying Welcome to React on the page.

    Import antd

    Below is the default directory structure.

    ├── README.md
    ├── package.json
    ├── public
    │   ├── favicon.ico
    │   └── index.html
    ├── src
    │   ├── App.css
    │   ├── App.js
    │   ├── App.test.js
    │   ├── index.css
    │   ├── index.js
    │   └── logo.svg
    └── yarn.lock

    Now we install antd from yarn or npm or pnpm.

    npm
    yarn
    pnpm
    $ npm install antd --save

    Modify src/App.js, import Button component from antd.

    import { Button } from 'antd';
    import React from 'react';
    const App: React.FC = () => (
    <div className="App">
    <Button type="primary">Button</Button>
    </div>
    );
    export default App;

    OK, you should now see a blue primary button displayed on the page. Next you can choose any components of antd to develop your application. Visit other workflows of create-react-app at its User Guide.

    Customize Theme

    Ref to the Customize Theme documentation. Modify theme with ConfigProvider:

    import { ConfigProvider } from 'antd';
    import React from 'react';
    const App: React.FC = () => (
    <ConfigProvider theme={{ token: { colorPrimary: '#00b96b' } }}>
    <MyApp />
    </ConfigProvider>
    );
    export default App;

    antd is written in TypeScript with complete definitions, try out and enjoy the property suggestion and typing check.

    Don't install @types/antd.

    We are successfully running antd components now, go build your own application!