Skip to main content
Version: Latest

Branding Colors

Provide a curated set of brand colors in the editor's color picker so users stay on-brand without memorizing hex codes.

import { useRef } from "react";
import { DragbleEditor, DragbleEditorRef } from "dragble-react-editor";

function BrandedColorEditor() {
const editorRef = useRef<DragbleEditorRef>(null);

return (
<DragbleEditor
ref={editorRef}
editorKey="db_your_key"
editorMode="email"
options={{
brandingColors: {
colors: [
{ label: "Primary", value: "#6366f1" },
{ label: "Secondary", value: "#ec4899" },
{ label: "Dark", value: "#1e1b4b" },
{ label: "Light", value: "#f5f3ff" },
{ label: "Success", value: "#10b981" },
{ label: "Warning", value: "#f59e0b" },
],
defaultColors: true,
},
}}
/>
);
}

Brand colors appear as a dedicated row of swatches at the top of every color picker in the editor.

Update colors at runtime

// React
editorRef.current?.editor?.setBrandingColors({
colors: [
{ label: "New Primary", value: "#2563eb" },
{ label: "New Secondary", value: "#7c3aed" },
],
defaultColors: true,
});

// Vanilla JS
dragble.setBrandingColors({
colors: [
{ label: "New Primary", value: "#2563eb" },
{ label: "New Secondary", value: "#7c3aed" },
],
});

:::tip Default colors Set defaultColors: true (default) to show the default preset colors below the brand colors. Set defaultColors: false to hide them and only show brand colors. :::

:::info Color format Colors must be 6-digit hex values (e.g., #6366f1). The label is shown as a tooltip when hovering over the swatch. :::

Method reference

MethodReturnsDescription
setBrandingColors(config)voidReplace brand color palette at runtime

Next steps