PHPackages                             souravmsh/laravel-widget - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. souravmsh/laravel-widget

ActiveLibrary[Templating &amp; Views](/categories/templating)

souravmsh/laravel-widget
========================

A Laravel package for building and bundling reusable UI widgets as Blade components.

v1.0.0(1y ago)12MITPHPPHP ^8.0

Since May 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/souravmsh/laravel-widget)[ Packagist](https://packagist.org/packages/souravmsh/laravel-widget)[ Docs](https://github.com/souravmsh/laravel-widget)[ RSS](/packages/souravmsh-laravel-widget/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Laravel Widget Package
======================

[](#laravel-widget-package)

A Laravel package for building and bundling reusable UI widgets as Blade components.

Overview
--------

[](#overview)

`laravel-widget` is a Laravel package designed to manage a collection of UI widgets that can be easily embedded into any Laravel Blade view. The package simplifies widget integration while maintaining a clean, modern interface.

The package currently includes two widgets:

- **Font Hunter**: A utility to download Google Fonts and their CSS files via a simple form.
- **Avatar Widget**: A component to display an avatar image or generate a fallback avatar based on text initials.

---

Features
--------

[](#features)

- **Widget Bundle Ready**: Designed to host multiple widgets under one package.
- **Reusable Blade Components**: Easily embed widgets using Blade components.
- **Customizable Configurations**: Control storage paths, file names, and other settings for Font Hunter, and avatar appearance for the Avatar Widget.

---

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Laravel 9.x or 10.x
- Writable storage directory (`storage/app/public`)
- GD PHP extension (for Avatar Widget image generation)

---

Installation
------------

[](#installation)

1. **Install via Composer**

    If published to a repository:

    ```
    composer require souravmsh/laravel-widget
    ```

    If developing locally:

    ```
    // Add to composer.json
    "repositories": [
        {
            "type": "path",
            "url": "packages/souravmsh/laravel-widget"
        }
    ]
    composer require souravmsh/laravel-widget:dev-main
    ```
2. **Publish Configuration &amp; Views**

    ```
    php artisan vendor:publish --tag=config
    php artisan vendor:publish --tag=views
    ```
3. **Set Storage Permissions**

    ```
    chmod -R 775 storage
    php artisan storage:link
    ```

---

Usage
-----

[](#usage)

### 1. Font Hunter Widget

[](#1-font-hunter-widget)

**Font Hunter Widget** is a Laravel package that provides a reusable, interactive Blade component for downloading Google Fonts and their associated CSS files. With a modern, Tailwind CSS-powered interface, users can input a Google Fonts CSS URL, fetch the font files, generate a custom CSS, and download everything as a convenient zip archive.

[![Font Hunter Widget Preview](docs/font-hunter-preview-1.png)](docs/font-hunter-preview-1.png)

**Usage**:

```

```

or

```

```

**Workflow**:

1. Enter a valid Google Fonts CSS URL (e.g., `https://fonts.googleapis.com/css?family=Lato:300,400,700`).
2. Click **Generate** to fetch the fonts and CSS.
3. A **Download** button appears to download a zip archive containing the fonts and a generated CSS file.

### 2. Avatar Widget

[](#2-avatar-widget)

**Avatar Widget** is a reusable Blade component that displays an avatar image from a provided URL or generates a fallback avatar using text initials. If the provided image URL is invalid or not provided, the widget generates an avatar with initials derived from the `alt` text or the `src` filename, displayed on a random background color with contrasting text.

**Usage**:

```

```

or

```

```

**Features**:

- Displays an image from the `src` URL if valid.
- Generates a fallback avatar with initials if `src` is invalid or missing:
    - Uses `alt` text for initials (e.g., "Font 2" → "F2").
    - If `alt` is missing, extracts initials from the `src` filename (e.g., "no.png" → "N").
    - If both are missing, uses default `alt` ("Avatar" → "A").
- Supports custom `width`, `height`, `class`, `id`, and additional HTML attributes via `attributes`.
- Percentage-based `height` (e.g., `height="48%"`) is applied as CSS `style`.
- Width and height are only applied if provided for valid images; fallback avatars use provided or default dimensions (48x48).

**Behavior**:

- If the `src` image loads successfully, it uses the provided `width`, `height`, and custom attributes, with natural image dimensions if `width` or `height` are not specified.
- If the `src` fails (e.g., 404), a JavaScript `onerror` handler swaps to a generated avatar with default or provided dimensions, preserving all custom attributes.

---

Configuration
-------------

[](#configuration)

Customize the package settings in `config/laravel-widget.php`:

```
return [
    'middleware' => ['web'], // Middleware for the route
    'url_prefix' => 'laravel-widget', // URL prefix for the route

    // Font Hunter
    'font_hunter' => [
        'dir'        => 'laravel-widget/font-hunter', // Base directory for storing files
        'fonts_dir'  => 'fonts', // Subdirectory for font files
        'css_dir'    => 'css', // Subdirectory for CSS files
        'file_name'  => 'fonts.css', // Name of the CSS file
    ],

    // Avatar Widget
    'avatar' => [
        'src'     => null,
        'alt'     => 'Avatar',
        'width'   => 48,
        'height'  => 48,
        'id'      => null,
        'classes' => null,
        'style'   => null,
        'attributes' => null,
    ]
];
```

You can adjust:

- **Font Hunter**: Base storage path, subdirectories for fonts and CSS, and default CSS filename.
- **Avatar Widget**: Default values for `src`, `alt`, `width`, `height`, `id`, `classes`, `style`, and `attributes`.

---

Customization
-------------

[](#customization)

- **Styling**:
    - For **Font Hunter**, edit `resources/views/vendor/laravel-widget/components/font-hunter.blade.php`.
    - For **Avatar Widget**, edit `resources/views/vendor/laravel-widget/avatar/index.blade.php`.
- **Form Handling**: Optionally convert the Font Hunter form to AJAX-based by adding custom JavaScript.
- **Additional Widgets**: Create new Blade components within the package to add more widgets.
- **Avatar Appearance**: Modify the `AvatarService` class to customize fallback avatar generation (e.g., colors, fonts).

---

Notes
-----

[](#notes)

- Files for Font Hunter are stored at `storage/app/public/laravel-widget/`. Ensure this directory is writable.
- The Font Hunter widget uses a minimal POST route `/laravel-widget/process` to handle form submissions.
- The Avatar Widget requires the GD PHP extension for generating fallback avatars.
- Fully compatible with Laravel 9.x and 10.x.

---

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

---

Support
-------

[](#support)

For issues or feature requests, open an issue on the [GitHub repository](https://github.com/souravmsh/laravel-widget).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance46

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

406d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12506579?v=4)[Shohrab Hossain](/maintainers/souravmsh)[@souravmsh](https://github.com/souravmsh)

---

Top Contributors

[![souravmsh](https://avatars.githubusercontent.com/u/12506579?v=4)](https://github.com/souravmsh "souravmsh (16 commits)")

---

Tags

laravelsouravmshlaravel-widget

### Embed Badge

![Health badge](/badges/souravmsh-laravel-widget/health.svg)

```
[![Health](https://phpackages.com/badges/souravmsh-laravel-widget/health.svg)](https://phpackages.com/packages/souravmsh-laravel-widget)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.5M85](/packages/unisharp-laravel-filemanager)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
