@yarcl/react
    Preparing search index...

    Function createComponent

    • Extends an existing component or native element with a config recipe. Preserves inherited attributes, refs and behavior. Visual variant props are consumed rather than passed to the base component. A render callback can apply named slots to custom markup. Recipe axes must not collide with inherited props.

      Type Parameters

      • N extends never
      • B extends ElementType

      Parameters

      • name: N
      • base: B & (
            Extract<
                keyof Axes<Extract<Record<never, never>[N], RecipeDefinition>>,
                keyof ComponentProps<B>,
            > extends never
                ? unknown
                : { error: "Recipe variants must not replace inherited props" }
        )
      • Optionalrender: (context: RecipeRenderContext<N, B>) => ReactNode

      Returns (props: ExtendedComponentProps<N, B>) => ReactNode

      const Action = createComponent('Action', Button);
      const Status = createComponent('Status', 'div', ({ rootProps, slots }) => (
      <div {...rootProps}><span className={slots.label}>{rootProps.children}</span></div>
      ));