Skip to content

#[Ghost] attribute

Apply to a component class — no view changes required:

use Ghostwire\Attributes\Ghost;
#[Ghost(mode: 'synthesize', delay: 200, hold: 400)]
class ProductTable extends Component
{
// ...
}

| Parameter | Type | Default | Meaning | |---|---|---|---| | mode | 'synthesize'|'freeze'|'off' | 'synthesize' | Loading strategy for this component | | only | array<string>|null | null | Actions that activate the ghost | | except | array<string>|null | null | Actions that never activate it | | delay | int|null | null (package default: 120ms) | Delay before the ghost appears | | hold | int|null | null (package default: 300ms) | Minimum visible duration | | rows | int|null | null | Repeat-row hint for an empty host | | poll | bool | false | Allow polled messages to activate the ghost | | sync | bool | false | Allow property-only (sync) messages to activate it | | lazy | bool | false | Reuse the learned tree as the lazy placeholder |

Seven levels, most to least specific:

  1. Directive modifier on the element — e.g. wire:ghost.freeze
  2. Directive expression / action targeting — e.g. wire:ghost="applyFilters"
  3. #[Ghost] on the executing action’s method
  4. #[Ghost] on the component class
  5. #[Ghost] inherited from a base class or trait
  6. config/ghostwire.php
  7. Package defaults

The wire:ghost directive on the element outranks the #[Ghost] attribute: a directive-level setting overrides whatever the attribute levels declare, field by field. Any field a given level doesn’t declare falls through to the next. Inspect exactly which level decided a component’s live configuration with:

Terminal window
php artisan ghost:inspect
#[Ghost(mode: 'freeze')]
class ReportTable extends Component
{
#[Ghost(mode: 'synthesize', delay: 50)]
public function refresh() { /* ... */ }
}

refresh()’s own attribute overrides the class-level default for that action only.