Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use in vanilla html? #347

Closed
ghost opened this issue Mar 3, 2022 · 4 comments
Closed

How to use in vanilla html? #347

ghost opened this issue Mar 3, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Mar 3, 2022

Describe the bug

When I try to use the vscode webview components in my vanilla app, I get the error,

controller.js:363 Uncaught Error: Missing FASTElement definition.
    at Function.forCustomElement (controller.js:363:19)
    at new <anonymous> (fast-element.js:9:24)
    at new FoundationElement (foundation-element.js:14:9)
    at new _Button (button.form-associated.js:3:1)
    at new C (form-associated.js:19:13)
    at new FormAssociatedButton (button.form-associated.js:12:9)
    at new Button (button.js:14:9)
    at new Button2 (index.js:12:8)
    at main.ts:4:16

To reproduce

  1. git clone https://github.com/axelthat2/vscode-bug
  2. Open developer tools and you can see the error.

Expected behavior

Web components to work.

Screenshots

Screen Shot 2022-03-03 at 10 45 34 AM

Desktop (please complete the following information):

  • OS Version: macOS 12.2.1
  • Toolkit Version: ^0.9.1
@ghost ghost added the bug Something isn't working label Mar 3, 2022
@ghost ghost assigned hawkticehurst Mar 3, 2022
@ghost ghost changed the title How to use it in vanilla html? How to use in vanilla html? Mar 3, 2022
@hawkticehurst
Copy link
Member

hawkticehurst commented Mar 3, 2022

Hey, @axelthat2 I checked out your repo (thanks for providing a reproduction of the issue!) and it seems like a simple case of using the incorrect functions/API to set up the components properly.

Change your src/main.ts file to include the following:

import { provideVSCodeDesignSystem, vsCodeButton } from "@vscode/webview-ui-toolkit"

provideVSCodeDesignSystem().register(vsCodeButton());

Also if you want to use other components, simply import the desired component function (always in the form vsCode{ComponentName} and then add it to the register method.

import { 
  provideVSCodeDesignSystem, 
  vsCodeButton, 
  vsCodeCheckbox,
  // Import other component functions –– always in the form `vsCode{ComponentName}`
} from "@vscode/webview-ui-toolkit"

provideVSCodeDesignSystem()
  .register(
    vsCodeButton(), 
    vsCodeCheckbox(),
    // Register other component functions here
  );

@hawkticehurst
Copy link
Member

I'm also going to go ahead and close this issue and open a new one about updating our documentation to better highlight this information since up to this point this method of using the toolkit components isn't that well documented, except in fairly deep issue threads and also in the FAST getting started guide (which I don't expect most toolkit users to ever see).

With that said, if you have any more questions, comments, concerns, etc. about this specific issue feel free to add more comments to this thread and I'll keep an eye on it over the next couple of days!

@ghost
Copy link
Author

ghost commented Mar 4, 2022

Thank you so much. That helps a lot. I tried going through the toolkit docs and couldn't find anything. Adding doc for this issue will be so much great. Again thank you for your swift response.

@hawkticehurst
Copy link
Member

You're welcome, happy to hear it was helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant