This package contains a set of useful Bootstrap Laravel Blade components. It promotes DRY principles and allows you to keep your HTML nice and clean. Components include alerts, badges, buttons, form inputs (with automatic error feedback), dropdowns, navs, pagination (responsive), and more. The components come with Laravel Livewire integration built in, so you can use them with or without Livewire.
- Bootstrap 5 must be installed via webpack first
- A font icon library (like Font Awesome) must be installed to use icons
Require the package via composer:
composer require bastinald/laravel-bootstrap-componentsA Bootstrap alert:
<x-bs::alert
:label="__('It was successful!')"
color="info"
dismissible
/>icon: icon to show before label e.g.cog,envelopelabel: label to display, can also be placed in theslotcolor: Bootstrap color e.g.primary,danger,successdismissible: set the alert to be dismissible
A Bootstrap badge:
<x-bs::badge
:label="__('Pending')"
color="warning"
/>icon: icon to show before label e.g.cog,envelopelabel: label to display, can also be placed in theslotcolor: Bootstrap color e.g.primary,danger,success
A Bootstrap button:
<x-bs::button
:label="__('Login')"
color="primary"
size="lg"
route="login"
/>icon: icon to show before label e.g.cog,envelopelabel: label to display, can also be placed in theslotcolor: Bootstrap color e.g.primary,danger,successsize: Bootstrap button size e.g.sm,lgtype: button type e.g.button,submitroute: sets thehrefto a routeurl: sets thehrefto a urlhref: sets thehrefdismiss: adata-bs-dismissvalue e.g.alert,modaltoggle: adata-bs-togglevalue e.g.collapse,dropdownconfirm: prompts the user for confirmation on click
A Bootstrap checkbox input:
<x-bs::check
:label="__('Agree')"
:checkLabel="__('I agree to the TOS')"
:help="__('Please accept the TOS.')"
switch
wire:model.defer="agree"
/>label: label to display above the inputcheckLabel: label to display beside the inputhelp: helper label to display under the inputswitch: style the input as a switch
A Bootstrap close button:
<x-bs::close
dismiss="modal"
/>dismiss: adata-bs-dismissvalue e.g.alert,modal
A Bootstrap color picker input:
<x-bs::color
:label="__('Favorite Color')"
:prepend="__('I like')"
:append="_('the most.')"
:help="__('Please pick a color.')"
wire:model.defer="favorite_color"
/>label: label to display above the inputicon: icon to show before input e.g.cog,envelopeprepend: addon to display before input, can be used via named slotappend: addon to display after input, can be used via named slotsize: Bootstrap input size e.g.sm,lghelp: helper label to display under the input
A Bootstrap datalist input:
<x-bs::datalist
:label="__('City Name')"
:options="['Toronto', 'Montreal', 'Las Vegas']"
:prepend="__('I live in')"
:append="_('right now.')"
:help="__('Please enter your city.')"
wire:model.defer="city_name"
/>label: label to display above the inputoptions: array of input options e.g.['Red', 'Blue']icon: icon to show before input e.g.cog,envelopeprepend: addon to display before input, can be used via named slotappend: addon to display after input, can be used via named slotsize: Bootstrap input size e.g.sm,lghelp: helper label to display under the input
A Bootstrap dropdown:
<x-bs::dropdown
:label="__('Filter')"
color="danger"
>
<x-bs::dropdown-item
:label="__('By Name')"
wire:click="$set('filter', 'name')"
/>
<x-bs::dropdown-item
:label="__('By Age')"
wire:click="$set('filter', 'age')"
/>
</x-bs::dropdown>icon: icon to show before label e.g.cog,envelopelabel: dropdown label to display, can be used via named slotitems: dropdown items, can also be placed in theslotcolor: Bootstrap color e.g.primary,danger,successsize: Bootstrap button size e.g.sm,lg
A Bootstrap dropdown menu item:
<x-bs::dropdown-item
:label="__('Login')"
route="login"
/>icon: icon to show before label e.g.cog,envelopelabel: label to display, can also be placed in theslotroute: sets thehrefto a routeurl: sets thehrefto a urlhref: sets thehref
A font icon via your installed library:
<x-bs::icon
name="cog"
/>name: icon name from the librarycolor: Bootstrap color e.g.primary,danger,success
An image:
<x-bs::image
asset="images/logo.png"
height="24"
rounded
/>asset: sets thesrcto an assetsrc: sets thesrcfluid: sets the image to be fluid widththumbnail: sets the image to use thumbnail stylingrounded: sets the image to have rounded corners
A Bootstrap text input:
<x-bs::input
:label="__('Email Address')"
type="email"
:help="__('Please enter your email.')"
wire:model.defer="email_address"
>
<x-slot name="prepend">
<i class="fa fa-envelope"></i>
</x-slot>
</x-bs::input>label: label to display above the inputtype: input type e.g.text,emailicon: icon to show before input e.g.cog,envelopeprepend: addon to display before input, can be used via named slotappend: addon to display after input, can be used via named slotsize: Bootstrap input size e.g.sm,lghelp: helper label to display under the input
A hyperlink:
<x-bs::link
:label="__('Users')"
route="users"
/>icon: icon to show before label e.g.cog,envelopelabel: label to display, can also be placed in theslotroute: sets thehrefto a routeurl: sets thehrefto a urlhref: sets thehref
A Bootstrap nav dropdown:
<x-bs::nav-dropdown
:label="Auth::user()->name"
>
<x-bs::dropdown-item
:label="__('Update Profile')"
wire:click="$emit('showModal', 'profile.update')"
/>
<x-bs::dropdown-item
:label="__('Logout')"
wire:click="logout"
/>
</x-bs::nav-dropdown>icon: icon to show before label e.g.cog,envelopelabel: dropdown label to display, can be used via named slotitems: dropdown items, can also be placed in theslot
A Bootstrap nav link:
<x-bs::nav-link
:label="__('Users')"
route="users"
/>icon: icon to show before label e.g.cog,envelopelabel: label to display, can also be placed in theslotroute: sets thehrefto a routeurl: sets thehrefto a urlhref: sets thehref
Responsive Bootstrap pagination links:
<x-bs::pagination
:links="App\Models\User::paginate()"
justify="center"
/>links: paginated Laravel modelsjustify: Bootstrap justification e.g.start,end
A Bootstrap progress bar:
<x-bs::progress
:label="__('25% Complete')"
percent="25"
color="success"
height="10"
animated
striped
/>label: label to display inside the progress barpercent: percentage of the progress barcolor: Bootstrap color e.g.primary,danger,successheight: height of the progress bar in pixelsanimated: animate the progress barstriped: use striped styling for the progress bar
A Bootstrap radio input:
<x-bs::radio
:label="__('Gender')"
:options="['Male', 'Female']"
:help="__('Please select your gender.')"
switch
wire:model.defer="gender"
/>label: label to display above the inputoptions: array of input options e.g.['Red', 'Blue']help: helper label to display under the inputswitch: sets the input to use a switch style
A Bootstrap select input:
<x-bs::select
:label="__('Your Country')"
:placeholder="__('Select Country')"
:options="['Australia', 'Canada', 'USA']"
:prepend="__('I live in')"
:append="_('right now.')"
:help="__('Please select your country.')"
wire:model.defer="your_country"
/>label: label to display above the inputplaceholder: placeholder to use for the empty first optionoptions: array of input options e.g.['Red', 'Blue']icon: icon to show before input e.g.cog,envelopeprepend: addon to display before input, can be used via named slotappend: addon to display after input, can be used via named slotsize: Bootstrap input size e.g.sm,lghelp: helper label to display under the input
A Bootstrap textarea input:
<x-bs::textarea
:label="__('Biography')"
rows="5"
:help="__('Please tell us about yourself.')"
wire:model.defer="biography"
/>label: label to display above the inputicon: icon to show before input e.g.cog,envelopeprepend: addon to display before input, can be used via named slotappend: addon to display after input, can be used via named slotsize: Bootstrap input size e.g.sm,lghelp: helper label to display under the input
Use your own component views by publishing the package views:
php artisan vendor:publish --tag=laravel-bootstrap-components:viewsNow edit the files inside resources/views/vendor/bs. The package will use these files to render the components.
Use your own font icons by publishing the package config:
php artisan vendor:publish --tag=laravel-bootstrap-components:configNow edit the icon_class_prefix value inside config/laravel-bootstrap-components.php. The package will use this class to render the icons.