How to work with brand policies
Learn all the technical details about how to make your brand experience happen using a brand policy's HTML, CSS, and Javascript.
Web resource loading
After a no-code component page is loaded, it synchronously loads branding.css and the main Javascript file's content and waits until this content is loaded. Once these files have been downloaded, the component's page loader spinner appears.
Afterward, the component will load the branding.json along with translation content, if the selected language is not English U.S. (en-US). Once the branding.json has been downloaded, the configured additional script will start.
CSS usage
To make CSS easier to use, each page's block name is added to the app's DOM element. You can use this as a selector to add CSS code to a specific screen.

CSS selector examples
:root {
// NOTE: You can check all CSS variable when you start typing the following in the CSS code editor: --sty
--sty-primary-color: #db3725; // Override primary color manually
--sty-danger-color: #b21f13; // Override danger/error color
--sty-text-color: #001823; // Override text color
--sty-link-color: var(--sty-text-color); // Override link color
--sty-link-decoration: underline;// Override link text decoration style
--sty-link-hover-color: var(--sty-primary-color); // Override link hover state color
--sty-link-hover-decoration: underline; // Override link hover state text decoration style
}
#app.login.registration { ... } // If you want to modify registration block design
#app.login [data-section="panelHeader"] { ... } // If you want to modify the login panel header design
#app.login:not(.identifier) [data-section="panelContainer"] { ... } // If you want to modify the login panel container if the current block is not the identifier
sty-input-phone[focused],
sty-input-text[focused],
sty-input-textarea[focused],
sty-select[focused] {
// Update input-* focused state box shadow
--sty-input-box-shadow: ...;
}
List of CSS variables
Here are examples of the types of variables that can be used. To see the full list, hit the Ctrl + Space keys inside the brand policy IDE.
CSS Variable | Description |
---|---|
--sty-checkbox-border-width | Checkbox "border-width" property |
--sty-tab-slider-color | Tab slider "color" property |
--sty-calendar-disabled-bg | Calendar "background" property |
--sty-link-focus-ring-style | Application link focus-ring "border-style" property |
--sty-calendar-weekday-border-color | Calendar navigation weekday "border-color" property |
--sty-calendar-cell-disabled-color | Calendar cell disabled state "color" property |
--sty-language-selector-color | Language selector "color" property |
--sty-input-list-bg | Input list "background" property |
--sty-button-danger-hover-color | Button danger variant hover "color" property |
--sty-alert-border-width | Alert "border-width" property |
--sty-form-section-description-line-height | Form section description "line-height" property |
--sty-button-info-text-focus-color | Button info-text variant focus "color" property |
--sty-button-success-outline-disabled-bg | Button success-outline variant disabled "background" property |
--sty-toast-box-shadow | Toast "box-shadow" property |
--sty-button-success-hover-bg | Button success variant hover "background" property |
--sty-alert-warning-border-color | Alert warning variant "border-color" property |
--sty-bg-size | Application "background-size" property |
--sty-link-hover-decoration | Application link hover state "text-decoration" property |
--sty-empty-state-line-height | Empty state "line-height" property |
--sty-calendar-panel-year-cell-padding-inline | Calendar year cell "padding-inline" property |
--sty-button-warning-outline-bg | Button warning-outline variant "background" property |
--sty-button-info-outline-disabled-border-color | Button info-outline variant disabled "border-color" property |
--sty-bg | Application "background" property |
--sty-loader-bg-size | Application loader "background-size" property |
--sty-calendar-cell-hover-color | Calendar cell hover state "color" property |
--sty-input-mode | Input mode style (united / separated) |
--sty-alert-info-bg | Alert info variant "background" property |
--sty-button-secondary-outline-color | Button secondary-outline variant "color" property |
--sty-input-color | Input "color" property |
--sty-action-panel-border-radius | Action panel "border-radius" property |
--sty-button-warning-text-disabled-color | Button warning-text variant disabled "color" property |
--sty-button-success-outline-disabled-border-color | Button success-outline variant disabled "border-color" property |
--sty-button-warning-color | Button warning variant "color" property |
--sty-button-secondary-text-bg | Button secondary-text variant "background" property |
--sty-calendar-cell-border-radius | Calendar cell "border-radius" property |
--sty-switch-border-style | Switch "border-style" property |
--sty-input-focus-box-shadow | Input focus state "box-shadow" property |
--sty-h1-font-size | Application <h1> "font-size" property |
--sty-switch-disabled-thumb-bg | Switch disabled state thumb icon "background" property |
--sty-button-info-text-disabled-color | Button info-text variant disabled "color" property |
--sty-menu-item-selected-bg | Menu item selected "background" property |
--sty-switch-border-radius-sm | Switch small size "border-radius" property |
--sty-calendar-box-shadow | Calendar "box-shadow" property |
--sty-bg-attachment | Application "background-attachment" property |
--sty-action-panel-bg | Action panel base "background" property |
--sty-checkbox-focus-ring | Checkbox focus-ring "background" property |
--sty-dialog-danger-color | Dialog danger variant "color" property |
--sty-button-focus-ring-offset | Button focus-ring "margin" property |
--sty-toast-border-style | Toast "border-style" property |
--sty-dialog-backdrop-transition-timing-function | Dialog backdrop "transition-timing-function" property |
JavaScript usage
Events
You can add the following code snippets into the additional script login section.
block-ready
Listen to this event if you want to do something on block change
/**
* Login "block-ready" event.
* Fires on every login block change.
*
* @event block-ready
* @property {BlockReadyEvent} event
*/
document.addEventListener('block-ready', (event) => {
if (event.detail.state.activeBlock === 'identifier') {
// Do something
}
});
/**
* @typedef {Object} BlockReadyEvent
*
* @property {BlockReadyDetail} detail - CustomEvent detail object.
*/
/**
* @typedef {Object} BlockReadyDetail
*
* @property {State} state - Current state.
* @property {State} previousState - Previous state.
*/
/**
* @typedef {Object} State
*
* @property {string} activeBlock - activeBlock value of state.
* @property {Object.<string, Object>} blocks - Stores the state blocks and their data.
* @property {Object.<string, Object>} formValues - Stores the previous or actual state form values.
* @property {Object.<string, Message>} messages - Stores the global or field specific messages.
* @property {Account} account - Stores the login identified account information.
* @property {Organization} organization - Stores the login identified organization information.
*/
/**
* @typedef {Object} Message
*
* @property {string} text - Text of the message.
* @property {string} type - Type of the message. (Possible values: error, info)
*/
/**
* @typedef {Object} Account
*
* @property {string} identifier - Identified account. (Email or username)
*/
/**
* @typedef {Object} Organization
*
* @property {string} name - Identified organization name.
*/
block-request
Listen to this event if you want to do something right after we call
/**
* Login "block-request" event.
* Fires on every login block request.
*
* @event block-request
* @property {BlockRequestEvent} event
*/
document.addEventListener('block-request', (event) => {
if (event.detail.previousState.activeBlock === 'identifier') {
// Do something if an identifier block request response is returned
}
});
/**
* @typedef {Object} BlockRequestEvent
*
* @property {BlockRequestDetail} detail - CustomEvent detail object.
*/
/**
* @typedef {Object} BlockRequestDetail
*
* @property {State} state - Current state.
* @property {State} previousState - Previous state.
* @property {string} block - Name of the block that started the request.
* @property {Object} request - Request data.
* @property {Object} response - Response to the request.
*/
/**
* @typedef {Object} State
*
* @property {string} activeBlock - activeBlock value of state.
* @property {Object.<string, Object>} blocks - Stores the state blocks and their data.
* @property {Object.<string, Object>} formValues - Stores the previous or actual state form values.
* @property {Object.<string, Message>} messages - Stores the global or field specific messages.
* @property {Account} account - Stores the login identified account information.
* @property {Organization} organization - Stores the login identified organization information.
*/
/**
* @typedef {Object} Message
*
* @property {string} text - Text of the message.
* @property {string} type - Type of the message. (Possible values: error, info)
*/
/**
* @typedef {Object} Account
*
* @property {string} identifier - Identified account. (Email or username)
*/
/**
* @typedef {Object} Organization
*
* @property {string} name - Identified organization name.
*/
Updated 7 months ago