[SOLVED] Html/css assets

I’am trying to create a button using css and html assets but nothing appears on my screen. I’m totally confused. How can i use my html and css so i can see the result on my screen?

Here’s a project sample of using HTML and CSS to create UI: https://developer.playcanvas.com/en/tutorials/htmlcss-ui/

Or are you talking about within the context of the editor?

I have css and html, i create two assets in my .js like this: MusicButton.attributes.add(‘cssAsset’, {
type: ‘asset’,
title: ‘CSS Asset’

MusicButton.attributes.add(‘htmlAsset’, {
type: ‘asset’,
title: ‘HTML Asset’

MusicButton.prototype.initialize = function() {

// Add the CSS
var style = pc.createStyle(this.cssAsset.resource); 

// Add the HTML
var html = this.htmlAsset.resource;


And then match them

Judging from the code you have posted, you haven’t added the HTML to the document.of the webpage.

1 Like

I agree with @yaustar all you have is CSS code on there and not the HTML tags

1 Like

I added this:
// Add the HTML
var div = document.createElement(‘div’);
div.innerHTML = this.htmlAsset.resource;

i don’t get any errors but the button still doesn’t appear.

Can you share the project please? It’s a bit difficult to see what’s wrong without the context of the project.

1 Like

Thank you for your help!I can see my button now.