0

In a Laravel component, you can specify default classes and merge them with extra classes that get passed in, something like this:

<a {{ $attributes->merge(['class' => 'text-white']) }}>{{ $slot }}</a>

But what if I want to remove that "text-white" class? How can I pass in a list of classes to exclude from the component?

Magmatic
  • 1,754
  • 3
  • 19
  • 34

1 Answers1

0

You need to use conditionally merge classes. You can accomplish this via the class method, which accepts an array of classes where the array key contains the class or classes you wish to add, while the value is a boolean expression.

<a {{ $attributes->class(['text-white' => $isTextWhite]) }}>{{ $slot }}</a>
Wahyu Kristianto
  • 8,719
  • 6
  • 43
  • 68