Use custom CSS for a change Styles and block settings do not offer. You can add CSS for the whole theme, or for one block or section.
Add CSS for the whole theme
Open your project in Fantasma.
In the icon rail, the narrow bar of icons along the edge of the editor, click the paintbrush icon, Styles.
Click Custom CSS.
Enter your CSS in the CSS field. The canvas shows the result as you type.
The field holds up to 20,000 characters. Past that, it shows "Custom CSS exceeds 20,000 characters. Shorten it to apply and save your changes." and keeps the last saved version that fit.
This CSS applies to every template. In the theme file it loads after the theme's own styles and after what Ghost adds to the page head, including Ghost Admin's code injection. When a rule here and a theme rule select the same element equally, yours wins.
You can also reach this field from Project settings. Under Custom code, next to Custom CSS, click Open in Styles.
Add CSS to one block or section
On the canvas, select the block or section.
In the right sidebar, click the plus button next to Advanced.
Select Custom CSS.
Enter your CSS in the Custom CSS field.
This CSS applies only to the block and what is inside it. Declarations at the top apply to the block itself. Write &:hover for the moment the pointer is over it, and a selector such as img for elements inside it:
If a bracket, a quote, a comment or a url( is left open, the field shows "A bracket, string, comment or URL is not closed. This CSS is not applied until it is." and none of the block's custom CSS applies until you close it. This field also holds up to 20,000 characters.
Give a block your own CSS classes
To add class names, click the plus button next to Advanced and select CSS classes. Enter the names separated by spaces. Then style every block with that class from the CSS field in Styles › Custom CSS:
The field also takes Tailwind CSS utility classes, and the theme builds the CSS for them. For example, uppercase tracking-widest sets a heading in spaced capitals, and md:hidden hides a block on screens 768 px wide and wider.
CSS variables
The theme sets these variables from your Styles. When you change a color or a size in Styles, CSS that uses its variable changes with it.
Colors
The color variables hold the colors of the scheme and mode each element sits in, so the same CSS works in a dark section and a light one.
Variable
Color in Styles
--background
Background
--foreground
Text
--accent, --accent-foreground
Accent, and the text on it
--primary, --primary-foreground
Primary, and the text on it
--secondary, --secondary-foreground
Secondary, and the text on it
--muted
Muted
--muted-foreground
Muted text
--border
Border
--input
Input
--success, --success-foreground
Success, and the text on it
--error, --error-foreground
Error, and the text on it
--warning, --warning-foreground
Warning, and the text on it
--notice, --notice-foreground
Notice, and the text on it
To replace a color in every scheme and both modes, set its --fs- version on :root in the CSS field in Styles › Custom CSS. It works for every color above except the four status colors and the text on them:
Use custom CSS for a change Styles and block settings do not offer. You can add CSS for the whole theme, or for one block or section.
Add CSS for the whole theme
Open your project in Fantasma.
In the icon rail, the narrow bar of icons along the edge of the editor, click the paintbrush icon, Styles.
Click Custom CSS.
Enter your CSS in the CSS field. The canvas shows the result as you type.
The field holds up to 20,000 characters. Past that, it shows "Custom CSS exceeds 20,000 characters. Shorten it to apply and save your changes." and keeps the last saved version that fit.
This CSS applies to every template. In the theme file it loads after the theme's own styles and after what Ghost adds to the page head, including Ghost Admin's code injection. When a rule here and a theme rule select the same element equally, yours wins.
You can also reach this field from Project settings. Under Custom code, next to Custom CSS, click Open in Styles.
Add CSS to one block or section
On the canvas, select the block or section.
In the right sidebar, click the plus button next to Advanced.
Select Custom CSS.
Enter your CSS in the Custom CSS field.
This CSS applies only to the block and what is inside it. Declarations at the top apply to the block itself. Write
&:hoverfor the moment the pointer is over it, and a selector such asimgfor elements inside it:If a bracket, a quote, a comment or a
url(is left open, the field shows "A bracket, string, comment or URL is not closed. This CSS is not applied until it is." and none of the block's custom CSS applies until you close it. This field also holds up to 20,000 characters.Give a block your own CSS classes
To add class names, click the plus button next to Advanced and select CSS classes. Enter the names separated by spaces. Then style every block with that class from the CSS field in Styles › Custom CSS:
The field also takes Tailwind CSS utility classes, and the theme builds the CSS for them. For example,
uppercase tracking-widestsets a heading in spaced capitals, andmd:hiddenhides a block on screens 768 px wide and wider.CSS variables
The theme sets these variables from your Styles. When you change a color or a size in Styles, CSS that uses its variable changes with it.
Colors
The color variables hold the colors of the scheme and mode each element sits in, so the same CSS works in a dark section and a light one.
Variable
Color in Styles
--backgroundBackground
--foregroundText
--accent,--accent-foregroundAccent, and the text on it
--primary,--primary-foregroundPrimary, and the text on it
--secondary,--secondary-foregroundSecondary, and the text on it
--mutedMuted
--muted-foregroundMuted text
--borderBorder
--inputInput
--success,--success-foregroundSuccess, and the text on it
--error,--error-foregroundError, and the text on it
--warning,--warning-foregroundWarning, and the text on it
--notice,--notice-foregroundNotice, and the text on it
To replace a color in every scheme and both modes, set its
--fs-version on:rootin the CSS field in Styles › Custom CSS. It works for every color above except the four status colors and the text on them:Fonts and text styles
Variable
Holds
--font-heading,--font-body,--font-monoThe headings, body and monospace fonts
--fs-font-size-xs,-sm,-md,-lg,-xl,-2xl,-3xl,-4xlThe font sizes Extra small to 4X large
--fs-text-<style>-font,-size,-weight,-style,-line-height,-letter-spacing,-caseEach setting of a text style.
<style>istext,h1toh6,caption,quoteorcode.--fs-text-link-weight,--fs-text-link-style,--fs-text-link-decorationThe Links style
--fs-content-h1-sizeto--fs-content-h6-sizeThe In posts size of each heading level
For example,
font-size: var(--fs-text-h3-size);gives an element the size of an H3 heading.Widths and spacing
Variable
Holds
--container-wide,--container-standard,--container-narrow,--container-fullThe four Container widths
--fs-space-0,-2,-6,-10,-16,-24,-32,-42The spacing presets None, Tiny, Small, Regular, Medium, Large, Extra Large and Huge
--fs-section-gapBetween sections
Corners and shadows
Variable
Holds
--radius-corner-none,-xs,-s,-m,-l,-xl,-2xl,-fullThe corner presets None to Full
--radius-cardCards and sections
--shadow-sm,--shadow-md,--shadow-lg,--shadow-xlThe shadows Small to Extra large
Motion
Variable
Holds
--fs-duration-quick,--fs-duration-default,--fs-duration-slowThe durations Quick, Default and Slow
--fs-easing-subtle,--fs-easing-balanced,--fs-easing-expressiveThe easings Subtle, Balanced and Expressive
Custom presets have no variable name you can see in Styles, so use the theme presets above in CSS.
Fantasma saves your CSS as you type. Your Ghost site shows it after you publish your theme.