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

Row Background Laravel Package

upline/row-background

A small Laravel package for adding alternating row background colors to tables and lists, with configurable shades and Blade-friendly helpers to keep data-heavy views readable at a glance.

View on GitHub
Deep Wiki
Context7

Getting Started

This field paints a Nova resource's index rows a given background color, which makes it a pure presentational field — it does not persist anything itself. Get it in place in three steps:

  1. Install into the Nova app: composer require upline/row-background. Since the package has 0 stars and 0 dependents, pin the version explicitly ("upline/row-background": "1.*") and read src/ before shipping to production. There is no ecosystem of examples to lean on, so the source is your documentation.
  2. Register the field in the resource's fields() method, typically near the top so it reads clearly:
    use Upline\RowBackground\RowBackground;
    
    public function fields(Request $request)
    {
        return [
            RowBackground::make()->color(fn ($model) => $model->status->color()),
            ID::make()->sortable(),
            // ...
        ];
    }
    
    The field resolves a color string (hex or CSS color) per row; how that resolution is wired exactly (->color(), a model attribute, withMeta()) is the first thing to confirm in the package source — it's small enough to read in a few minutes.
  3. First use case: color-code a status or priority column. Pair it with the model's existing enum or cast so the color logic lives in one place, not duplicated in the field.

If your Nova version isn't explicitly supported in composer.json, test a single resource before rolling it out across a panel.

Implementation Patterns

Derive the color, don't store it. The field is a view concern; keep the source of truth in an enum, accessor, or cast. A clean pattern:

enum TicketStatus: string
{
    public function rowColor(): string
    {
        return match($this) {
            self::Open    => '#dbeafe',
            self::Overdue => '#fee2e2',
            self::Closed  => '#e5e7eb',
        };
    }
}

Then RowBackground::make()->color(fn ($ticket) => $ticket->status->rowColor()). Colors stay testable and versionable.

Fallback for null/missing values. Always guard: fn ($m) => $m->status?->rowColor() ?? 'transparent'. Without a fallback, a null status can leave the row with an empty or unexpected background and you'll chase a "broken" row that's really just unset data.

Conditional highlighting for at-a-glance triage. The strongest day-to-day use is surfacing outliers: overdue invoices red, unassigned items amber, healthy rows neutral. Combine with a Badge on the same column so the color is reinforced by text — never rely on color alone for meaning (accessibility and color-blind users).

Compute once, avoid accessor overhead. If the color depends on a query (e.g. counts, relations), the field callback runs per row during index rendering. On a 50-row index that's 50 evaluations — fine — but if each one hits the database you're building an N+1. Push the logic into indexQuery() with eager loading or a withCount, and make the callback a cheap read on already-loaded data.

Keep the color rules in one class. For panels with many resources, a small RowColorPalette service (or enum trait) beats scattering hex codes across resources. When the design team changes the palette, you edit one file.

Don't overload it. It's tempting to encode urgency, category, and SLA state into one row color. Pick one dimension per resource; anything more becomes noise and the colors stop conveying anything.

Gotchas and Tips

  • Display-only, no storage. If the field's computed value never changes, the row won't restyle on filter/page changes beyond Nova's normal re-render — but confirm the package re-evaluates per row rather than caching meta aggressively. If colors look stale, the meta()/withMeta() payload is the first place to look.
  • Nova version compatibility is the real risk. With zero dependents there's no trail of working/failing versions. Check composer.json constraints against your Nova major version and smoke-test the index view; silent breakage (field renders, no color applied) is the most likely failure mode.
  • Dark mode contrast. A pastel #dbeafe reads well on white but can look washed out or glare on Nova's dark theme. If you support dark mode, keep backgrounds light enough for dark text or verify text stays legible — the field usually only controls background, not foreground.
  • Name collisions. If your make() argument matches a real column, Nova may treat it as an actual attribute in search/sort contexts. Use a presentation-only name (row_background) or omit sorting; a display field shouldn't be sortable.
  • Unsupported/abandoned risk. 0 stars, 0 dependents, no visible maintenance signal: treat the dependency as a liability. The field is a few lines of CSS/meta under the hood — if it breaks after a Nova upgrade, forking or inlining the behavior is a realistic fallback. Consider whether Nova's own row/badge styling can approximate it first.
  • Debugging: if no color appears, verify (a) the field is in fields(), not just indexFields(), (b) the callback returns a non-null string for at least some rows, (c) the value isn't being overridden by a later field or resource-level styling, and (d) the emitted meta reaches the frontend — php artisan nova:check / browser console on the index route.
  • Extension point: because colors are computed at runtime, you can repurpose the field for computed visual states (e.g. "row dimmed when archived") without touching the database. Wrap the logic in a policy-aware callback if visibility depends on the current user's permissions — but check the row's data is already loaded, or you'll pay for it on every render.
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.
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle