1

I'm creating a web application in Vaadin. I found there is a possibility to add custom layout with CSS or create your own theme to existing vaadin component. Is there a possibility to add your own html element and css in Vaadin application? If yes, how can You achieve it? (Java 8, Intellij IDEA)

2
  • It depends what do you wish to achieve. But adding CSS to vaadin is just a matter of adding it to sccs styles, html as you mentioned to the custom layouts (or via Label in html rendering mode) Commented Nov 28, 2016 at 10:31
  • I created simple news-ticker in pure HTML and CSS and try to add it to my application (that mostly contains vaadin elements). So You think about custom layout like: vaadin.com/docs/-/part/framework/layout/…? Commented Nov 28, 2016 at 10:36

1 Answer 1

2

Among other things, you can write HTML and CSS directly by setting the content mode of a label to HTML:

Label label = new Label("<p style='background: yellow;'>Test</p>");
label.setContentMode(ContentMode.HTML);
Sign up to request clarification or add additional context in comments.

4 Comments

If you ever re-display user entered text inside your HTML here make sure you cleanse it otherwise you might be opening up your application to XSS etc...
Cross-site scripting :( Actually not a bad idea to write inside a label, but my css is a little bit complicated with many animations so it would require additional work to rewrite it to one html file :(
EDIT Forgot about internal CSS style- it's easy to make html out of html + css, i will try this for short-term purposes if i won't find better solution :)
Vaadin has pretty extensive support for CSS: vaadin.com/docs/-/part/framework/themes/themes-creating.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.