Skip to content

Instantly share code, notes, and snippets.

@sagalbot
Last active October 16, 2020 14:45
Show Gist options
  • Save sagalbot/e40bad7e7454418889885ff233bb24fb to your computer and use it in GitHub Desktop.
Save sagalbot/e40bad7e7454418889885ff233bb24fb to your computer and use it in GitHub Desktop.
<button {{ $attributes->merge(['class' => App\View\Components\Button::$class ]) }}>
{{ $slot }}
</button>
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class Button extends Component
{
public static $class = "py-1 px-2 font-bold uppercase rounded";
public function render()
{
return view('components.button');
}
}
// now we find ourselves in a situation where we need to implement what
// looks like a button, but we need to use `a` instead of `button`.
<a href="/some-other-page" class="{{ App\View\Components\Button::$class }}">
My Great Link, That Looks Like a Button!
</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment