Home > Web Front-end > CSS Tutorial > How to Override GWT Theme Style with Custom CSS?

How to Override GWT Theme Style with Custom CSS?

Barbara Streisand
Release: 2024-10-28 12:44:02
Original
800 people have browsed it

How to Override GWT Theme Style with Custom CSS?

Overriding GWT Theme Style with Custom CSS

When integrating HTML files with custom CSS styles into GWT applications, you may encounter a conflict where the default GWT theme style overrides your styles. Here's how to resolve this and give precedence to your custom CSS.

Alternative Solution

As suggested in a GWT mailing list discussion, you can create a ClientBundle to reference your CSS file:

<code class="java">import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;

public interface Resources extends ClientBundle {

      public static final Resources INSTANCE = GWT.create(Resources.class); 

      @Source("style.css")
      @CssResource.NotStrict
      CssResource css();
}</code>
Copy after login

Within the onModuleLoad() method of your EntryPoint class, inject the CSS file to ensure its precedence over the GWT theme style:

<code class="java">public class YourApp implements EntryPoint {

    public void onModuleLoad() {
        //...
        Resources.INSTANCE.css().ensureInjected(); 
        //...
    }
}</code>
Copy after login

This method offers a clean and convenient way to override the GWT theme style with your custom CSS, ensuring that the intended visual presentation of your application is maintained.

The above is the detailed content of How to Override GWT Theme Style with Custom CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template