Skip to content

UUI components not working in basic vue app. #831

Open
@Ellarddekoeijer

Description

@Ellarddekoeijer

Which exact UI Library version are you using? For example: 1.0.1 - don't just write v1.

1.8.2

Bug summary

As the title describes, I would like to use The @umbraco-ui/uui web components in a vue app. Vue supports the use of web components, yet I cannot seem to get this to work.

I created a simple vue app using pnpm create vue@latest then I follow the steps over at https://vuejs.org/guide/extras/web-components#using-custom-elements-in-vue. (I can provide my vite config if need be, let me know.)

Then I pnpm add @umbraco-ui/uui-button, remove everything from App.vue, render the web component like so:

<script setup lang="ts"> import '@umbraco-ui/uui-button'; </script>
Testing

No dice! The error chunk-2OPG2DWD.js?v=5cdc5437:9659 Uncaught DOMException: Failed to construct 'CustomElement': The result must not have attributes is thrown and the element does not work.

As far as my understanding about web components & vue goes; built lit components should work in vue. Am I doing something wrong or does @umbraco-ui not support this?

FYI: Originally posted on the Umbraco discord server.

Specifics

No response

Steps to reproduce

  1. Create a basic vue app using pnpm create vue@latest
  2. Add uui package pnpm add @umbraco-ui/uui-button
  3. Tell vue to not handle uui web web components by changing vite config:
plugins: [
        vue({
            template: {
                compilerOptions: {
                    isCustomElement: (tag) => tag.startsWith('uui')
                }
            }
        })
    ],
  1. Render the button in App.vue:
<script setup lang="ts">
import '@umbraco-ui/uui-button';
</script>

<template>
  <div>
    <uui-button look="default" color="default" label="Basic">Testing</uui-button>
  </div>
</template>
  1. Run the app using pnpm dev. Go to the url vite spits out.

Expected result / actual result

People should be able to use your lovely uui components inside of front end frameworks that support the use of web components.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageThis issue has not been tested by a team member yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions