Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Nova Swatches

Nova Swatches Laravel Package

ynacorp/nova-swatches

A Laravel Nova field that lets you display and select colors as visual swatches, making color attributes easier to manage in Nova resources with a clean, compact admin UI.

View on GitHub
Deep Wiki
Context7

Nova Swatches adds a clean, swatch-based color selector to Laravel Nova resource forms. Instead of free-form color input, it lets users choose from predefined colors, keeping admin interfaces consistent and stored values easy to manage.

  • Add a swatch field to any Nova resource.
  • Configure a custom color palette.
  • Select colors visually in forms.
  • Store the chosen swatch value with the model.
  • Lightweight integration with standard Nova field APIs.
Frequently asked questions about Nova Swatches
How do I install nova-swatches in a Laravel Nova application?
Install it with composer require ynacorp/nova-swatches, then run php artisan nova:publish and php artisan view:clear. Register the field in your resource's fields method with a single make() call on your color column. Before using it in production, confirm who controls the Packagist namespace and pin an exact tag rather than a caret constraint.
Is nova-swatches compatible with Laravel Nova 4 and Nova 5?
A custom Nova field is only a stable contract within a single Nova major version, and Nova 4 to 5 moved to Vue 3 with revised asset registration. Check the laravel/nova constraint in the package composer.json and verify it covers the major you actually run. If it pins ^4.0 and you are on Nova 5, treat it as a front-end rebuild rather than a drop-in field.
How do I configure a custom color palette for the swatch field?
The palette is configured through fluent setters on the field, typically a key-to-color map, and the selected key is stored in a plain string column. Because the README may lag the code, read src/ for the exact setter names. Each withMeta() key in resources/js maps one to one to a PHP setter, which is the quickest way to confirm the real API surface.
What format does nova-swatches store in the database?
The package stores a plain string, so the canonical format follows whatever you define in the palette, commonly a #RRGGBB hex value. Decide in advance whether an empty selection means null or an empty string, and whether alpha (#RRGGBBAA) will ever be needed. A string('accent_color', 9)->nullable() column is a cheap hedge that costs nothing today.
Does the swatch field validate that the submitted color is in the palette?
No. The swatch UI is a suggestion, not an enforcement, so any user with the field open can POST an arbitrary string. Add Rule::in(array_keys($palette)) to the field rules, plus a hex regex if arbitrary input is ever permitted. That validation line is the highest-value code in the entire integration and it does not ship with the package.
Does nova-swatches support nullable fields and dependsOn conditions?
It uses the standard Nova field APIs, so nullable and dependsOn should behave as they do for core fields. The risk is that custom Vue fields commonly cache props on mount and fail to re-render reactively, so test dependsOn explicitly on a single resource first. Also confirm how the component renders when the underlying column is null.
Why does my swatch field appear blank in staging but work locally?
That is almost always stale published assets rather than a bug in the field. Run nova:publish as part of your deploy script, not just on your local machine, and follow it with view:clear if compiled components or views are cached. Isolating the field on one resource makes this fast to confirm.
Who maintains nova-swatches and is it safe for production?
The package publishes from the ynacorp Packagist namespace but lives in the triolla-io/nova-swatches repository, which is a governance question worth resolving before it enters a production composer.lock. With roughly 22 stars and zero dependents, the README is effectively the only documentation and may lag the code. Pin an exact tag and keep a fork or replacement path open.
What are the alternatives to nova-swatches for color input in Laravel Nova?
If you only need a handful of colors, a Nova Select field populated from an enum or config array gives you built-in validation and zero front-end risk. If you need arbitrary color picking, a maintained picker field or a small custom field of your own may be safer. nova-swatches makes sense when a constrained palette is the actual requirement.
Is the nova-swatches color picker accessible via keyboard?
Color pickers are a known failure mode for keyboard navigation, focus management, and contrast, and nothing in this package claims to address that. Test keyboard-only selection and focus rings on a single resource before exposing it to admins. If it fails, wrap it or fall back to a Select field for the same palette.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console