ant-design/docs/react/use-with-farm.en-US.md
curry 08e39ba2e4
docs: add farm with antd (#48923)
Co-authored-by: liangchaofei <liangchaofei@liangchaofeideMacBook-Pro.local>
2024-05-15 13:54:52 +08:00

2.3 KiB
Raw Blame History

group order title tag
title
Basic Usage
6 Usage with Farm New

Farm is a Rust-Based Web Building Engine to Facilitate Your Web Program and JavaScript Library. This article will try to use Farm to create a project and import antd.

Install and Initialization

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

During the initialization process, farm provides a series of templates for us to choose, We need choose the React template.

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 farm-project
$ npm install
$ npm start

Open the browser at http://localhost:9000. It renders a title saying Farm with React on the page, which is considered successful.

Import antd

Now we install antd from yarn or npm or pnpm or bun.

Modify src/main.tsx, import Button component from antd.

import React from 'react';
import { Button } from 'antd';

export function Main() {
  return (
    <div>
      <Button type="primary">Button</Button>
    </div>
  );
}

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 Farm at its Official documentation.

Customize Theme

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

import React from 'react';
import { Button, ConfigProvider } from 'antd';

export function Main() {
  return (
    <ConfigProvider theme={{ token: { colorPrimary: '#00b96b' } }}>
      <Button type="primary">Button</Button>
    </ConfigProvider>
  );
}

We are successfully running the antd components using Rsbuild now, lets start build your own application!