> For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/zh/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/zh/llms-full.txt.

# FormActions

数据录入`@rockshin/tao-ui`

[代码演示](#代码演示)[API](#api)

统一排列表单中的提交、取消与次要操作。

## 何时使用

表单底部需要稳定、可预测的操作区域时使用 FormActions。

**推荐**

- 主操作保持唯一并放在一致位置。
- 取消与破坏性操作使用正确语义层级。

**避免**

- 不要把无关操作混入表单操作区。

## 代码演示


### 基础用法
```tsx preview
import { Button, FormActions } from '@rockshin/tao-ui';

function FormActionsExample() {
  return (
    <FormActions>
      <Button variant="ghost">Cancel</Button>
      <Button>Save changes</Button>
    </FormActions>
  );
}

export default FormActionsExample;
```

### 次要与破坏性操作
```tsx preview
import { Button, FormActions } from '@rockshin/tao-ui';

function FormActionVariants() {
  return (
    <FormActions>
      <Button variant="destructive">Delete</Button>
      <Button variant="ghost">Cancel</Button>
      <Button>Save</Button>
    </FormActions>
  );
}

export default FormActionVariants;
```

### 语义化对齐
```tsx preview
import { Button, FormActions } from '@rockshin/tao-ui';

function CustomizedFormActions() {
  return (
    <FormActions styles={{ root: { justifyContent: 'space-between' } }}>
      <Button variant="ghost">Back</Button>
      <Button>Continue</Button>
    </FormActions>
  );
}

export default CustomizedFormActions;
```

### 完整表单组合
组合布局、字段与操作区，用原生提交展示保存结果。
```tsx preview
import { useState } from 'react';
import {
  FormLayout,
  FormSection,
  FormField,
  FormActions,
  Input,
  Textarea,
  Button,
} from '@rockshin/tao-ui';
export default function Example() {
  const [saved, setSaved] = useState('');
  return (
    <form
      onSubmit={(e) => {
        e.preventDefault();
        setSaved(String(new FormData(e.currentTarget).get('name')));
      }}
      onReset={() => setSaved('')}
    >
      <FormLayout>
        <FormSection title="Profile" description="Public workspace information">
          <FormField label="Display name" required>
            <Input name="name" required defaultValue="Alex" />
          </FormField>
          <FormField label="Bio" description="A short introduction">
            <Textarea name="bio" autoSize />
          </FormField>
        </FormSection>
        <FormActions>
          <Button type="reset">Reset</Button>
          <Button type="submit" variant="primary">
            Save
          </Button>
        </FormActions>
        <output aria-live="polite">
          {saved ? `Saved ${saved}` : 'No changes saved'}
        </output>
      </FormLayout>
    </form>
  );
}
```

### 对齐与换行
通过 root 样式设置对齐，窄屏保留自然换行。
```tsx preview
import { FormActions, Button } from '@rockshin/tao-ui';
export default function Example() {
  return (
    <FormActions
      styles={{ root: { justifyContent: 'space-between', flexWrap: 'wrap' } }}
    >
      <Button>Back</Button>
      <Button variant="primary">Continue</Button>
    </FormActions>
  );
}
```

### 操作等待状态
等待时统一禁用操作并显示加载；按钮可结束本地演示状态。
```tsx preview
import { useState } from 'react';
import { FormActions, Button, Stack } from '@rockshin/tao-ui';
export default function Example() {
  const [pending, setPending] = useState(false);
  return (
    <Stack direction="vertical">
      <FormActions>
        <Button disabled={pending}>Cancel</Button>
        <Button loading={pending} onClick={() => setPending(true)}>
          Save
        </Button>
      </FormActions>
      {pending && (
        <Button onClick={() => setPending(false)}>
          Finish simulated request
        </Button>
      )}
    </Stack>
  );
}
```

## API


### [#](#formactions)FormActions



| 属性 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| className | 节点类名 | `string | undefined` | `-` |
| style | 节点样式 | `CSSProperties | undefined` | `-` |

