Admonitions API
The Admonitions plugin exposes a programmatic API that other plugins can use to register, remove, and inspect admonition types at runtime.
Accessing the Plugin
PermalinkThere is no separate API object — methods are accessed directly on the plugin instance:
const plugin = this.app.plugins.plugins["obsidian-admonition"];
Admonition Management
PermalinkaddAdmonition(admonition: Admonition): Promise<void>
Permalink
Registers a new custom admonition type. Updates CSS and saves settings.
await plugin.addAdmonition({
type: "my-type",
title: "My Type",
icon: { type: "font-awesome", name: "star" },
color: "200, 50, 50",
command: false,
iconWithCss: false,
noTitle: false,
copy: false,
});
removeAdmonition(admonition: Admonition): Promise<void>
Permalink
Removes a custom admonition type. Cleans up CSS and saves settings.
// Look up the admonition object first, then remove it
const admonition = plugin.admonitions["my-type"];
if (admonition) {
await plugin.removeAdmonition(admonition);
}
admonitions: Record<string, Admonition> (getter)
Permalink
Returns all available admonition types — both built-in and user-defined — keyed by type name.
const all = plugin.admonitions;
// { note: {...}, tip: {...}, "my-type": {...}, ... }
admonitionArray: Array<Admonition & { type: string }> (getter)
Permalink
Returns all admonitions as an array with the type property included on each object.
for (const admonition of plugin.admonitionArray) {
console.log(admonition.type, admonition.icon);
}
types: string[] (getter)
Permalink
Returns an array of all registered admonition type names.
console.log(plugin.types);
// ["note", "tip", "warning", "my-type", ...]
Icon Management
PermalinkIcon operations are delegated to plugin.iconManager.
downloadIcon(pack: DownloadableIconPack): Promise<void>
Permalink
Downloads an optional icon pack.
await plugin.downloadIcon("rpg");
removeIcon(pack: DownloadableIconPack): Promise<void>
Permalink
Removes a downloaded icon pack.
await plugin.removeIcon("rpg");
Type Definitions
PermalinkAdmonition
Permalink
See JSON Specification for the full Admonition interface with field descriptions.
interface Admonition {
type: string;
title?: string;
icon: AdmonitionIconDefinition;
color: string;
command: boolean;
iconWithCss?: boolean;
/** @deprecated Use iconWithCss instead. */
injectColor?: boolean;
noTitle: boolean;
copy?: boolean;
}
AdmonitionIconDefinition
Permalink
type AdmonitionIconDefinition = {
type?: IconType;
name?: string; // Exact icon name from the chosen icon pack
};
type IconType =
| "obsidian"
| "image"
| DownloadableIconPack;
// Downloadable packs (can be enabled in Settings → Icon Packs)
type DownloadableIconPack =
| "fas" // Font Awesome Solid
| "far" // Font Awesome Regular
| "fab" // Font Awesome Brands
| "octicons" // GitHub Octicons
| "rpg"; // RPG Awesome
The legacy "font-awesome" type string is still accepted for backwards compatibility and is automatically migrated to the appropriate fas/far/fab pack. As of v12.0.4, Font Awesome packs are downloadable like other packs; existing users with Font Awesome icons are migrated automatically.
Prefer addAdmonition / removeAdmonition over mutating plugin.data.userAdmonitions directly. Those methods also update the injected CSS and persist settings to disk.