Skip to content

Celebrating our new site: 30% off everything with code , until Dec 1.

Bright Themes

Alert boxes for Ghost

Note, info, warning, danger and success boxes to highlight part of a post, each with its own color, icon and label.

  • Works with any Ghost theme

New to Ghost snippets?

Build a card once, save it as a snippet, and add it to any post from the card menu. The tutorial shows each step.

Demo

Note: This box uses the default, neutral style.

Info: The new issue goes out every Friday morning.

Warning: Back up your site before you change the theme.

Danger: Deleting your account can't be undone.

Success: Your settings are saved.

Compare the five types: each has its own icon and label, not only its own color.

When to use it

  • A warning in a tutorial before a step that can't be undone, such as deleting members or changing a domain.
  • A note at the top of an older post saying what has changed since, with a link to the update.
  • A success box after setup steps, telling readers what they should see if it worked.
  • An affiliate or sponsor disclosure in reviews, in the same style and place in every post.

When not to: For a one-off tip, or anything that has to show in the newsletter, Ghost's Callout card does the job with no CSS.

The code

<div class="bt-alert-box">
  <p><strong>Note:</strong> This box uses the default, neutral style.</p>
</div>

<div class="bt-alert-box bt-alert-box-info">
  <p><strong>Info:</strong> The new issue goes out every Friday morning.</p>
</div>

<div class="bt-alert-box bt-alert-box-warning">
  <p><strong>Warning:</strong> Back up your site before you change the theme.</p>
</div>

<div class="bt-alert-box bt-alert-box-danger">
  <p><strong>Danger:</strong> Deleting your account can't be undone.</p>
</div>

<div class="bt-alert-box bt-alert-box-success">
  <p><strong>Success:</strong> Your settings are saved.</p>
</div>

Add it to your site

  1. Copy the CSS and paste it in Settings › Advanced › Code injection › Site headerSettings › Advanced › Code injection › Site header (opens your Ghost Admin in a new tab), between <style> and </style>. Once per site.
  2. In a post, add an HTML card (type /html) and paste the HTML.
  3. Change the example text to your own, then publish or update the post.

Tip

Save the card as a Ghost snippet to add it to any post from the card menu: how Ghost snippets work.

How it works

An alert box is a <div class="bt-alert-box"> with a second class for its type: bt-alert-box-info, bt-alert-box-warning, bt-alert-box-danger or bt-alert-box-success, or none for a neutral note. The prefix keeps a theme’s own .info or .success rules away from it. The type sets one color, which the CSS uses for the rule on the left, the background tint and the outlined icon. The text keeps your theme’s own color, so it stays readable in light and dark themes.

Color is never the only signal: the icon and the bold label at the start of the text say what kind of box it is too. Keep a label when you write your own. Inside the box you can use any HTML: several paragraphs, a list or links.

To add a type of your own, copy one of the type rules in the CSS, give it a new class name, and set --bt-alert-box-accent in it, and --bt-alert-box-icon to an SVG url(…) (a 24×24 drawing in black; it’s used as a mask, filled with the type’s color).

Ghost’s editor has its own Callout card, a highlighted box with an emoji and a background color, which needs no code and also works in newsletters. Use it for a quick tip; use this snippet when you want the same types across your posts. The CSS from code injection doesn’t reach emails, so in a newsletter these boxes show as plain text. See how editor cards work in Ghost and how code injection works.

Customize

VariableDefaultWhat it changes
--bt-alert-box-color#6b7280The color of the default, neutral note.
--bt-alert-box-info#2563ebThe color of info boxes.
--bt-alert-box-warning#d97706The color of warning boxes (an amber dark enough for its icon to read on the tint).
--bt-alert-box-danger#dc2626The color of danger boxes.
--bt-alert-box-success#15803dThe color of success boxes.
--bt-alert-box-rule4pxThe width of the colored rule on the left.
--bt-alert-box-tint8%How much of the box's color tints its background. 0% for no background.
--bt-alert-box-radius4pxThe corner radius.
Works with every Ghost theme, including ours. Something not right? Ask us.

All snippets

Launch a better Ghost site

From a solo newsletter to a busy newsroom, there is a theme that fits. No code needed.