mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-28 03:44:19 +08:00
1.3 KiB
1.3 KiB
title
| title |
|---|
| Checkbox |
The checkbox component, similar to a toggle, allows you to interact a boolean value.
use Filament\Forms\Components\Checkbox;
Checkbox::make('is_admin')
If you're saving the boolean value using Eloquent, you should be sure to add a boolean cast to the model property:
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $casts = [
'is_admin' => 'boolean',
];
// ...
}
Positioning the label above
Checkbox fields have two layout modes, inline and stacked. By default, they are inline.
When the checkbox is inline, its label is adjacent to it:
use Filament\Forms\Components\Checkbox;
Checkbox::make('is_admin')->inline()
When the checkbox is stacked, its label is above it:
use Filament\Forms\Components\Checkbox;
Checkbox::make('is_admin')->inline(false)

