Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to theme jquery-ui with npm and requires?

Is it possible to theme jquery-ui via npm?
Or do we still have to go through the download builder?

The jquery-ui package has the default theme included at:
./node_modules/jquery-ui/themes/base/*.css.

If we require('jquery-ui') that won't load any css styling as well, right?

Do we need to require('./jquery-ui/themes/base/all.css')?
Or is there a better way?

like image 289
John Mee Avatar asked Oct 21 '25 04:10

John Mee


1 Answers

  1. Is it possible to theme jquery-ui via npm?

    Yes, you can use jquery theme package (link).

    npm i jquery-ui-themeroller.

    And import it

    require('./jquery-ui-themes/themes/dot-luv/theme.css');

    dot-luv is the name of theme.

    Here is official document, not only theme list also tool for customize theme.

    Remember to import jquery css file first require('./jquery-ui/themes/base/all.css')

  2. If we require('jquery-ui') that won't load any css styling as well, right?

    Yes, you should import require('./jquery-ui/themes/base/all.css'); to get the style file.

  3. Do we need to require('./jquery-ui/themes/base/all.css')?

    It is the simplest way to get all widgets style. But in most case we only need several widget.

    That say we want datepicker only, we should import css file by

    require('./jquery-ui/themes/base/core.css');
    require('./jquery-ui/themes/base/datepicker.css');
    

    And now you can use your own theme in the end.

like image 188
呂學洲 Avatar answered Oct 23 '25 19:10

呂學洲



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!