> For the complete documentation index, see [llms.txt](https://docs.scaleflex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scaleflex.com/portals/building-a-portal/custom-css.md).

# Custom CSS

Add your own CSS when the Style panel doesn't go far enough.

The **Code** tab in the builder sidebar lets you add CSS of your own, for the things the [Style](https://docs.scaleflex.com/portals/building-a-portal/style.md) panel doesn't cover.

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FHIxMCWajg9NC5Bw5Rs8Z%2Fimage.png?alt=media&#x26;token=b62ddcb3-fe31-4aa6-a797-2e58c607b011" alt=""><figcaption><p>The <strong>Code</strong> tab in the builder sidebar, where custom CSS is written.</p></figcaption></figure>

## Add CSS

1. Open the **Code** tab.
2. Turn on **Enable custom CSS**.
3. Write your rules in **Your CSS**.
4. Select **Publish changes** to make them live.

**Full screen** gives you more room — **Exit full screen** comes back. The **Styling reference** panel lists the classes and variables the Portal exposes, so you target what the templates actually render rather than guessing; **Back to editor** returns from it.

**Clear** empties the editor.

## Writing it with AI

The **AI-generated** tab is for people who know what they want the Portal to look like but not which rules produce it.

**Copy AI prompt** puts a prompt on your clipboard — the button confirms with **Copied!** — already carrying the context an assistant needs: the classes and variables this Portal exposes. Paste it into the assistant of your choice, describe the change in your own words, and bring the CSS back into **Your CSS**.

The point of the prompt is that it stops the assistant inventing class names. An assistant asked cold will confidently target selectors your Portal has never rendered.

{% hint style="info" %}
Whatever comes back is still yours to check. Read it before you apply it, and keep it as small as what you actually asked for.
{% endhint %}

## Where it lands

Your CSS is applied **after** everything else the Portal loads — its theme, its layout, and the styles each section brings. That is what lets a short rule win without a pile of `!important`: where your rule and the theme's are equally specific, yours is the one that takes effect.

It also means the rest of the Portal cannot defend itself against a careless selector. A rule written broadly enough will reach into parts of the Portal you weren't looking at.

## When to use it, and when not to

Reach for the Style panel first. Anything you set there follows the Portal — it survives theme changes, adapts across device widths, and keeps working when sections gain variants. Custom CSS does none of that on its own.

Custom CSS is right for the genuinely specific: a brand detail the panel has no control for, a tweak to one section. It is wrong for things like colours and type, which have proper controls.

{% hint style="warning" %}
Custom CSS is not checked against anything. A rule that targets an internal class can stop working when that part of the Portal is rebuilt, and nothing will warn you — the Portal will simply look wrong. Keep it small, and prefer the variables in the styling reference to class names.
{% endhint %}

{% hint style="info" %}
The `<` character is removed from custom CSS before it reaches a visitor, for safety. CSS has no need for it outside string literals, but it does mean a `<` you type will quietly disappear.
{% endhint %}
