A profile can carry a saved custom stylesheet. Davi sanitizes it, scopes it to one profile body, and drops anything outside the contract below. The authored source is stored as written; the rendered stylesheet is always the sanitized form.
This page describes the stylesheet contract. Writing CSS is not part of the
public API: a profile template carries theme.custom_css, and a profile's saved
owner stylesheet lives in its document at theme.overrides.custom_css. There is
no CSS editor in the API or a public endpoint that accepts a stylesheet.
Where the stylesheet applies
A profile body is mounted inside a generated scope element. The server binds
every accepted selector to that element — prefixing ordinary selectors, and
using it directly for :scope — so a stylesheet can only reach the profile it
belongs to: never the page header, the footer, the editor toolbar, another
profile, or a dialog rendered beside it.
:scope addresses the profile body itself. Any other selector addresses a
descendant of it:
/* The profile body only. */
:scope {
border-radius: 16px;
}
/* A child within it. */
:scope > [data-section="identity"] {
padding: 24px;
}
:scope stands alone. It cannot be followed by a combinator or suffixed with a
class, id or attribute; write the descendant rule instead.
Stable selectors
The renderer exposes a small set of attributes that survive layout and component changes. Target these, not class names, element structure or React internals — those are implementation details even where a selector happens to match.
| Selector | Matches |
|---|---|
[data-section="identity"] | The identity card (name, avatar, headline, role) |
[data-section="main"] | The main profile section |
[data-section-type="main"] | The main section by type |
[data-part="socials"] | The social links part |
[data-part="connect"] | The connect button part |
[data-part="call_to_action"] | The call-to-action part |
[data-part="links"] | The links part |
[data-part="blocks"] | The long-form blocks part |
[data-part="socials"] {
gap: 12px;
}
[data-section="identity"] > * {
color: #1e58a4;
}
Accepted syntax
The stylesheet is at most 10,000 bytes. Accepted input is:
- Qualified style rules.
@mediarules whose conditions arewidth,min-widthormax-width(a0, or a length inpx,emorrem),prefers-color-scheme(lightordark), orprefers-reduced-motion(reduceorno-preference). Conditions combine withandand comma alternatives, up to four levels deep.
Other at-rules are handled by name. A known at-rule outside that set —
@import, @font-face, @keyframes, @supports, @layer, @property,
@container, @scope and the rest of the sanitizer's fixed list — is dropped,
and the rest of the stylesheet still applies. A vendor-prefixed at-rule such as
@-webkit-keyframes is dropped the same way. An at-rule name the sanitizer does
not recognize refuses the whole stylesheet: nothing from that input applies.
Selectors accept:
- Type, universal, class and id compounds, and descendant or child (
>) combinators. - The stable
data-section,data-section-typeanddata-partattributes, with an exact value or a bare existence check. - The
:hover,:focus,:focus-visible,:focus-within,:active,:disabled,:first-childand:last-childpseudo-classes. - The
::beforeand::afterpseudo-elements.
Sibling combinators, nesting (&), namespaces, :is(), :where(), :not(),
:has(), :nth-*, :root, :host and :visited are not accepted. A selector
branch using one is removed; the other branches in the same selector list stay.
Declarations accept a fixed set of property families:
| Family | Properties |
|---|---|
| Colour and paint | color, background-color, background-image, background-size, background-position, background-repeat |
| Borders | border, border-{top,right,bottom,left}, border width/style/colour, border-radius and its corners |
| Spacing and size | margin, padding, their longhands, width, height, min-*, max-* |
| Layout | display (none, block, inline, inline-block, flex, inline-flex, grid, inline-grid), gap, row-gap, column-gap, flex and grid alignment/placement, box-sizing, overflow |
| Type | font-size, font-weight, font-style, line-height, letter/word spacing, text-align, text-decoration, text-transform, white-space, overflow-wrap, word-break |
| Effects and position | opacity, box-shadow, text-shadow, position (static, relative, absolute), inset and longhands, z-index, transform, transform-origin |
Values are validated by property, not just by name. Unknown, vendor and custom
properties, !important, all, animation and transition properties,
font-family, content, position: fixed and position: sticky are dropped.
var() and env() are not accepted.
url() is accepted only in background-image, and only for an HTTPS URL on an
asset origin Davi serves. Signed URLs, query strings, fragments and relative
URLs are dropped.
Removed declarations, not a failed save
Sanitizing is per declaration: a stylesheet with one disallowed declaration keeps every other accepted declaration and the save succeeds. If nothing survives — every declaration stripped, or an empty stylesheet — the profile renders with no custom CSS and the stored source remains what was written.
The response carries the sanitized stylesheet, not the source. A client cannot tell from rendering alone which rules were removed; preview the saved result if that matters.
Fonts
Font loading and font families are not part of the contract. fonts is reserved
and must be null, @font-face is dropped, and font-family is not accepted.
font-size, font-weight, font-style and line-height style the fonts the
profile already uses.
When it stops applying
Custom CSS is a Davi Pro feature. An owner's stylesheet applies while the plan grants it and for 30 days after the plan ends. After that window the stylesheet stops applying, but the profile's saved source, omission metadata and other settings are retained: restoring Pro restores the same rendering, and no re-save is required.
A stylesheet supplied by an eligible profile template is the template author's effect, not the owner's, and follows the template's own approval and grant rather than the owner's plan.
CSS can hide the connect button
An accepted rule can make the connect button invisible:
[data-part="connect"] {
display: none;
}
The button is still present in the document; the rule only hides it while the stylesheet applies. This is why a downgrade restores the button: once the stylesheet stops applying, the hidden part renders again. Removing the connect section from the profile is a separate, explicit editor action, and hiding it with CSS is not a substitute for it.