Skip to content

Component overview

ElfUI's components are standard Custom Elements. The main line of writing is macro components: the top-level TypeScript is responsible for logic, and defineHtml(...) is responsible for declaring templates and component boundaries.

ts
import { defineHtml, defineProps } from "@elfui/core";

const props = defineProps<{ label: string }>({
  label: { type: String, default: "保存" }
});

export const SaveButton = defineHtml(` <button>${props.label}</button> `);

Component capabilities

CapabilitiesDocumentation
Define componentsdefineHtml, file export, tag inference
InputProps
outputevents, v-model
Content DistributionSlots
Cross-layer sharingProvide / Inject
Imperative accessTemplate reference, component exposure
CombinationLocal components, dynamic components
MultiplexinguseExtend / useVariant

TIP

Write props and events clearly first, then decide whether you need v-model, slots, provide/inject or expose. Don’t mix too many component communication methods. The fewer APIs, the more stable they are.