ui-translation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Skill: UI Translation

技能:UI转换

Purpose

用途

Translate natural language UI descriptions into IDS (Iress Design System) component implementations using
@iress-oss/ids-components
and
@iress-oss/ids-tokens
.
将自然语言描述的UI转换为IDS(Iress设计系统)组件实现,使用
@iress-oss/ids-components
@iress-oss/ids-tokens

Setup

设置

tsx
import '@iress-oss/ids-components/dist/style.css'; // Required — component styles
import '@iress-oss/ids-tokens/build/css-vars.css'; // Required if using tokens directly
import {
  IressProvider,
  IressButton,
  IressInput,
  IressField,
  IressStack,
  IressInline,
  IressText,
  IressCard,
  // ... import what you need
} from '@iress-oss/ids-components';

// Wrap your app in IressProvider (handles fonts + CSS variables)
function App() {
  return <IressProvider>{/* your UI */}</IressProvider>;
}
tsx
import '@iress-oss/ids-components/dist/style.css'; // Required — component styles
import '@iress-oss/ids-tokens/build/css-vars.css'; // Required if using tokens directly
import {
  IressProvider,
  IressButton,
  IressInput,
  IressField,
  IressStack,
  IressInline,
  IressText,
  IressCard,
  // ... import what you need
} from '@iress-oss/ids-components';

// Wrap your app in IressProvider (handles fonts + CSS variables)
function App() {
  return <IressProvider>{/* your UI */}</IressProvider>;
}

Component Mapping

组件映射

Actions

操作组件

DescriptionIDS ComponentExample
Submit / primary action button
IressButton mode="primary"
<IressButton mode="primary">Submit</IressButton>
Cancel / secondary action button
IressButton mode="secondary"
<IressButton mode="secondary">Cancel</IressButton>
Less prominent action
IressButton mode="tertiary"
<IressButton mode="tertiary">Details</IressButton>
Icon-only action
IressButton icon="edit" mode="muted"
<IressButton mode="muted" icon="edit">Edit</IressButton>
Danger / delete action
IressButton status="danger"
<IressButton mode="primary" status="danger">Delete</IressButton>
Link in text
IressLink
<IressLink href="/about">About</IressLink>
Dropdown/context menu trigger
IressDropdownMenu
See patterns docs
描述IDS 组件示例
提交/主要操作按钮
IressButton mode="primary"
<IressButton mode="primary">Submit</IressButton>
取消/次要操作按钮
IressButton mode="secondary"
<IressButton mode="secondary">Cancel</IressButton>
次要操作按钮(低突出度)
IressButton mode="tertiary"
<IressButton mode="tertiary">Details</IressButton>
仅图标操作
IressButton icon="edit" mode="muted"
<IressButton mode="muted" icon="edit">Edit</IressButton>
危险/删除操作
IressButton status="danger"
<IressButton mode="primary" status="danger">Delete</IressButton>
文本内链接
IressLink
<IressLink href="/about">About</IressLink>
下拉/上下文菜单触发器
IressDropdownMenu
查看模式文档

Form Inputs

表单输入组件

DescriptionIDS ComponentExample
Labelled text input
IressField
+
IressInput
See Form example below
Select dropdown
IressField
+
IressSelect
<IressField label="Country"><IressSelect>...</IressSelect></IressField>
Currency input
IressField
+
IressInputCurrency
<IressField label="Amount"><IressInputCurrency /></IressField>
Checkbox
IressCheckbox
<IressCheckbox label="I agree" />
Checkbox group
IressCheckboxGroup
<IressCheckboxGroup label="Options"><IressCheckbox label="A" /><IressCheckbox label="B" /></IressCheckboxGroup>
Radio buttons
IressRadioGroup
+
IressRadio
<IressRadioGroup label="Choice"><IressRadio label="Yes" value="yes" /><IressRadio label="No" value="no" /></IressRadioGroup>
Toggle switch
IressToggle
<IressToggle label="Enable" />
Slider / range
IressSlider
<IressSlider min={0} max={100} />
Autocomplete / typeahead
IressAutocomplete
See component docs
Read-only display
IressReadonly
<IressReadonly label="Status" value="Active" />
描述IDS 组件示例
带标签的文本输入
IressField
+
IressInput
参见下方表单示例
选择下拉框
IressField
+
IressSelect
<IressField label="Country"><IressSelect>...</IressSelect></IressField>
货币输入
IressField
+
IressInputCurrency
<IressField label="Amount"><IressInputCurrency /></IressField>
复选框
IressCheckbox
<IressCheckbox label="I agree" />
复选框组
IressCheckboxGroup
<IressCheckboxGroup label="Options"><IressCheckbox label="A" /><IressCheckbox label="B" /></IressCheckboxGroup>
单选按钮
IressRadioGroup
+
IressRadio
<IressRadioGroup label="Choice"><IressRadio label="Yes" value="yes" /><IressRadio label="No" value="no" /></IressRadioGroup>
切换开关
IressToggle
<IressToggle label="Enable" />
滑块/范围选择器
IressSlider
<IressSlider min={0} max={100} />
自动完成/输入提示
IressAutocomplete
查看组件文档
只读展示
IressReadonly
<IressReadonly label="Status" value="Active" />

Layout

布局组件

DescriptionIDS ComponentExample
Vertical stack (items stacked top-to-bottom)
IressStack
<IressStack gap="4">...</IressStack>
Horizontal row (items side-by-side)
IressInline
<IressInline gap="2">...</IressInline>
Grid columns
IressRow
+
IressCol
<IressRow><IressCol span={6}>...</IressCol><IressCol span={6}>...</IressCol></IressRow>
Container with max-width
IressContainer
<IressContainer>...</IressContainer>
Divider / separator
IressDivider
<IressDivider />
Responsive visibility
IressHide
<IressHide below="md">Desktop only</IressHide>
描述IDS 组件示例
垂直堆叠(元素从上到下排列)
IressStack
<IressStack gap="4">...</IressStack>
水平行(元素并排排列)
IressInline
<IressInline gap="2">...</IressInline>
网格列
IressRow
+
IressCol
<IressRow><IressCol span={6}>...</IressCol><IressCol span={6}>...</IressCol></IressRow>
带最大宽度的容器
IressContainer
<IressContainer>...</IressContainer>
分隔线/分割符
IressDivider
<IressDivider />
响应式可见性
IressHide
<IressHide below="md">Desktop only</IressHide>

Content & Display

内容与展示组件

DescriptionIDS ComponentExample
Text / paragraph
IressText
<IressText>Body text</IressText>
Heading
IressText element="h2"
<IressText element="h2">Heading</IressText>
Card / panel
IressCard
or
IressPanel
<IressCard><IressCard.Header>Title</IressCard.Header><IressCard.Body>Content</IressCard.Body></IressCard>
Alert / notification
IressAlert
<IressAlert status="success">Saved!</IressAlert>
Loading spinner
IressSpinner
<IressSpinner />
Skeleton loader
IressSkeleton
<IressSkeleton height="20px" width="200px" />
Progress bar
IressProgress
<IressProgress value={75} max={100} />
Image
IressImage
<IressImage src="..." alt="..." />
Icon
IressIcon
<IressIcon name="settings" />
Tag / badge
IressTag
<IressTag>New</IressTag>
Pill
IressPill
<IressPill>Category</IressPill>
Tooltip
IressTooltip
<IressTooltip content="Help text"><IressButton>Hover me</IressButton></IressTooltip>
描述IDS 组件示例
文本/段落
IressText
<IressText>Body text</IressText>
标题
IressText element="h2"
<IressText element="h2">Heading</IressText>
卡片/面板
IressCard
or
IressPanel
<IressCard><IressCard.Header>Title</IressCard.Header><IressCard.Body>Content</IressCard.Body></IressCard>
提示/通知
IressAlert
<IressAlert status="success">Saved!</IressAlert>
加载旋转器
IressSpinner
<IressSpinner />
骨架加载器
IressSkeleton
<IressSkeleton height="20px" width="200px" />
进度条
IressProgress
<IressProgress value={75} max={100} />
图片
IressImage
<IressImage src="..." alt="..." />
图标
IressIcon
<IressIcon name="settings" />
标签/徽章
IressTag
<IressTag>New</IressTag>
胶囊标签
IressPill
<IressPill>Category</IressPill>
工具提示
IressTooltip
<IressTooltip content="Help text"><IressButton>Hover me</IressButton></IressTooltip>

Overlays & Navigation

浮层与导航组件

DescriptionIDS ComponentExample
Modal / dialog
IressModal
See Modal docs
Slideout / drawer
IressSlideout
See Slideout docs
Popover
IressPopover
See Popover docs
Menu
IressMenu
+
IressMenuItem
See Menu docs
Tab navigation
IressTabSet
+
IressTab
<IressTabSet><IressTab label="Tab 1">Content 1</IressTab></IressTabSet>
Skip link (a11y)
IressSkipLink
<IressSkipLink href="#main">Skip to content</IressSkipLink>
Side navigation
IressSideNav
See SideNav pattern docs
Breadcrumbs
IressBreadcrumbs
See Breadcrumbs pattern docs
描述IDS 组件示例
模态框/对话框
IressModal
查看Modal文档
侧边滑出/抽屉
IressSlideout
查看Slideout文档
弹出框
IressPopover
查看Popover文档
菜单
IressMenu
+
IressMenuItem
查看Menu文档
标签页导航
IressTabSet
+
IressTab
<IressTabSet><IressTab label="Tab 1">Content 1</IressTab></IressTabSet>
跳转链接(无障碍)
IressSkipLink
<IressSkipLink href="#main">Skip to content</IressSkipLink>
侧边导航
IressSideNav
查看SideNav模式文档
面包屑导航
IressBreadcrumbs
查看Breadcrumbs模式文档

Tables

表格组件

DescriptionIDS ComponentExample
Data table
IressTable
<IressTable><IressTable.Head>...</IressTable.Head><IressTable.Body>...</IressTable.Body></IressTable>
描述IDS 组件示例
数据表格
IressTable
<IressTable><IressTable.Head>...</IressTable.Head><IressTable.Body>...</IressTable.Body></IressTable>

Styling Props (IressCSSProps)

样式属性(IressCSSProps)

Most IDS components accept styling props for layout adjustments:
PropPurposeValues
alignSelf
Override flex alignment
"start"
,
"end"
,
"center"
,
"stretch"
bg
Background colourColour tokens:
"colour.primary.fill"
,
"colour.neutral.20"
,
"alt"
, etc.
borderRadius
Border radiusRadius tokens:
"radius.0"
"radius.4"
,
"none"
color
Text colourColour tokens:
"colour.neutral.80"
,
"colour.primary.text"
, etc.
flex
Flex grow
"1"
only
focusable
Apply focus ring
"true"
,
"within"
hideFrom
Hide from breakpoint up
true
, or breakpoints:
"sm"
,
"md"
,
"lg"
,
"xl"
hideBelow
Hide below breakpointBreakpoints:
"sm"
,
"md"
,
"lg"
,
"xl"
maxWidth
Max widthSize tokens:
"container.sm"
,
"container.md"
, etc.
m
Margin (all sides)Spacing tokens:
"xs"
"xl"
,
"spacing.1"
"spacing.10"
,
"auto"
, negatives (responsive)
mx
Margin horizontalSame as
m
(responsive)
my
Margin verticalSame as
m
(responsive)
mt
Margin topSame as
m
(responsive)
mr
Margin rightSame as
m
(responsive)
mb
Margin bottomSame as
m
(responsive)
ml
Margin leftSame as
m
(responsive)
noGutter
Remove last-child bottom margin
true
/
false
p
Padding (all sides)Spacing tokens:
"xs"
"xl"
,
"spacing.1"
"spacing.10"
(responsive)
px
Padding horizontalSame as
p
(responsive)
py
Padding verticalSame as
p
(responsive)
pt
Padding topSame as
p
(responsive)
pr
Padding rightSame as
p
(responsive)
pb
Padding bottomSame as
p
(responsive)
pl
Padding leftSame as
p
(responsive)
scrollable
Enable overflow scrolling
true
,
"x"
,
"y"
srOnly
Screen-reader only
true
/
false
(responsive)
stretch
Fill parent height
true
/
false
textAlign
Text alignment
"left"
,
"right"
,
"center"
,
"justify"
,
"inherit"
textStyle
Typography style
"typography.body.sm"
,
"typography.body.md"
,
"typography.heading.1"
"typography.heading.5"
,
"typography.code"
width
Element widthSize tokens:
"input.2"
"input.16"
,
"input.25perc"
"input.100perc"
,
"auto"
(responsive)
大多数IDS组件支持用于布局调整的样式属性:
属性用途取值
alignSelf
覆盖flex对齐方式
"start"
,
"end"
,
"center"
,
"stretch"
bg
背景颜色颜色令牌:
"colour.primary.fill"
,
"colour.neutral.20"
,
"alt"
borderRadius
边框圆角圆角令牌:
"radius.0"
"radius.4"
,
"none"
color
文本颜色颜色令牌:
"colour.neutral.80"
,
"colour.primary.text"
flex
Flex占比
"1"
(仅支持该值)
focusable
应用焦点环
"true"
,
"within"
hideFrom
从指定断点及以上隐藏
true
,或断点值:
"sm"
,
"md"
,
"lg"
,
"xl"
hideBelow
在指定断点以下隐藏断点值:
"sm"
,
"md"
,
"lg"
,
"xl"
maxWidth
最大宽度尺寸令牌:
"container.sm"
,
"container.md"
m
外边距(四边)间距令牌:
"xs"
"xl"
,
"spacing.1"
"spacing.10"
,
"auto"
, 负值(支持响应式)
mx
水平外边距
m
取值相同(支持响应式)
my
垂直外边距
m
取值相同(支持响应式)
mt
顶部外边距
m
取值相同(支持响应式)
mr
右侧外边距
m
取值相同(支持响应式)
mb
底部外边距
m
取值相同(支持响应式)
ml
左侧外边距
m
取值相同(支持响应式)
noGutter
移除最后一个子元素的底部外边距
true
/
false
p
内边距(四边)间距令牌:
"xs"
"xl"
,
"spacing.1"
"spacing.10"
(支持响应式)
px
水平内边距
p
取值相同(支持响应式)
py
垂直内边距
p
取值相同(支持响应式)
pt
顶部内边距
p
取值相同(支持响应式)
pr
右侧内边距
p
取值相同(支持响应式)
pb
底部内边距
p
取值相同(支持响应式)
pl
左侧内边距
p
取值相同(支持响应式)
scrollable
启用滚动溢出
true
,
"x"
,
"y"
srOnly
仅屏幕阅读器可见
true
/
false
(支持响应式)
stretch
填充父容器高度
true
/
false
textAlign
文本对齐方式
"left"
,
"right"
,
"center"
,
"justify"
,
"inherit"
textStyle
排版样式
"typography.body.sm"
,
"typography.body.md"
,
"typography.heading.1"
"typography.heading.5"
,
"typography.code"
width
元素宽度尺寸令牌:
"input.2"
"input.16"
,
"input.25perc"
"input.100perc"
,
"auto"
(支持响应式)

Translation Examples

转换示例

"A login form with email and password fields and a submit button"

“包含邮箱、密码输入框和提交按钮的登录表单”

tsx
import {
  IressButton,
  IressField,
  IressInput,
  IressStack,
} from '@iress-oss/ids-components';

function LoginForm() {
  return (
    <IressStack gap="4">
      <IressField label="Email" htmlFor="email" required>
        <IressInput id="email" type="email" placeholder="Enter your email" />
      </IressField>
      <IressField label="Password" htmlFor="password" required>
        <IressInput
          id="password"
          type="password"
          placeholder="Enter your password"
        />
      </IressField>
      <IressButton mode="primary" type="submit">
        Log in
      </IressButton>
    </IressStack>
  );
}
tsx
import {
  IressButton,
  IressField,
  IressInput,
  IressStack,
} from '@iress-oss/ids-components';

function LoginForm() {
  return (
    <IressStack gap="4">
      <IressField label="Email" htmlFor="email" required>
        <IressInput id="email" type="email" placeholder="Enter your email" />
      </IressField>
      <IressField label="Password" htmlFor="password" required>
        <IressInput
          id="password"
          type="password"
          placeholder="Enter your password"
        />
      </IressField>
      <IressButton mode="primary" type="submit">
        Log in
      </IressButton>
    </IressStack>
  );
}

"A card with a title, description, and two action buttons"

“包含标题、描述和两个操作按钮的卡片”

tsx
import {
  IressCard,
  IressButton,
  IressInline,
  IressText,
} from '@iress-oss/ids-components';

function ActionCard() {
  return (
    <IressCard>
      <IressCard.Header>
        <IressText element="h3">Card Title</IressText>
      </IressCard.Header>
      <IressCard.Body>
        <IressText>
          This is the card description with supporting details.
        </IressText>
      </IressCard.Body>
      <IressCard.Footer>
        <IressInline gap="2">
          <IressButton mode="primary">Confirm</IressButton>
          <IressButton mode="secondary">Cancel</IressButton>
        </IressInline>
      </IressCard.Footer>
    </IressCard>
  );
}
tsx
import {
  IressCard,
  IressButton,
  IressInline,
  IressText,
} from '@iress-oss/ids-components';

function ActionCard() {
  return (
    <IressCard>
      <IressCard.Header>
        <IressText element="h3">Card Title</IressText>
      </IressCard.Header>
      <IressCard.Body>
        <IressText>
          This is the card description with supporting details.
        </IressText>
      </IressCard.Body>
      <IressCard.Footer>
        <IressInline gap="2">
          <IressButton mode="primary">Confirm</IressButton>
          <IressButton mode="secondary">Cancel</IressButton>
        </IressInline>
      </IressCard.Footer>
    </IressCard>
  );
}

"A settings page with a toggle, some checkboxes, and a save button"

“包含切换开关、多个复选框和保存按钮的设置页面”

tsx
import {
  IressStack,
  IressToggle,
  IressCheckboxGroup,
  IressCheckbox,
  IressButton,
  IressText,
  IressDivider,
} from '@iress-oss/ids-components';

function SettingsPage() {
  return (
    <IressStack gap="6">
      <IressText element="h2">Settings</IressText>
      <IressToggle label="Enable notifications" />
      <IressDivider />
      <IressCheckboxGroup label="Notification types">
        <IressCheckbox label="Email" value="email" />
        <IressCheckbox label="SMS" value="sms" />
        <IressCheckbox label="Push" value="push" />
      </IressCheckboxGroup>
      <IressDivider />
      <IressButton mode="primary">Save settings</IressButton>
    </IressStack>
  );
}
tsx
import {
  IressStack,
  IressToggle,
  IressCheckboxGroup,
  IressCheckbox,
  IressButton,
  IressText,
  IressDivider,
} from '@iress-oss/ids-components';

function SettingsPage() {
  return (
    <IressStack gap="6">
      <IressText element="h2">Settings</IressText>
      <IressToggle label="Enable notifications" />
      <IressDivider />
      <IressCheckboxGroup label="Notification types">
        <IressCheckbox label="Email" value="email" />
        <IressCheckbox label="SMS" value="sms" />
        <IressCheckbox label="Push" value="push" />
      </IressCheckboxGroup>
      <IressDivider />
      <IressButton mode="primary">Save settings</IressButton>
    </IressStack>
  );
}

Best Practices

最佳实践

  1. Always wrap in IressProvider — Required at the root of your app for fonts and CSS variables
  2. Use IressField for all form inputs — Provides consistent labels, hints, and validation display
  3. Use IressStack/IressInline for layout — Prefer these over custom CSS flex/grid
  4. Use spacing tokens for gap — Values 0–10 map to multiples of 4px
  5. Use semantic button modes — One
    primary
    per section,
    secondary
    for most actions
  6. Always include labels — All form inputs need accessible labels via
    IressField
  7. Use status for feedback
    IressAlert
    for messages,
    status
    prop on buttons for danger/success
  8. Prefer IDS components — Use
    IressText
    instead of raw
    <p>
    ,
    IressButton
    instead of
    <button>
  9. Check the component docs — Read the specific component doc for detailed props and patterns (
    node_modules/@iress-oss/ids-components/.ai/components/
    )
  1. 始终用IressProvider包裹应用 — 必须在应用根节点使用,以加载字体和CSS变量
  2. 所有表单输入都使用IressField — 提供一致的标签、提示和验证展示
  3. 使用IressStack/IressInline进行布局 — 优先使用这些组件而非自定义CSS flex/grid
  4. 使用间距令牌设置gap — 0-10的值对应4px的倍数
  5. 使用语义化的按钮模式 — 每个区域仅保留一个
    primary
    按钮,大多数操作使用
    secondary
  6. 始终包含标签 — 所有表单输入需通过
    IressField
    添加可访问的标签
  7. 使用状态进行反馈 — 用
    IressAlert
    展示消息,按钮使用
    status
    属性标记危险/成功状态
  8. 优先使用IDS组件 — 用
    IressText
    替代原生
    <p>
    ,用
    IressButton
    替代原生
    <button>
  9. 查看组件文档 — 阅读具体组件的文档获取详细属性和模式(路径:
    node_modules/@iress-oss/ids-components/.ai/components/