Styling with SDK

CSS Sanitization

Pay 3x or 4x over an agreed period

To style the element inside the iframe, use the SDK to inject your CSS rules. Valid CSS is required by the SDK. If syntax errors occur (missing semicolons, braces, etc.), the SDK attempts to preserve as many valid rules as possible.


CSS Sanitization

CSS Sanitization is a process that checks and cleans up CSS code to prevent potential security risks and ensure the code is valid. There are some limitations to the CSS rules you can inject into the iframe:

Inside the iframe, only the element #text can be styled. You can style #text:focus, #text:hover, and the toggling classes for this element:

  • .invalid
  • .valid
  • .not-empty

The best practice is to always prefix CSS selectors with #text to ensure they pass the sanitization process.

You can only use the following properties:

Typography

TypographyProperties
Font Propertiesfont, font-family, font-size, font-size-adjust, font-smooth, font-stretch, font-style, font-variant, font-variant-alternates, font-variant-caps, font-variant-east-asian, font-variant-ligatures, font-variant-numeric, font-weight
Text Propertiestext-decoration, text-shadow, text-transform
Other Typography Propertiesline-height, letter-spacing, unicode-bidi, direction

Visual Effects

Visual EffectsProperties
outline, opacity, transition, -moz-transition, -webkit-transition

Browser-Specific Properties

Browser-Specific PropertiesProperties
-moz-osx-font-smoothing, -webkit-font-smoothing, -moz-tap-highlight-color, -webkit-tap-highlight-color

For example:

If you inject the following style, our CSS sanitizer will remove all unauthorized rules and properties before injecting the style into the iframe:

Before

#text {
  background: url('https://abc.com/a.png'); /* unauthorized */
  color: black;
}
.valid:hover {
  position: absolute; /* unauthorized */
  margin: 5px; /* unauthorized */
  font-size: 1.2em;
}
/* th