Skip to main content

Installation

npm install @sanity-labs/logo-soup jquery@^4
Supports jQuery 4.x. Auto-installs onto window.jQuery if available.

Quick Start

Install the plugin, then call .logoSoup() on any jQuery selection:
import $ from "jquery";
import { install } from "@sanity-labs/logo-soup/jquery";

install($);

$("#logos").logoSoup({
  logos: [
    { src: "/logos/acme.svg", alt: "Acme Corp" },
    { src: "/logos/globex.svg", alt: "Globex" },
    { src: "/logos/initech.svg", alt: "Initech" },
  ],
  baseSize: 48,
  alignBy: "visual-center-y",
});
The plugin automatically renders normalized logos into the target element.

Plugin API

Installation

import $ from "jquery";
import { install } from "@sanity-labs/logo-soup/jquery";

install($);
If window.jQuery exists, the plugin auto-installs.

Initialization

$(selector).logoSoup(options);
Initializes Logo Soup on the selected element(s). Returns the jQuery object for chaining. Options: All standard processing options plus:
OptionTypeDefaultDescription
logos(string | LogoSource)[]requiredArray of logo URLs or objects
baseSizenumber48Target size in pixels
scaleFactornumber0.5Shape handling balance
densityAwarebooleantrueScale dense logos
densityFactornumber0.5Density effect strength
cropToContentbooleanfalseCrop whitespace
contrastThresholdnumber10Content detection threshold
backgroundColorstring | [r,g,b]autoBackground color hint
alignByAlignmentMode"visual-center-y"Alignment mode
gapnumber | string28Space between logos
onReady(logos) => void-Callback when ready
onError(error) => void-Error callback

Methods

Update Logos

$("#logos").logoSoup("process", { logos: newLogos });
Updates the logos and triggers re-processing.

Wait for Ready

const logos = await $("#logos").logoSoup("ready");
console.log("Loaded", logos.length, "logos");
Returns a native Promise that resolves with normalized logos when ready.
Uses native Promise (not jQuery Deferred) to support jQuery 4 slim builds.

Destroy

$("#logos").logoSoup("destroy");
Cleans up the engine, unsubscribes listeners, and clears the container.

Get Instance

const instance = $("#logos").logoSoup("instance");
if (instance) {
  const state = instance.engine.getSnapshot();
}
Returns the internal instance object (engine, options, unsubscribe).

Examples

import $ from "jquery";
import { install } from "@sanity-labs/logo-soup/jquery";

install($);

$("#logos").logoSoup({
  logos: [
    { src: "/logos/acme.svg", alt: "Acme Corp" },
    { src: "/logos/globex.svg", alt: "Globex" },
    { src: "/logos/initech.svg", alt: "Initech" },
  ],
  baseSize: 48,
  gap: 32,
  alignBy: "visual-center-y",
});

Data Attributes

The plugin sets data-logo-soup-loading on the container element:
<div id="logos" data-logo-soup-loading="true"><!-- logos --></div>
You can use this for CSS-based loading states:
#logos[data-logo-soup-loading="true"] {
  opacity: 0;
}

#logos[data-logo-soup-loading="false"] {
  opacity: 1;
  transition: opacity 0.3s;
}

Instance Storage

The plugin stores instance data using $.data():
const instance = $.data(element, "logoSoup");
// { engine, unsubscribe, options }

Chaining

All methods return the jQuery object for chaining:
$("#logos")
  .logoSoup({ logos: ["/logo1.svg"] })
  .addClass("active")
  .fadeIn();

TypeScript

The plugin extends jQuery’s type definitions:
import type {
  LogoSoupPluginOptions,
} from "@sanity-labs/logo-soup/jquery";

import type {
  LogoSource,
  NormalizedLogo,
  AlignmentMode,
} from "@sanity-labs/logo-soup";

declare global {
  interface JQuery {
    logoSoup(options: LogoSoupPluginOptions): JQuery;
    logoSoup(method: "process", options: ProcessOptions): JQuery;
    logoSoup(method: "destroy"): JQuery;
    logoSoup(method: "ready"): Promise<NormalizedLogo[]>;
    logoSoup(method: "instance"): LogoSoupInstance | undefined;
  }
}

See Also

Build docs developers (and LLMs) love