Style, theme, and usability
Last updated
Last updated
Good user interface (UI) improves user experience (UX) and increases user involvement. You can customize the style of each component in PocketBlocks and use the theme feature to design the interface on a per-app or workspace basis. Features such as icon configuration and hint messages make the app interaction more user-friendly.
You can modify the style of all components in the Properties tab.
Click the color picker to select a color or write CSS color code in the text box.
You can also write JavaScript in the text box to conditionally control the style setting of the component.
The theme feature helps you quickly set the styles of all your apps within a workspace, such as the primary color of the apps and the default background color of containers.
Workspace admins have access to theme settings. On PocketBlocks homepage, go to Settings > Themes, and click + Create theme. Enter the theme name, and select one of the preset default themes as the starting point.
Preview the real-time theme effect on the right.
In the app editor, switch the theme by clicking ⚙️ on the left side-bar. Select a theme from Theme setting.
You can also set the default theme for all your apps within a workspace in Settings > Themes on PocketBlocks homepage.
You can access the global variable theme
and call the method theme.switchTo()
to allow the end users to switch the theme of the apps on their side using JavaScript.The global variable theme
has three fields. You can view them in the data browser.
id
and name
are strings, indicating the ID and name of the current theme. When their values are empty, then the default theme is applied.
allThemes
is an array, including all information of available themes in the current workspace.
theme.switchTo()
method switches the theme at the end user's side, and requires only a theme ID. When the passed value is an empty string ""
, then the default theme is applied.Once the end user switches the theme, it will be saved to the user browser's local storage. And this theme will override the default theme and apply to all apps that are used in the same browser.
Combining Option lists and Events, end users can switch the theme within the app.
Follow the steps below to include this function in your app.
Drag and drop a Select component onto your canvas. Set the data value as follows.
Set the labels and values as {{item.name}}
and {{item.id}}
respectively. Then, you can view the default theme and all other available themes in the current workspace.
Insert a Button component onto your canvas to switch theme. Add an event to the button, select "Run JavaScript" as the action, and run theme.switchTo()
method which takes the value of the Select component.
PocketBlocks provides a custom CSS feature for more flexible and customized UI styling.
In the app editor, click ⚙️ on the left side-bar, select Scripts and style > CSS, and then write CSS code for the current app.
For example, insert text component text1
. Then use .text1
as the element name and modify its CSS style.
It is recommended to modify the component styles in Properties > Style because the DOM of an adjusted CSS style may change as the system iterates.
In PocketBlocks, workspace admins can also set pre-loaded CSS styles for all apps within the workspace. Open the Settings, and click Advanced > Preload CSS.
It is highly recommended to use CSS selectors as follows:
top-header
Top navigation bar
root-container
Root container of the app
The name of each component functions as the class name. For example, for the text1
component, you can use .text1
as its class name and write CSS code for it. And the class names share the same form: ui-comp-{COMP_TYPE}
—for example, you can use .ui-comp-select
to define CSS style of all select components. All the components' class names are listed as follows.
Avoid using class names that may change with iterations, such as sc-dkiQaF bfTYCO
.PocketBlocks supports CSS pre-processor, you can use CSS nesting to improve efficiency, for example:
All the custom CSS for apps is saved into the space named #app-{APP_ID}
, and the CSS for modules is saved into the space named #module-{MODULE_ID}
.If your preload CSS does not work properly, it might be overridden by the theme or component styles with higher priority. Open the browser Inspect to check.
To allow line break in table header, insert the following code in Script and style > CSS.
To use custom font family, you need to define it first and then apply it. Insert the following code in Script and style > CSS to apply the font "Fredoka One" to all text components using Markdown mode within the app.
PocketBlocks always lives up to efficiency, security, and easy-to-use design.
To achieve this effect, set the hidden property of the component textArea1
with the code:
When the value of the component radio1
is "1", the value of the hidden property is "false"; otherwise, the value is "true". The component layout is automatically adjusted.
Icons are intuitive, and can be alternatives to text in some cases. The proper use of icons gives users a better visual experience, and helps them use the app more easily.
Prefix and suffix icons are available for some components, such as Button. Add icons in Properties > Layout.
You can select from preset icons or write JS code to insert icons, for example, {{ "/icon:solid/Users" }}
.
Tips improve app usability–for example, showing the tips for the input helps users better interact with the app.
Placeholder: It displays in the empty input field to prompt the user what to type.
Tooltip: It adds an underline to the label. Users can see the tooltip via a mouse hover.
Notifications are messages directly sent to your users to remind them of the status of their operations, confirm their success, or help them to proceed.
Global notifications for certain user interactions give users timely feedback. PocketBlocks offers four types of global notificaitons: Information, Success, Warning and Error.
You can set global notifications in three ways:
Set in Event handlers > Action > Show notification. See Show notification (Event handlers).
Set in JavaScript queries with built-in functions.
Set in Notification tab in query settings. See Notification tab.
When a query takes time to run, you can set the loading effect to inform your users that the query is running and avoid them from performing frequent operations.
For example, the loading effect of the Submit button is {{form1SubmitToHrmsEn1.isFetching}}
. Clicking the button triggers query form1SubmitToHrmsEn1
to run, and during this process, the button is displayed with the loading effect.
You can set a confirmation modal for a double check for your users when they perform operations such as adding, modifying or deleting data. In the Advanced tab of the query, toggle Show a confirmation modal before running, and enter a confirmation message.
Forms are frequently used to collect information. For more details on building easy-to-follow and productive forms, see Design an efficient and user-friendly form.
Set the hidden properties of components when necessary to avoid information overload. For example, when creating a suggestion collection form, you can set the input box as visible or hidden depending on the user's selection.