filamentphp/filament · error · LogicException

At least one `darkBackground()` candidate must be configured

Error message

At least one `darkBackground()` candidate must be configured before calling `get()`.

What it means

Error "At least one `darkBackground()` candidate must be configured before calling `get()`." thrown in filamentphp/filament.

Source

Thrown at packages/support/src/View/Components/ColorMaps/ButtonComponentColorMap.php:92

     */
    public function darkBackground(int $bg, int $hover, ?int $alternateHover = null): static
    {
        $this->darkBackgrounds[] = ['bg' => $bg, 'hover' => $hover, 'alternateHover' => $alternateHover];

        return $this;
    }

    /**
     * @return array<string, int>
     */
    public function get(): array
    {
        if (empty($this->lightBackgrounds)) {
            throw new LogicException('At least one `lightBackground()` candidate must be configured before calling `get()`.');
        }

        if (empty($this->darkBackgrounds)) {
            throw new LogicException('At least one `darkBackground()` candidate must be configured before calling `get()`.');
        }

        $textForBg = $this->resolveTextForEachBackground();

        $textLightness = $this->probeTextLightness($textForBg);

        [$bg, $hoverBg] = $this->pickBackgroundShades($textLightness, $this->lightBackgrounds);
        [$darkBg, $darkHoverBg] = $this->pickBackgroundShades($textLightness, $this->darkBackgrounds);

        return [
            'bg' => $bg,
            'hover:bg' => $hoverBg,
            'dark:bg' => $darkBg,
            'dark:hover:bg' => $darkHoverBg,
            'text' => $textForBg[$bg] ?? 0,
            'hover:text' => $textForBg[$hoverBg] ?? 0,
            'dark:text' => $textForBg[$darkBg] ?? 0,
            'dark:hover:text' => $textForBg[$darkHoverBg] ?? 0,

View on GitHub (pinned to 53483fa934)

When it happens

Trigger: Thrown at packages/support/src/View/Components/ColorMaps/ButtonComponentColorMap.php:92 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of filamentphp/filament@53483fa934 (2026-08-17). Data as JSON: /api/errors/32f63f38af78a99b. Report an issue: GitHub.