Using CSS Stylesheet File in Web App

I have been wondering about this since I discovered Xojo. I know you can use Bootstrap and I have used the App Header file.

Like the people on the linked page below, I would like to know if there is a document or series of documents that explain how and where to save an external CSS file and link it to your app and/or its components, just like one would do in PHP or Ruby (and I am personally not interested in WebSDK).

Clearly other folks are interested in this topic.

Please Note This Forum Page:

Thank you

fritz

You linked to a 13 year old post, that was a different product Xojo Web1.
A lot has changed since then, we have a new product Xojo Web2.
There are some examples that ship with Xojo about CSS Classes.
You can change the Bootstrap theme if you want, you can make adjustments using App Header (as you already doing) and (I bet) you can attach a CSS file to your project, do a build step to copy it to resource folder and add it with App HTML header. Once is added you can use the CSS classes.

Alberto

I linked to the old post to illustrate that there were a lot of questions about this subject that evidently didn’t get answers, even though, like today, there were helpful people in the forum trying to answer them.

I, for one, would like to know exactly how I can “add” the CSS file with App HTML header and then how I can “use the CSS classes” for objects on the web page.

I would like to know if I can copy it to the “Resources” folder in particular, or can I declare the location in the App HTML file.

I don’t expect you to know or to tell me all this (even though I would indeed like for you to tell me all this), but I think a clear explanation of this whole process should be available in the documentation or in an extensive blog post.

I did take a look at the Bootstrap example under “Platforms/Web” which is certainly helpful if I wanted to use Bootstrap, which I don’t. I just want to know how to use a regular CSS file.

I was told I couldn’t edit the Bootstrap file in its unminified form. Otherwise I could just add my CSS to that. I was also told all I had to do was drag and drop the Bootstrap file to make it work. There is a link to a web-based Bootstrap file in this example which I don’t know is applicable.

As you see, I am confused by this topic. It strikes me that if they could make such a production out of this WebSDK stuff (which I also find mystifying) somebody at HQ could spare a half hour and make these several points clear.

Thank you very much for your response,

fritz

Xojo uses Bootstrap even if you don’t want to.

Who told you that?


Here is an example of a Xojo project and a file called bootstrap.min.css that is not minified.
I changed the bg color from blue to green for the primary button.

testbootstrap.zip (42.1 KB)

Hope this helps for now. I’ll try to add more information another day on adding a CSS file.

You need to make your file available to the Web Application.
I can recommend Lifeboat if you need an app to configure static files from your server.

In App HTML Header you write the location of your file, for example:

<link  type="text/css" href="https://dl.dropbox.com/scl/fi/2aafix53xl5whaikmv9ey/grad1.css?rlkey=jx902xgydcjrbbxq7t554ykti&st=n62a6vb8&raw=1" rel="stylesheet">

Then you can add the CSS Class to the element you want to change:

If all goes well, you will see your CSS applied to the button, like this:

This is the CSS in that file:

.grad1 {
   background-image: linear-gradient(to bottom, red, yellow);
}

Hope this helps.