Skip to main content

usePaletteService

Use usePaletteService to load the colors that belong to a color palette, for example to render a custom color picker. Like useMediaService, it returns a plain object of async methods and configures ApiClient on first use with the configurator's apiBaseUrl and apiToken.

Getting the service

import { usePaletteService } from "@expivi/product-configurator";

const palette = usePaletteService(configurator);

Example: read a palette's colors

const palette = usePaletteService(configurator);

const { colors } = await palette.getPaletteColors(paletteId);

API

getPaletteColors(paletteId, params?)

Loads colors for a single palette id. params is an optional PaletteColorsSearchParams for pagination or filtering (depending on the backing API). Resolves to a PaletteColorsResponse.