@cantinc/ui

中文文档
0.3.16发布于 2025/10/05MITTypeScriptESM + CJS近 30 天下载 15.8万

UI components of innetjs

原始使用文档
文档目录6 节
  1. Abstract
  2. Usage
  3. Start application
  4. Install
  5. Styles
  6. Issues

  @cantinc/ui

 

NPM downloads changelog license

Abstract

CANT inc. UI based on innet.

This is a library of UI components you can use with @innet/dom application.

stars watchers

Usage

Start application

Create a new project with the next command in terminal console:

npx innetjs init my-app -t fe

change my-app if you want to call it another way

Go into my-app and run:

npm start

Go to localhost:3000 in your browser, and you can see default application.

Install

Stop the server and install @cantinc/ui

npm i @cantinc/ui

Then start again.

In the docs, you can find examples of components, you can copy any example and put into src/index.tsx file of your project (clear src folder before).

Styles

A big part of the library components has a class prop.

Provide the class as a string to add one.

import innet from 'innet'
import dom from '@innet/dom'

import { Button } from '@cantinc/ui'

innet(
  <Button class='test'>
    Click me
  </Button>,
  dom,
)

Or provide an object of classes.

Keys are elements of a component or different states.

import innet from 'innet'
import dom from '@innet/dom'

import { Checkbox } from '@cantinc/ui'

innet(
  <Checkbox
    class={{
      root: 'test-root',
      disabled: 'test-disabled',
      icon: 'test-icon',
    }}
  />,
  dom,
)

Values can be an array, string, or a function which returns them.

More information here html-classes.

import innet from 'innet'
import dom from '@innet/dom'
import { State } from 'watch-state'

import { Button } from '@cantinc/ui'

const state = new State('foo')

innet(
  <>
    <Button
      onclick={() => { state.value = 'bar' }}
      class={{
        root: [
          'test1-root',
          'test2-root',
          ['test3-root'],
          () => `${state.value}-root`,
        ],
        content: () => ['test-content', `${state.value}-content`],
      }}>
      Click me
    </Button>
    <Button class={() => state.value} />
  </>,
  dom,
)

You can use style prop to add inline styles.

import innet from 'innet'
import dom from '@innet/dom'
import { State } from 'watch-state'

import { Button } from '@cantinc/ui'

const color = new State('red')

const handleClick = () => {
  color.value = 'blue'
}

innet(
  <>
    <Button
      style={{
        background: () => color.value,
      }}
      onclick={handleClick}>
      Click me
    </Button>
  </>,
  dom,
)

Issues

If you find a bug or have a suggestion, please file an issue on GitHub.

issues

版本与发布记录

@cantinc/ui 共发布 127 个版本,首次发布于 2022/12/26;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.3.16latest2025/10/051.1 年前
0.3.152025/10/051.1 年前
0.3.142025/09/141.2 年前
0.3.132025/09/131.2 年前
0.3.122025/09/131.2 年前
0.3.112025/09/131.2 年前

关于 @cantinc/ui 的常见问题

@cantinc/ui 是什么?

UI components of innetjs

如何安装 @cantinc/ui?

在项目目录运行 npm install @cantinc/ui,或使用 pnpm add / yarn add / bun add。

@cantinc/ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cantinc/ui 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cantinc/ui 可以商用吗?

@cantinc/ui 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cantinc/ui 的下载量有多少?

根据 npm 官方下载统计,@cantinc/ui 在 2026/10/09 – 2026/11/07 这 30 天内被下载 157,820 次,日均约 5,261 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cantinc/ui 还在维护吗?

最新版本 0.3.16 发布于 2025/10/05(1.1 年前);至今共发布 127 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/12/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。