组件目录

安装与使用

在 React 或 Vue 项目中安装 momo-ui,并引入组件与样式。

安装

需要 React 19 或 Vue 3.5,以及支持 ESM 的前端构建工具。组件分发在 GitHub Releases。

pnpm add https://momoyeyu.github.io/momo-ui/packages/momo-ui-0.3.0.tgz

使用 npm 的项目可用同一地址执行 npm install。也可直接下载安装包。

引入第一个控件

在应用入口引入一次样式,再按需导入组件。应用保存业务状态,组件接收值、标签和回调。

import {useState} from 'react';
import {Field, Switch} from '@momoyeyu/momo-ui';
import '@momoyeyu/momo-ui/styles.css';

export function VoiceSettings() {
  const [enabled, setEnabled] = useState(false);
  return (
    <Field label="语音">
      <Switch label="语音" checked={enabled} onChange={setEnabled}/>
    </Field>
  );
}

Vue

<script setup>
import {Button, Link} from '@momoyeyu/momo-ui/vue';
import '@momoyeyu/momo-ui/styles.css';
</script>

<template>
  <Button variant="primary" href="/download">下载</Button>
  <Link href="/docs">阅读文档</Link>
</template>

两种框架使用同一套颜色变量和按钮变体。Vue 的 Button 会根据 href 渲染链接或按钮。已有场景需要维持自己的布局和动效时,可用 variant="bare" 仅复用控件结构和属性。

本地维护

git clone https://github.com/Momoyeyu/momo-ui.git
cd momo-ui
pnpm install --frozen-lockfile
pnpm dev
pnpm build

安装与设计说明使用 MDX,单组件页面从 src/component-docs.ts 生成。新增公开组件时同步更新 API 说明、示例和目录。