element-vir - v26.14.0
    Preparing search index...

    Function defineElement

    • Defines an element with inputs. Note that this function must be called twice, due to TypeScript type inference limitations.

      Type Parameters

      Parameters

      • ...errorParams: DeclarativeElementInputErrorParams<Inputs>

        These errorParams is present when there are problems with the Inputs type. If it is present, the error should be fixed. This should always be empty.

      Returns <
          const TagName extends `${string}-${string}`,
          State extends PropertyInitMapBase = {},
          EventsInit extends EventsInitMap = {},
          const HostClassKeys extends `${string}-${string}-${string}` = `${TagName}-`,
          const CssVarKeys extends `${string}-${string}-${string}` = `${TagName}-`,
          const SlotNames extends readonly string[] = readonly [],
          const TestIds extends readonly string[] = readonly [],
      >(
          initInput: DeclarativeElementInit<
              TagName,
              Inputs,
              State,
              EventsInit,
              HostClassKeys,
              CssVarKeys,
              SlotNames,
              TestIds,
          >,
      ) => DeclarativeElementDefinition<
          TagName,
          Inputs,
          State,
          EventsInit,
          HostClassKeys,
          CssVarKeys,
          SlotNames,
          TestIds,
      >

      import {defineElement, html} from 'element-vir';

      const MyElement = defineElement<{username: string}>()({
      tagName: 'my-element',
      render({inputs}) {
      return html`
      <p>hi: ${inputs.username}</p>
      `;
      },
      });