jQuery UI Themes
All jQuery UI plugins allow developers to seamlessly integrate the look and feel of UI widgets into their websites or applications. Each plugin defines styles through CSS and contains two layers of style information: standard jQuery UI CSS Framework styles and plugin-specific styles.
The jQuery UI CSS framework provides semantic classes to indicate the roles of elements within a widget, such as headers, content, or clickable areas. These are consistent across all widgets; a clickable tab, accordion, or button all have the same ui-state-default class to indicate they are clickable. When the user hovers over these elements, this class becomes ui-state-hover, and when these elements are selected it becomes ui-state-active. The consistency of these classes makes elements with similar roles or interaction states look consistent across all widgets.
The CSS framework styles are encapsulated in a single file named ui.theme.css. This file is modified by the ThemeRoller application. The framework styles only contain properties that affect the look and feel, such as colors, background images, icons, etc. So these are "safe" styles that do not affect plugin functionality. This separation means developers can create a custom look and feel by modifying colors and images in the theme.css file. As future plugins or bug fixes become available, these work with themes without modification.
Since the framework styles only cover the look and feel, plugin-specific stylesheets must also be included. These stylesheets contain all the additional structural style rules that make widgets functional, such as size, padding, margins, positioning, and floats. Each plugin's stylesheet is located in the themes/base folder and is named after the plugin, for example "jquery.ui.accordion.css". These styles must be edited carefully, as they work with the script to provide overrides of the framework styles.
We encourage all developers to create jQuery plugins; the jQuery UI CSS framework makes it easier for end users to customize themes and use plugins.
Theming
The following are three general ways to theme jQuery UI plugins:
- Downloading a ThemeRoller theme: The earliest way to create a theme is to use ThemeRoller to generate and download a theme. This application will create a new
ui.theme.cssfile and aimagesfolder containing all the required background images and icon sprites. This is the earliest way to create and maintain a theme, but it limits customization to the options provided in ThemeRoller. - Modifying CSS files: For further control over the look and feel, you can choose to start from the default theme (Smoothness) or from a theme generated by ThemeRoller, and then adjust the
ui.theme.cssfile, or the stylesheet of any individual plugin. For example, you can easily adjust the corner radius of all buttons to a value different from other UI components, or change the path to icon sprites with custom settings. With a little styling scope, you can even use multiple themes in one UI. For ease of maintenance, it is recommended to change only theui.theme.cssfile and images. - Rewriting custom CSS: For maximum control over the look and feel, you can start from scratch and write the CSS for each plugin, without using framework classes or plugin-specific stylesheets. This approach is suitable when the desired look and feel cannot be achieved by modifying CSS, or when using highly custom markup. It requires deep expertise in CSS and manual updates for future plugins.