Laravel 10 - How to Use New @style Attribute

Laravel 10 - How to Use New @style Attribute

 Laravel 10 - How to Use New @style Attribute

I'll show you how to use @style in our Laravel app. Using this directive we can easily add any style to that tag. So, let's see how we can use this @style attribute.


Note: Tested on Laravel 10.0 

Table of Contents

  1. Example 1
  2. Example 2

Example 1

If we back to the previous moments, where if we need any change in style, we need to use so called @if @endif directiveLike below


@php
    $isActive = false;
@endphp

@if($isActive)
    <span style="background-color: red; color: white;">When $isActive is true</span>
@else
    <span style="background-color: red;color: green">When $isActive is false</span>
@endif

<span style="background-color: red; font-weight: bold;">hello</span>

Thank you for being so supportive!

Souy Soeng

Souy Soeng

Our website teaches and reads PHP, Framework Laravel, and how to download Admin template sample source code free. Thank you for being so supportive!

Github

Post a Comment

CAN FEEDBACK
close