diff --git a/blade.md b/blade.md index 07ef8ef19a..46ae633b50 100644 --- a/blade.md +++ b/blade.md @@ -906,6 +906,33 @@ The final, rendered HTML of the component will appear like the following: ``` + +#### Conditionally Merge Classes + +You may conditionally merge a set of classes with the `class` method by passing an array of classes. + +
class(['p-4', 'mb-4']) }}> + {{ $message }} +
+ +Sometimes you may wish to merge classes by specifying conditions. You can accomplish this by passing an array of classes where the array value evaluates to `true`. + +
class(['p-4', 'bg-red' => $hasError]) }}> + {{ $message }} +
+ +If you need to pass other attributes, you can chain the `merge` method. + + + +For convenience, the `class` method accepts a string as well. + +
class('p-4') }}> + {{ $message }} +
+ #### Non-Class Attribute Merging