├── .gitignore ├── LICENSE.md ├── README.md ├── composer.json ├── screenshots ├── dashboard.png ├── login.png ├── pagination-simple.png ├── pagination.png ├── register.png ├── reset-password-email.png ├── reset-password.png └── verify.png ├── src ├── LaravelPresetServiceProvider.php └── Preset.php └── stubs ├── controllers └── HomeController.stub ├── resources ├── css │ └── app.css └── views │ ├── auth │ ├── login.blade.php │ ├── passwords │ │ ├── confirm.blade.php │ │ ├── email.blade.php │ │ └── reset.blade.php │ ├── register.blade.php │ └── verify.blade.php │ ├── home.blade.php │ ├── layouts │ └── app.blade.php │ └── vendor │ └── pagination │ ├── default.blade.php │ └── simple-default.blade.php ├── tailwind.config.js └── webpack.mix.js /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /vendor 3 | composer.lock 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Tailwindcomponents 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel preset for TailwindCSS 2 | 3 | [![License](https://poser.pugx.org/tailwindcomponents/laravel-preset/license)](//packagist.org/packages/tailwindcomponents/laravel-preset) 4 | [![Latest Stable Version](https://poser.pugx.org/tailwindcomponents/laravel-preset/v)](//packagist.org/packages/tailwindcomponents/laravel-preset) 5 | [![Total Downloads](https://poser.pugx.org/tailwindcomponents/laravel-preset/downloads)](//packagist.org/packages/tailwindcomponents/laravel-preset) 6 | [![Monthly Downloads](https://poser.pugx.org/tailwindcomponents/laravel-preset/d/monthly)](//packagist.org/packages/tailwindcomponents/laravel-preset) 7 | 8 | 9 | 10 | 11 | 🛹 A Laravel front-end scaffolding preset for [Tailwind CSS](https://tailwindcss.com) - a Utility-First CSS Framework for Rapid UI Development. 12 | 13 | ## Installation and usage 14 | This package requires Laravel 7.0 or higher. 15 | 16 | 1. Fresh install Laravel and `cd` to your app. 17 | 2. Install `composer require tailwindcomponents/laravel-preset --dev`. 18 | 19 | ### a. Preset WITHOUT Authentication 20 | 21 | 1. Use `php artisan ui tailwindcss` for the basic Tailwind CSS preset. 22 | 2. `npm install && npm run dev` 23 | 3. `php artisan serve` (or equivalent) to run server and test preset. 24 | 25 | ### b. Preset WITH Authentication 26 | 27 | 1. Use `php artisan ui tailwindcss --auth` for the basic preset, auth route entry, and Tailwind CSS auth views in one go. (NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`) 28 | 4. `npm install && npm run dev` 29 | 5. Configure your favorite database (mysql, sqlite etc.) 30 | 6. `php artisan migrate` to create basic user tables. 31 | 7. `php artisan serve` (or equivalent) to run server and test preset. 32 | 33 | ### Config 34 | 35 | The default `tailwind.config.js` configuration file included by this package simply uses the config from the Tailwind vendor files. Should you wish to make changes, you should remove the file and run `node_modules/.bin/tailwind init`, which will generate a fresh configuration file for you, which you are free to change to suit your needs. 36 | 37 | ## Screenshots 38 | 39 | ![Dashboard](/screenshots/dashboard.png) 40 | 41 | ![Login](/screenshots/login.png) 42 | 43 | ![Register](/screenshots/register.png) 44 | 45 | ![Reset Password](/screenshots/reset-password-email.png) 46 | 47 | ![Reset Password](/screenshots/reset-password.png) 48 | 49 | ![Verify](/screenshots/verify.png) 50 | 51 | ![Pagination](/screenshots/pagination.png) 52 | 53 | ![Pagination](/screenshots/pagination-simple.png) 54 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tailwindcomponents/laravel-preset", 3 | "description": "Laravel frontend preset for Tailwind CSS", 4 | "keywords": ["laravel", "preset", "tailwindcss"], 5 | "license": "MIT", 6 | "require": { 7 | "laravel/framework": "^7.0|^8.0", 8 | "laravel/ui": "^2.0|^3.0" 9 | }, 10 | "autoload": { 11 | "psr-4": { 12 | "TailwindComponents\\LaravelPreset\\": "src/" 13 | } 14 | }, 15 | "extra": { 16 | "laravel": { 17 | "providers": [ 18 | "TailwindComponents\\LaravelPreset\\LaravelPresetServiceProvider" 19 | ] 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /screenshots/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tailwindcomponents/laravel-preset/4e2aa8719e4f22e8a867cce046b924928fbbc830/screenshots/dashboard.png -------------------------------------------------------------------------------- /screenshots/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tailwindcomponents/laravel-preset/4e2aa8719e4f22e8a867cce046b924928fbbc830/screenshots/login.png -------------------------------------------------------------------------------- /screenshots/pagination-simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tailwindcomponents/laravel-preset/4e2aa8719e4f22e8a867cce046b924928fbbc830/screenshots/pagination-simple.png -------------------------------------------------------------------------------- /screenshots/pagination.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tailwindcomponents/laravel-preset/4e2aa8719e4f22e8a867cce046b924928fbbc830/screenshots/pagination.png -------------------------------------------------------------------------------- /screenshots/register.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tailwindcomponents/laravel-preset/4e2aa8719e4f22e8a867cce046b924928fbbc830/screenshots/register.png -------------------------------------------------------------------------------- /screenshots/reset-password-email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tailwindcomponents/laravel-preset/4e2aa8719e4f22e8a867cce046b924928fbbc830/screenshots/reset-password-email.png -------------------------------------------------------------------------------- /screenshots/reset-password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tailwindcomponents/laravel-preset/4e2aa8719e4f22e8a867cce046b924928fbbc830/screenshots/reset-password.png -------------------------------------------------------------------------------- /screenshots/verify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tailwindcomponents/laravel-preset/4e2aa8719e4f22e8a867cce046b924928fbbc830/screenshots/verify.png -------------------------------------------------------------------------------- /src/LaravelPresetServiceProvider.php: -------------------------------------------------------------------------------- 1 | info('Tailwind CSS scaffolding installed successfully.'); 18 | 19 | if ($command->option('auth')) { 20 | Preset::installAuth(); 21 | 22 | $command->info('Tailwind CSS auth scaffolding installed successfully.'); 23 | } 24 | 25 | $command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); 26 | }); 27 | 28 | Paginator::defaultView('pagination::default'); 29 | Paginator::defaultView('pagination::simple-default'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Preset.php: -------------------------------------------------------------------------------- 1 | '^0.2.1', 15 | 'tailwindcss' => '^2.0.2', 16 | 'autoprefixer' => '^10.2.1', 17 | 'vue' => '^2.6.11', 18 | 'vue-template-compiler' => '^2.6.11', 19 | 'vue-loader'=> '^15.9.5', 20 | ]; 21 | 22 | public static function install() 23 | { 24 | static::updatePackages(); 25 | static::updateStyles(); 26 | static::updateBootstrapping(); 27 | static::removeNodeModules(); 28 | static::updatePagination(); 29 | } 30 | 31 | public static function installAuth() 32 | { 33 | static::scaffoldController(); 34 | static::scaffoldMigrations(); 35 | static::scaffoldAuth(); 36 | static::scaffoldAuthViews(); 37 | } 38 | 39 | protected static function updatePackageArray($packages) 40 | { 41 | return array_merge( 42 | static::NPM_PACKAGES_TO_ADD, 43 | $packages 44 | ); 45 | } 46 | 47 | protected static function updateStyles() 48 | { 49 | tap(new Filesystem, function ($filesystem) { 50 | $filesystem->delete(public_path('css/app.css')); 51 | 52 | if (! $filesystem->isDirectory($directory = resource_path('css'))) { 53 | $filesystem->makeDirectory($directory, 0755, true); 54 | } 55 | }); 56 | 57 | copy(__DIR__.'/../stubs/resources/css/app.css', resource_path('css/app.css')); 58 | } 59 | 60 | protected static function updateBootstrapping() 61 | { 62 | copy(__DIR__.'/../stubs/tailwind.config.js', base_path('tailwind.config.js')); 63 | 64 | copy(__DIR__.'/../stubs/webpack.mix.js', base_path('webpack.mix.js')); 65 | } 66 | 67 | 68 | protected static function scaffoldController() 69 | { 70 | if (! is_dir($directory = app_path('Http/Controllers/Auth'))) { 71 | mkdir($directory, 0755, true); 72 | } 73 | 74 | $filesystem = new Filesystem; 75 | 76 | collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/Auth'))) 77 | ->each(function (SplFileInfo $file) use ($filesystem) { 78 | $filesystem->copy( 79 | $file->getPathname(), 80 | app_path('Http/Controllers/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename())) 81 | ); 82 | }); 83 | } 84 | 85 | protected static function scaffoldMigrations() 86 | { 87 | $filesystem = new Filesystem; 88 | 89 | collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/migrations'))) 90 | ->each(function (SplFileInfo $file) use ($filesystem) { 91 | $filesystem->copy( 92 | $file->getPathname(), 93 | database_path('migrations/'.$file->getFilename()) 94 | ); 95 | }); 96 | } 97 | 98 | protected static function scaffoldAuth() 99 | { 100 | file_put_contents(app_path('Http/Controllers/HomeController.php'), static::compileControllerStub()); 101 | 102 | file_put_contents( 103 | base_path('routes/web.php'), 104 | "\n\nAuth::routes();\n\nRoute::get('/home', [\App\Http\Controllers\HomeController::class, 'index'])->name('home');\n\n", 105 | FILE_APPEND 106 | ); 107 | } 108 | 109 | protected static function compileControllerStub() 110 | { 111 | return str_replace( 112 | '{{namespace}}', 113 | Container::getInstance()->getNamespace(), 114 | file_get_contents(__DIR__.'/../stubs/controllers/HomeController.stub') 115 | ); 116 | } 117 | 118 | protected static function updatePagination() 119 | { 120 | (new Filesystem)->delete(resource_path('views/vendor/paginate')); 121 | 122 | (new Filesystem)->copyDirectory(__DIR__.'/../stubs/resources/views/vendor/pagination', resource_path('views/vendor/pagination')); 123 | } 124 | 125 | protected static function scaffoldAuthViews() 126 | { 127 | (new Filesystem)->copyDirectory(__DIR__.'/../stubs/resources/views', resource_path('views')); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /stubs/controllers/HomeController.stub: -------------------------------------------------------------------------------- 1 | middleware('auth'); 17 | } 18 | 19 | /** 20 | * Show the application dashboard. 21 | * 22 | * @return \Illuminate\Contracts\Support\Renderable 23 | */ 24 | public function index() 25 | { 26 | return view('home'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /stubs/resources/css/app.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss/base"; 2 | /* @import "./custom-base-styles.css"; */ 3 | 4 | @import "tailwindcss/components"; 5 | /* @import "./custom-components.css"; */ 6 | 7 | @import "tailwindcss/utilities"; 8 | /* @import "./custom-utilities.css"; */ -------------------------------------------------------------------------------- /stubs/resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |

{{ __('Login') }}

7 | 8 |
9 | @csrf 10 | 11 | 21 | 22 | 32 | 33 |
34 |
35 | 39 |
40 | 41 |
42 | @if (Route::has('password.request')) 43 | 44 | {{ __('Forgot Your Password?') }} 45 | 46 | @endif 47 |
48 |
49 | 50 |
51 | 54 |
55 |
56 |
57 |
58 | @endsection 59 | -------------------------------------------------------------------------------- /stubs/resources/views/auth/passwords/confirm.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |

{{ __('Confirm Password') }}

7 | 8 |

{{ __('Please confirm your password before continuing.') }}

9 | 10 |
11 | @csrf 12 | 13 | 23 | 24 |
25 | 28 |
29 |
30 |
31 |
32 | @endsection 33 | -------------------------------------------------------------------------------- /stubs/resources/views/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |

{{ __('Reset Password') }}

7 | 8 | @if (session('status')) 9 | 20 | @endif 21 | 22 |
23 | @csrf 24 | 25 | 29 | 30 |
31 | 34 |
35 |
36 |
37 |
38 | @endsection 39 | -------------------------------------------------------------------------------- /stubs/resources/views/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |

{{ __('Reset Password') }}

7 | 8 |
9 | @csrf 10 | 11 | 12 | 13 | 23 | 24 | 34 | 35 | 39 | 40 |
41 | 44 |
45 |
46 |
47 |
48 | @endsection 49 | -------------------------------------------------------------------------------- /stubs/resources/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |

{{ __('Register') }}

7 | 8 |
9 | @csrf 10 | 11 | 21 | 22 | 32 | 33 | 43 | 44 | 48 | 49 |
50 | 53 |
54 |
55 |
56 |
57 | @endsection 58 | -------------------------------------------------------------------------------- /stubs/resources/views/auth/verify.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |

{{ __('Verify Your Email Address') }}

7 | 8 | @if (session('resent')) 9 | 20 | @endif 21 | 22 |

{{ __('Before proceeding, please check your email for a verification link.') }} {{ __('If you did not receive the email') }},

23 | 24 |
25 | @csrf 26 | 27 |
28 |
29 |
30 | @endsection 31 | -------------------------------------------------------------------------------- /stubs/resources/views/home.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |

{{ __('Dashboard') }}

7 | 8 | 9 | @if (session('status')) 10 |
11 |
12 |
13 | 14 | 15 | 16 | 17 |

{{ session('status') }}

18 |
19 |
20 |
21 | @endif 22 | 23 |

{{ __('You are logged in!') }}

24 |
25 |
26 | @endsection 27 | -------------------------------------------------------------------------------- /stubs/resources/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{ config('app.name', 'Laravel') }} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 56 | 57 |
58 | @yield('content') 59 |
60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /stubs/resources/views/vendor/pagination/default.blade.php: -------------------------------------------------------------------------------- 1 | @if ($paginator->hasPages()) 2 | 46 | @endif 47 | -------------------------------------------------------------------------------- /stubs/resources/views/vendor/pagination/simple-default.blade.php: -------------------------------------------------------------------------------- 1 | @if ($paginator->hasPages()) 2 | 27 | @endif 28 | -------------------------------------------------------------------------------- /stubs/tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | purge: [ 3 | "app/**/*.php", 4 | "resources/**/*.html", 5 | "resources/**/*.js", 6 | "resources/**/*.jsx", 7 | "resources/**/*.ts", 8 | "resources/**/*.tsx", 9 | "resources/**/*.php", 10 | "resources/**/*.vue", 11 | "resources/**/*.twig" 12 | ], 13 | darkMode: false, // or 'media' or 'class' 14 | theme: { 15 | extend: { 16 | fontFamily: { 17 | "roboto": ["Roboto"], 18 | }, 19 | } 20 | }, 21 | variants: { 22 | extend: {}, 23 | }, 24 | plugins: [ 25 | require("@tailwindcss/forms") 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /stubs/webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js'); 15 | 16 | mix.postCss('resources/css/app.css', 'public/css', [ 17 | require('tailwindcss'), 18 | ]).version(); 19 | 20 | --------------------------------------------------------------------------------