Cagilo: Blade Components for Laravel

Packages

September 14th, 2021

cagilo-featured.png

Cagilo is a set of open-source Blade components for the Laravel framework. This package doesn't require a CSS framework or JS resources to function and provides the following components:

  • Alerts component for working with Laravel session flashing
  • Device component - ability to hide or show depending on the user's device (user-agent)
  • Error component - easy way to work with Laravel's error message bag
  • Icon component - insert inline SVG files
  • Logout component - component log out users via a POST request
  • Meta component - set several OG and meta elements used by social media to provide previews of your content

The <x-meta> component seems powerful, with just a few lines, you can generate the following:

1<x-meta
2 title="Hello World"
3 description="Blade components are awesome!"
4 image="http://example.com/social.jpg"
5/>
6 
7<!--
8Outputs the following:
9-->
10<title>Hello World</title>
11 
12<!-- Primary Meta Tags -->
13<meta name="title" content="Hello World">
14<meta name="description" content="Blade components are awesome!">
15 
16 
17<!-- Open Graph / Facebook -->
18<meta property="og:type" content="website">
19<meta property="og:url" content="http://localhost"/>
20<meta property="og:locale" content="en"/>
21<meta property="og:title" content="Hello World"/>
22<meta property="og:description" content="Blade components are awesome!">
23<meta property="og:image" content="http://example.com/social.jpg">
24 
25<!-- Twitter -->
26<meta name="twitter:card" content="summary_large_image"/>
27<meta name="twitter:url" content="http://localhost">
28<meta name="twitter:title" content="Hello World">
29<meta name="twitter:description" content="Blade components are awesome!">
30<meta name="twitter:image" content="http://example.com/social.jpg">

While creating a logout button is straightforward, this package has a convenient component for doing this:

1<x-logout/>
2 
3<!--
4Outputs the following:
5-->
6<form method="POST" action="http://localhost/logout" id="logout">
7 <input type="hidden" name="_token" value="...">
8</form>
9 
10<button form="logout" type="submit">
11 Log out
12</button>

Lastly, the <x-device> component is helpful if you want to conditionally render your template based on a user's user-agent:

1<x-device desktop="true">
2 <h1>Hello Word</h1>
3</x-device>
4 
5<!-- or multiple devices -->
6<x-device phone="true" tablet="true">
7 <h1>Hello Word</h1>
8</x-device>

The documentation can help you get started and has examples for each blade component. You can learn more about this package, get full installation instructions, and view the source code on GitHub.


This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.