bogdancondorachi/kirby-colour-swatch-field

Colour swatch field for Kirby CMS

Fund package maintenance!
bogdancondorachi

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:Vue

Type:kirby-plugin

pkg:composer/bogdancondorachi/kirby-colour-swatch-field

1.0.0 2025-09-26 14:48 UTC

This package is auto-updated.

Last update: 2025-10-26 15:03:29 UTC


README

Note

A simple color field extention that allows to pass options like 'hex', 'class' or 'title' for Kirby CMS.

📦 Installation

Composer

composer require bogdancondorachi/kirby-colour-swatch-field

Git Submodule

git submodule add https://github.com/bogdancondorachi/kirby-colour-swatch-field.git site/plugins/colour-swatch-field

Manual

Download the plugin and extract it to: /site/plugins/colour-swatch-field

⚙️ Usage

Add the field to your blueprint:

bgColor:
  label: Background Color
  type: swatch
  options:
    amber:
      hex: 'FFB900'
      title: Amber
      class: bg-amber-400
    emerald:
      hex: '009966'
      title: Apricot
      class: bg-emerald-600
    white:
      hex: 'FFFFFF'
      title: White
      class: bg-white
    black:
      hex: '000000'
      title: Black
      class: bg-black

Use the field in your template:

// Outputs the selected color title as a string
$page->bgColor()->toSwatch('title')

// Outputs the selected color hex code as a string (without preceding #)
$page->bgColor()->toSwatch('hex')

// Outputs the selected color class as a string
$page->bgColor()->toSwatch('class')

🙏 Credits

📜 License

MIT License Copyright © 2024 Bogdan Condorachi