martin-ro / filament-charcount-field
Filament fields with character count.
Installs: 3 809
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 1
Forks: 3
Open Issues: 2
Language:Blade
Requires
- php: ^8.0
- filament/filament: ^2.10
- illuminate/contracts: ^8.73|^9.0
Requires (Dev)
- nunomaduro/collision: ^5.10|^6.1
- orchestra/testbench: ^6.22|^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
README
Character counted TextInput & Textarea for Filament.
This package provides a TextInput and Textarea component for Filament Admin and Forms with a character count display.
TextInput
use MartinRo\FilamentCharcountField\Components\CharcountedTextInput; CharcountedTextInput::make('title') ->minCharacters(5) ->maxCharacters(10),
Textarea
use MartinRo\FilamentCharcountField\Components\CharcountedTextarea; CharcountedTextarea::make('title') ->minCharacters(5) ->maxCharacters(10),
Here's an example of how the components looks like:
Demo:
Installation
First, install the packages:
composer require martin-ro/filament-charcount-field
Add the components to a Filament resource form:
<?php namespace App\Filament\Resources; // ... use MartinRo\FilamentCharcountField\Components\CharcountedTextInput; use MartinRo\FilamentCharcountField\Components\CharcountedTextarea; class PostResource extends Resource { // ... public static function form(Form $form): Form { return $form->schema([ // ... // TextInput CharcountedTextInput::make('title') ->label('Title') ->hintIcon('heroicon-o-code') ->hint('Title tag in header') ->helperText('While Google does not specify a length for title tags, usually the first 50–60 characters are displayed.') ->minCharacters(50) ->maxCharacters(60), // Textarea CharcountedTextarea::make('description') ->label('Description') ->rows(4) ->hintIcon('heroicon-o-code') ->hint('Meta description tag in header') ->helperText('Meta descriptions can technically be any length, but Google generally truncates snippets to ~155-160 characters.') ->minCharacters(155) ->maxCharacters(160), // .. ]); } // ... }