Oracle APEX Style Templates give developers powerful tools to control the look and feel of application components without writing complex code. By using style templates, you can apply consistent visual formatting across pages, regions, buttons, cards, and reports. These templates define the HTML structure, CSS classes, and appearance settings that get applied to elements automatically, helping maintain design uniformity throughout the app. Whether you're building a simple dashboard or a complex enterprise application, style templates allow you to create visually appealing layouts while keeping development efficient and structured.
In Oracle APEX, Style Templates are a powerful feature that allow you to control the appearance and layout of your application components—such as regions, buttons, cards, lists, and reports—using a combination of HTML structure, CSS classes, and substitution strings. Creating custom style templates gives you full control over how UI elements look and behave, allowing your app to follow specific branding, theming, or user experience guidelines.
To create an APEX style template, follow these steps in detail:
Step 1: Navigate to Shared Components
From the App Builder, open your application
Click on Shared Components
Under the User Interface section, select Templates
Step 2: Choose the Template Type
In the Templates page, click Create
You’ll be prompted to select a template type. Choose from options like:
-
Region (for layout containers)
-
Button (for styled buttons)
-
List (for menus and navigation structures)
-
Report (for tabular data and lists)
-
Label, Breadcrumb, Popup LOV, etc.
Each type supports different attributes and structure.
Step 3: Define the Template Name and Description
Give your template a unique Name, such as “Custom Card Template” or “Flat Button Style”
Optionally, provide a short description to explain its purpose
Step 4: Create the Template Markup
Depending on the template type, you’ll provide HTML code and CSS classes.
Use APEX substitution strings to inject dynamic content. For example:
<div class="card custom-card">
<div class="card-header">#TITLE#</div>
<div class="card-body">#BODY#</div>
</div>
Here, #TITLE#
and #BODY#
are placeholders that APEX replaces with runtime values.
Step 5: Assign CSS Classes and Attributes
Use the Classes field to assign custom CSS classes to your template
If your app uses a custom theme, make sure these classes are defined in your CSS file
You can also assign conditions to templates (like only show under specific circumstances)
Step 6: Save and Test
Click Apply Changes
Return to your application pages and apply the new template to a region, report, or button via the page designer
Check how it renders in the runtime preview. You may need to tweak HTML or CSS for alignment or responsiveness.
Optional: Use Template Options
For more dynamic control, create Template Options
Template options are toggles or switches (e.g., “Show Border,” “Icon Left”) that a developer can select when applying the template
To do this, go back to your custom template and add options under the “Template Options” section
Step 7: Maintain and Reuse
Once defined, templates become reusable across multiple pages or even across multiple applications (if you export/import them).
They ensure consistency and speed up development when building large applications with shared layout patterns.
By creating and using APEX style templates, you not only save time during design but also gain flexibility to implement responsive, brand-aligned, and maintainable applications.
Example
Oracle APEX provides a flexible way to create visually consistent applications through APEX Style Templates. These templates allow you to apply pre-built or custom styles to various components in your application, such as reports, forms, and regions, without needing to manually write CSS for each component.
This tutorial will guide you through the process of creating and using APEX Style Templates in your Oracle APEX application. By the end, you'll understand how to apply these templates to regions and components, customize them, and take advantage of pre-defined styles in APEX.
Step 1: Understanding APEX Style Templates
An APEX Style Template is a set of CSS styles and predefined visual components that you can apply to different parts of your APEX application, such as:
Regions (e.g., report, chart, calendar)
Forms (e.g., create, edit, update forms)
Buttons
Charts
Cards
APEX offers a collection of predefined styles such as Classic, Universal, Minimal, and more, which can be easily applied to give your application a modern and consistent look.
Step 2: Create a New Application (if you don't have one already)
Log in to your Oracle APEX workspace.
From the App Builder, click on Create.
Choose New Application and follow the steps to create a basic application with a few pages (e.g., a form and a report).
After the application is created, navigate to the App Builder.
Step 3: Explore and Use Predefined APEX Style Templates
APEX comes with a collection of predefined themes and templates that you can apply to your application components. These templates are part of the Theme you select for your application.
Navigate to Shared Components:
In the App Builder, go to Shared Components.
Under User Interface, click on Themes.
Select a Theme:
APEX provides a set of predefined themes. Choose a theme that suits your application (e.g., Universal, Classic, Redwood, etc.).
Click on the theme name (e.g., Universal).
Assign a Theme to Your Application:
After selecting the theme, click on Assign to Application to apply this theme to your entire application.
You can also customize the theme further by choosing Theme Styles or Theme Stylesheets from the Theme Settings page.
Step 4: Apply Predefined Templates to Regions
Now that your application has a theme, you can apply APEX Style Templates to specific regions. Regions are the building blocks of your application’s UI, such as reports, charts, forms, and cards.
Example 1: Apply a Style Template to a Report Region
Create a Report Region:
In App Builder, navigate to the page where you want to create the region (e.g., a report page).
Click Create > Region.
Choose Classic Report as the region type.
Set the SQL Query for the report.
Click Save.
Assign a Style Template to the Region:
Go to the Attributes tab of the report region.
Under Region Template, select one of the predefined templates. For example, choose Report - Classic or Report - Simple.
Click Save.
Example 2: Apply a Style Template to a Form Region
Create a Form Region:
In App Builder, go to the page where you want to create the form region (e.g., a create/edit form).
Click Create > Form > Form on a Table.
Select the table or view you want to create the form for and follow the steps to configure the form.
Click Save.
Assign a Style Template to the Form Region:
Under the Attributes tab of the form region, locate the Region Template dropdown.
Choose a template that fits your form’s needs. For example, select Form - Clean or Form - Standard.
Click Save.
Step 5: Customize APEX Style Templates
You may want to further customize the templates to match your application's branding. You can achieve this by modifying Theme Styles or adding your own custom CSS.
Example 1: Modify Theme Styles
Modify Theme Styles:
Navigate to Shared Components > Themes.
Click on Theme Styles.
Select the Style you want to modify (e.g., Universal Theme).
Customize the background color, font size, buttons, and other aspects of the style.
Click Save.
Example 2: Add Custom CSS
Navigate to the Page’s CSS:
In App Builder, go to the page where you want to apply custom styles.
Under the Page Attributes section, locate the Inline CSS field.
Write Custom CSS: You can write your custom CSS directly in this section. For example:
.t-Button {
background-color: #4CAF50;
color: white;
}
.t-RegionHeader {
font-size: 18px;
color: #2c3e50;
}
Save your changes, and preview the application to see the new styles in action.
Step 6: Use APEX Style Templates with Cards
Oracle APEX also allows you to use Card Regions, which are very flexible for displaying data in a visually appealing way. You can apply a style template to these cards to ensure they are consistent with the rest of your application’s theme.
Example: Apply a Template to a Card Region
Create a Card Report Region:
In App Builder, click Create > Region.
Choose Card Report as the region type.
Define the SQL Query for the cards, such as:
SELECT employee_id, first_name, last_name, job_title, department_name FROM employees
Assign a Style Template:
In the Region Attributes section, find the Region Template dropdown.
Select Card - Simple or any other predefined card template.
Save and Run the page to see the cards with the applied template.
Step 7: Advanced Customization of APEX Style Templates (Optional)
If you need more advanced customizations, you can define your own custom templates or themes:
Create a Custom Theme:
In Shared Components, under Themes, click Create to create a custom theme.
Choose a Parent Theme to base your custom theme on (e.g., Universal).
Modify the CSS, HTML structure, or JavaScript to fit your needs.
Use the Custom Theme:
Once the custom theme is created, assign it to your application by navigating to App Builder > Shared Components > Themes, and assign the custom theme to your app.
Advanced Templates:
You can create advanced templates for specific regions, such as report templates, form templates, and button templates, by navigating to Shared Components > Templates and creating a custom template with HTML and CSS.
By leveraging APEX style templates, developers can significantly enhance the visual presentation of their applications while preserving consistency and usability. Templates make it easier to maintain brand standards, apply custom themes, and update designs centrally without having to modify each page manually. With just a few changes in Shared Components, you can instantly refresh the design across your entire application, streamlining both development and maintenance.
No comments:
Post a Comment