跳到主要内容
Tennantite
EN
文档目录

物品格

凹槽视觉的最小物品格,可选选中白框。

安装

CLI 拷贝

$npx shadcn add @tennantite/slot

npm 直装

$pnpm add @tennantite/ui

npm 方式安装编译产物;需要改造源码请用上方的 CLI 拷贝安装。

用法

npm 导入

import { Slot } from "@tennantite/ui";

CLI 拷贝导入

import { Slot } from "@/components/tennantite/slot";
import { Grid } from "../grid/index";
import { Icon } from "../icon/index";
import { Slot } from "./index";

/**
 * Slot / Grid 预览用例(规格 §5 #2)
*/
export function SlotDemo() {
  return (
    <div className="mc-tex-panel inline-block p-6">
      <Grid columns={4}>
        <Slot selected>
          <Icon name="grass-block" />
        </Slot>
        <Slot />
        <Slot />
        <Slot />
        <Slot />
        <Slot />
        <Slot />
        <Slot />
      </Grid>
    </div>
  );
}

API Reference

PropTypeDefault描述
barebooleanfalse不绘制槽位纹理(用于 HUD 热键栏等自带槽位纹理的容器)。
frameClassNamestring"mc-tex-slot"自定义槽框纹理类(默认 `mc-tex-slot`;mod 界面可传自己的槽框)。
ghostGuiSpriteName—空槽 ghost 精灵。
selectedbooleanfalse选中态:1 GUI px 白色内框。
sizenumber18边长(GUI px,默认 18 —— 原版槽位)。

源码

packages/ui/src/containers/slot/index.tsx

npm 包保留源码目录,可直接复制改造。