You can use the Oracle JET SCSS files to customize themes. At build time, Oracle JET uses Sass to convert the alta/oj.alta.scss aggregating files to CSS. You can also use Sass to generate your own themes.
Topics:
You can use Sass to customize an Oracle JET theme.
To customize an Oracle JET theme using Sass:
Oracle JET uses icon fonts whenever possible to render images provided by the Alta theme. When icon fonts are not possible, Oracle JET uses image files. In either case, framework images support high contrast mode. Oracle JET also provides CSS classes for most framework images.
Topics:
For examples of framework images, see Framework Images.
There are a variety of ways to load icons, such as sprites, data URIs, icon fonts, and so on. Factors to consider when choosing an image strategy include:
Themable: Can you use CSS to change the image? Can you replace a single image easily?
High contrast mode: Does the image render properly in high contrast mode for accessibility?
High resolution support: Does the image look acceptable on high resolution (retina) displays?
Browser support: Do you require support for all browsers? Some browsers may not support certain image formats, such as SVG.
Image limitations: Are there limitations that impact your use case? For example, icon fonts are a single color, and small SVG images often do not render well.
Performance: Is image size a factor? Do you need alternate versions of an image for different resolutions or states such as disabled, enabled, hover, and active?
Oracle JET uses icon fonts whenever possible because icon fonts have certain advantages over other formats.
Themable: You can use style classes to change their color instead of having to replace the image, making them very easy to theme.
High contrast mode: Icon fonts are optimal for high contrast mode as they are considered text. However, keep in mind that you can't rely on color in high contrast mode, and you may need to indicate state (active, hover, and so on) using another visual indicator. For example, you can add a border or change the icon font's size. For additional information about Oracle JET and high contrast mode, see Configuring High Contrast Mode.
High resolution: Icon fonts look good on a high resolution (retina) display without providing alternate icons.
Performance: You can change icon font colors using CSS so alternate icons are not required to indicate state changes. Alternate images are also not required for high resolution displays.
Icon fonts also have disadvantages. It can be difficult to replace a single image, and they only show one color. You can use text shadows to provide some depth to the icon font.
Oracle JET supports two generic classes for setting the icon font colors in the $iconColorDefault, $iconColorHover, $iconColorActive, $iconColorSelected, and $iconColorDisabled variables.
oj-clickable-icon
oj-clickable-icon-nocontext
These classes, when used in conjunction with an anchor tag and/or marker classes like oj-default, oj-hover, oj-focus, oj-active, oj-selected, and oj-disabled, will use the $iconColor* variables.
The oj-clickable-icon class is optionally contextual, meaning the anchor or marker style can be on an ancestor as shown in the example below. The example assumes that a JavaScript method is replacing oj-default as needed with oj-hover, oj-focus, oj-active, oj-selected, and oj-disabled.
<div class="oj-default"> <span class="oj-clickable-icon demo-icon-font demo-icon-gear"></span> </div> <a href="http://www.oracle.com"> <span class="oj-clickable-icon demo-icon-font demo-icon-gear"></span> </a>
The oj-clickable-icon-nocontext class is not contextual and must be placed on the same tag as shown in the example below. oj-clickable-icon would also work in this example.
<span class="oj-default oj-clickable-icon-nocontext demo-icon-font demo-icon-gear"> </span> <a href="http://www.oracle.com" class="oj-clickable-icon-nocontext demo-icon-font demo-icon-gear"> </a>
For an example that illustrates icon font classes on a link, see Icon Fonts.
Oracle JET uses images when icon fonts can't be used. Informational images must appear in high contrast mode for accessibility, as described in Configuring High Contrast Mode.
Oracle JET provides Sass mixins that you can use to create CSS for your own icons. For examples, see CSS Images.
Oracle JET provides marker styles that can be used instead of CSS3 and CSS4 pseudo classes. For example, the oj-hover class can be used instead of the :hover pseudo class typically used in CSS3. The advantage of using a marker style is that you can use the same style on any DOM element.
The following table lists the Oracle JET marker styles and their CSS3 and jQuery UI equivalent.
| Oracle JET Marker Style | CSS3 Inspiration | jQuery UI Equivalent | Description |
|---|---|---|---|
|
Accessibility: |
|||
|
|
This marker is placed on the body tag by either a script or the application. For details, see Configuring High Contrast Mode. |
||
|
Component: |
|||
|
|
|
Marks the root DOM element of a widget. |
|
|
|
Mark the |
||
|
Link: |
|||
|
|
Applied when user visits the link or item. |
||
|
Input: |
|||
|
|
|||
|
|
|
||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
User Action: |
|||
|
|
jQuery UI uses |
||
|
|
See previous explanation. |
Used when something is selected, checked, or toggled on. |
|
|
|
|
|
|
|
|
|
||
|
|
Used when something is focused, but you only want to set the style when |
||
|
|
Used when something is clickable, but you only want to set the style when For example, the following code will render the text white only when the button is not in a selected, hover, focus, or active state.
.demo-appheader-toolbar .oj-button.oj-default .oj-button-text {
color: white; }
|
||
|
Collapsible: |
|||
|
|
Used when something expandable is expanded. |
||
|
|
Used when something expandable is collapsed, meaning that it's not expanded. |
||
|
Alignment: |
|||
|
|
Indicates the horizontal position, such as the tail of a popup. |
||
|
|
Indicates the vertical position, such as the tail of a popup. |
Oracle JET also provides the following marker styles that can be used instead of CSS4 pseudo classes.
| Oracle JET Marker Style | CSS4 Inspiration | jQuery UI Equivalent | Description |
|---|---|---|---|
|
Drag and Drop: |
|||
|
|
Used on draggable elements. |
||
|
|
Used on element when dragged. |
||
|
|
Applies to all elements that are drop targets during a drag. |
||
|
|
Used on element that will receive the item currently being dragged. |
||
|
|
Used on elements that can receive the item currently being dragged. |
||
|
|
Used on elements that can't receive the item currently being dragged. |
Internally, Oracle JET follows these rules for clickable elements:
| Oracle JET Marker Style | Used if Widget is Disabled? |
|---|---|
|
|
|
|
|
Yes |
|
|
No |
|
|
No |
|
|
No |
|
|
No |
|
|
No |
For additional information about the CSS3 selectors, see http://www.w3.org/TR/css3-selectors/. For more information about the CSS4 selectors, see http://dev.w3.org/csswg/selectors4/.
You can set an Oracle JET component's CSS visibility property to hidden on the DOM until the component is initialized using the $initialVisibility variable. The component will still occupy space on the page, but the user will not see the component during page load.
// when $initialVisiblity is hidden then visibility: hidden is set on the DOM until the // component is initialized. This reduces the unstyled DOM seen by the user during page load. $initialVisibility: hidden !default
In addition to using this variable, you may also want to inline the following CSS into the head section of the first page so that uninitialized DOM is hidden even before the CSS file is downloaded and cached.
<style>
[data-bind*="ojComponent"]:not(.oj-component-initnode) {
visibility: hidden;
}
</style>
For more information about the CSS visibility property, see http://www.w3.org/wiki/CSS/Properties/visibility.
By default, the same CSS is used for right-to-left and left-to-right behavior, even if you set dir=rtl on the HTML tag. If you prefer to generate one CSS file for each direction, you can set the $textDirection variable to rtl or ltr.
Oracle JET does not support multiple directions on a page. The reason this is not supported is that the proximity of elements in the document tree has no effect on the CSS specificity, so switching directions multiple times in the page may not work the way you might expect. The code sample below shows an example.
<style>
[dir=ltr] .foo {color: blue}
[dir=rtl] .foo {color: red}
</style>
<span dir="rtl">
<span dir="ltr">
<span class="foo">You might think I will be blue because dir=ltr is on,
a closer ancestor than dir=rtl. But css doesn't care
about proximity, so instead I am red
(because [dir=rtl] .foo {color: red} was defined last).
Isn't that surprising?
</span>
</span>
</span>
For additional information about Oracle JET and bidirectional support, see Enabling Bidirectional (BiDi) Support in Oracle JET. For more information about CSS specificity, see https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity.
Certain browsers that Oracle JET supports may not support CSS properties such as animations, box shadows, and so on. This is considered acceptable as long as it degrades in a reasonable fashion. For example you may not get any animations on that browser, and you will just get a border instead of a box shadow.
On other browsers, for performance reasons, Oracle JET will not render a border radius, box shadow, or gradient, even if the browser supports it. For example, on Internet Explorer, Oracle JET sets the border radius to 0, as shown in the following example.
.oj-button {
border-radius: 2px;
}
.oj-slow-borderradius .oj-button {
border-radius: 0;
}
Internet Explorer has two rendering modes, GPU and software rendering. Performance for these CSS properties can be very slow in software rendering mode, and even GPU rendering has been slow in many cases. Also, Oracle JET has no way to determine which rendering mode is being used. Therefore, in Oracle JET the oj-slow-* classes are used in all supported versions of Internet Explorer.
You can control the behavior of the border radius, gradient, and box shadow by setting the following variables:
$borderRadiusGeneration
$gradientGeneration
$boxShadowGeneration
Valid options for these variables include:
slowOverride (default): Generate the regular value but also generate overrides for slow browsers to remove the border radius, gradient, and box shadow on slow browsers.
on: Generate only the regular value. Do not generate overrides.
off: Do not generate a regular or override value. This setting is useful if you want to design style sheets specifically for Internet Explorer only.
Oracle JET includes styles that implement responsive printing through print media queries.
In general, printing should look reasonable on most screens. However, you may need to require the end user to turn on background colors and images before printing, which are off by default for most browsers. For example, in the Chrome Print dialog, your end user may need to select the Background colors and images checkbox.
Also, Oracle JET removes some background images in high contrast mode. For more information about high contrast mode and workarounds for displaying images even when background images are disabled, see Configuring High Contrast Mode.
For additional information about responsive classes and printing, see Oracle JET and Responsive Web Design.