Laravel doesn’t have color picker field as a default option, but we can build one easily, please follow this tutorial.

Let’s create a CRUD for Tags like Github issues labels, where you can add a Label and choose a color for it:

We will generate our form with QuickAdminPanel, but it’s not necessary – it’s a simple CRUD.

Now, let’s turn a “color” field from simple text, to color picker.

Step 1. Preparation – CRUD code

Database migration:

Schema::create('tags', function (Blueprint $table) {

Model app/Tag.php:

class Tag extends Model
    protected $fillable = ['name', 'color'];

Controller app/Http/Controllers/Admin/TagsController.php:

namespace App\Http\Controllers\Admin;

use App\Tag;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\StoreTagsRequest;

class TagsController extends Controller
    public function index()
        $tags = Tag::all();
        return view('admin.tags.index', compact('tags'));

    public function create()
        return view('admin.tags.create');

    public function store(StoreTagsRequest $request)
        $tag = Tag::create($request->all());
        return redirect()->route('admin.tags.index');

    // ... other CRUD methods


In routes/web.php, there’s one line for resourceful Controller:

Route::resource('tags', 'Admin\TagsController');

To view it all, we need two blade files.
Notice 1: to simplify tutorial, I won’t get deeper into overall layout structure, only the form and table, which are relevant for this article.
Notice 2: for the forms we use Laravelcollective/html package which is part of our QuickAdminPanel.


<table class="table table-bordered table-striped datatable">
            <th> </th>
        @if (count($tags) > 0)
            @foreach ($tags as $tag)
                <tr data-entry-id="{{ $tag->id }}">
                    <td field-key='name'>{{ $tag->name }}</td>
                    <td field-key='color'>{{ $tag->color }}</td>
                        <a href="{{ route('admin.tags.edit',[$tag->id]) }}" class="btn btn-xs btn-info">Edit</a>
                        {!! Form::open(array(
                            'style' => 'display: inline-block;',
                            'method' => 'DELETE',
                            'onsubmit' => "return confirm('Are you sure?');",
                            'route' => ['admin.tags.destroy', $tag->id])) !!}
                        {!! Form::submit('Delete', array('class' => 'btn btn-xs btn-danger')) !!}
                        {!! Form::close() !!}
                <td colspan="3">No entries in table</td>

And resources/views/admin/tags/create.blade.php:

<h3 class="page-title">Tags</h3>
{!! Form::open(['method' => 'POST', 'route' => ['']]) !!}

<div class="panel panel-default">
    <div class="panel-heading">
    <div class="panel-body">
        <div class="row">
            <div class="col-xs-12 form-group">
                {!! Form::label('name', 'Name', ['class' => 'control-label']) !!}
                {!! Form::text('name', old('name'), ['class' => 'form-control', 'placeholder' => '', 'required' => '']) !!}
                <p class="help-block"></p>
                    <p class="help-block">
                        {{ $errors->first('name') }}
        <div class="row">
            <div class="col-xs-12 form-group">
                {!! Form::label('color', 'Color', ['class' => 'control-label']) !!}
                {!! Form::text('color', old('color'), ['class' => 'form-control', 'placeholder' => '']) !!}
                <p class="help-block"></p>
                    <p class="help-block">
                        {{ $errors->first('color') }}

{!! Form::submit('Save', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}

Pretty simple, right?
So, what we need to do here to adapt colorpicker:

  1. Adapt jQuery Colorpicker library for picking color
  2. Save result as #XXXXXX into the database
  3. In the table list view the color block instead of #XXXXXX value

Step 2. jQuery ColorPicker

For JavaScript part of actually picking the color, we will choose one of the most popular library called Bootstrap Colorpicker and will load it from Cloudflare CDN.

In our <head> section of HTML, we need to add this:

<link href="" rel="stylesheet">

Where to put it – depends on the structure of your layout, for me it’s resources/views/layouts/app.blade.php.

Now, in the same app.blade.php at the bottom we need to load jQuery and then add a section for javascript code:

<script src="//"></script>


Finally, in the resources/views/admin/tags/create.blade.php file, in the form, we add this at the bottom:

    <script src=""></script>

That’s it, we have the result:

Step 3. Viewing color in the list

This is how our list currently looks like:

Let’s change those #421c1c values into actual colors, we need to change the internals of that td cell. To simplify, we just make additional td with the background color:

<td style="background-color:{{ $tag->color }}"> </td>

Here’s the result:

That’s it, thanks for following the tutorial.
Meanwhile, if you want to create such CRUD forms quicker, try our QuickAdminPanel!