Home > Mobile >  How to link css file to blade.php laravel file
How to link css file to blade.php laravel file

Time:11-18

Hey i'm using laravel 9 here and im using the SB ADMIN template from bootstrap , i'm making the template as a component <x-dashboard >...</x-dashboard> and i'm passing children inside it ! but i want the children to have it's own css ( not the bootstrap one ) which is in my app.css file i added the head just so i can link the css file to the blade file but still doesn't work any solutions ?

seeProscpect.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
  <link rel="stylesheet" href="{{ asset('../css/app.css') }}">
</head>
<body>
<x-dashboard >
    <h3 >TRYING CSS</h3>
</x-dashboard>
</body>
</html>

app.css


.changeColor {
   color: green;
}

CodePudding user response:

You have to use @pushonce for this purpose.

@pushonce('styles')
  <link href="{{ mix('css/tile.css') }}" rel="stylesheet">
@endpush

CodePudding user response:

Inside your <head> after all other CSS script put @stack('css')

Ex:

<head>
  <link rel="stylesheet" href="{{asset('../css/app.css')}}">
  @stack('css')
</head>

Then from your children blade, add @push or @pushonce Ex:

@push('css')
<link rel="stylesheet" href="{{asset('assets/css/blade_style.css')}}" />
<style>
  .body {
     background: #000 !important;
  }
</style>
@endpush

@section
<h1>Children Blade Content</h1>
@endsection
  • Related