Skip to main content
The Component class is the foundation for all schema components in Filament, including form fields, infolist entries, and layout components. It provides core functionality for state management, visibility control, and component composition.

Namespace

Filament\Schemas\Components\Component

Inheritance

Extends: Filament\Support\Components\ViewComponent

Constructor

The Component class does not define a public constructor. Use the static make() method provided by extending classes.

State Management

State Access

Components can access and modify state through injected parameters:
use Filament\Forms\Get;
use Filament\Forms\Set;

TextInput::make('price')
    ->live()
    ->afterStateUpdated(function (Set $set, ?float $state) {
        $set('total', $state * 1.2);
    });

Closure Parameters

Closures in component methods automatically receive contextual parameters:
context
string
The operation context (e.g., ‘create’, ‘edit’, ‘view’)
operation
string
Alias for context
get
Get
Utility for getting component state
livewire
Component
The Livewire component instance
model
Model | null
The Eloquent model instance
record
Model | array | null
The current record
set
Set
Utility for setting component state
state
mixed
The current component state

Visibility Control

Components provide powerful visibility control methods:

hidden()

Hide the component based on a condition.
public function hidden(bool | Closure $condition = true): static
Example:
TextInput::make('vat_number')
    ->hidden(fn (Get $get) => $get('country') !== 'GB');

visible()

Show the component based on a condition.
public function visible(bool | Closure $condition = true): static
Example:
TextInput::make('state')
    ->visible(fn (Get $get) => $get('country') === 'US');

isHidden()

Check if the component is hidden.
public function isHidden(): bool

isVisible()

Check if the component is visible.
public function isVisible(): bool

Disability Control

disabled()

Disable the component.
public function disabled(bool | Closure $condition = true): static
Example:
TextInput::make('email')
    ->disabled(fn (string $operation) => $operation === 'view');

isDisabled()

Check if the component is disabled.
public function isDisabled(): bool

Layout Control

columnSpan()

Set how many columns the component should span.
public function columnSpan(int | string | array | Closure $span): static
Example:
Textarea::make('description')
    ->columnSpan('full'); // or 2, or ['md' => 2, 'xl' => 3]

columns()

Set the number of columns for child components.
public function columns(int | array | Closure $columns): static
Example:
Section::make()
    ->columns([
        'sm' => 1,
        'md' => 2,
        'lg' => 3,
    ]);

grow()

Allow the component to grow to fill available space.
public function grow(bool | Closure $condition = true): static

maxWidth()

Set the maximum width for the component.
public function maxWidth(Width | string | Closure | null $width): static
Example:
use Filament\Support\Enums\Width;

Section::make()
    ->maxWidth(Width::TwoExtraLarge);

Child Components

schema()

Set the child components.
public function schema(array | Closure $components): static
Example:
Section::make('Contact Information')
    ->schema([
        TextInput::make('email'),
        TextInput::make('phone'),
    ]);

Actions

Components can have associated actions:

actions()

Set the actions for the component.
public function actions(array | Closure $actions): static
Example:
Section::make()
    ->actions([
        Action::make('edit')
            ->icon('heroicon-o-pencil'),
    ]);

State Binding

statePath()

Set the state path for the component.
public function statePath(?string $path): static
Example:
TextInput::make('name')
    ->statePath('data.user.name');

getStatePath()

Get the state path.
public function getStatePath(bool $isAbsolute = true): string

getState()

Get the current state.
public function getState(): mixed

getRawState()

Get the raw state before type casting.
public function getRawState(): mixed

Model Binding

model()

Set the Eloquent model for the component.
public function model(Model | string | Closure | null $model): static

getModel()

Get the Eloquent model.
public function getModel(): ?Model

getRecord()

Get the current record (alias for getModel).
public function getRecord(): Model | array | null

Livewire Integration

getLivewire()

Get the parent Livewire component.
public function getLivewire(): Component

Key and ID

key()

Set a unique key for the component.
public function key(string | Closure | null $key): static

getKey()

Get the component key.
public function getKey(): ?string

id()

Set the HTML ID.
public function id(string | Closure | null $id): static

getId()

Get the HTML ID.
public function getId(): ?string

Extra Attributes

extraAttributes()

Set additional HTML attributes.
public function extraAttributes(array | Closure $attributes, bool $merge = false): static
Example:
TextInput::make('name')
    ->extraAttributes([
        'class' => 'custom-class',
        'data-foo' => 'bar',
    ]);

Utilities

makeGetUtility()

Create a Get utility for accessing component state.
public function makeGetUtility(): Get

makeSetUtility()

Create a Set utility for modifying component state.
public function makeSetUtility(): Set

Traits

The Component class uses numerous traits:
  • BelongsToContainer - Container relationship
  • BelongsToModel - Model binding
  • CanBeConcealed - Concealment logic
  • CanBeDisabled - Disability control
  • CanBeGridContainer - Grid layout support
  • CanBeHidden - Visibility control
  • CanBeLiberatedFromContainerGrid - Grid liberation
  • CanBeRepeated - Repeater support
  • CanGrow - Growth control
  • CanOrderColumns - Column ordering
  • CanPartiallyRender - Partial rendering
  • CanPoll - Polling support
  • CanSpanColumns - Column spanning
  • Cloneable - Component cloning
  • HasActions - Action support
  • HasChildComponents - Child component management
  • HasColumns - Column configuration
  • HasEntryWrapper - Entry wrapper (infolists)
  • HasExtraAttributes - Extra HTML attributes
  • HasFieldWrapper - Field wrapper (forms)
  • HasGap - Gap configuration
  • HasHeadings - Heading support
  • HasId - ID management
  • HasInlineLabel - Inline label support
  • HasKey - Key management
  • HasMaxWidth - Width constraints
  • HasMeta - Metadata storage
  • HasState - State management
  • HasStateBindingModifiers - State binding modifiers
  • Field - Form field components
  • Column - Table column components
  • Action - Action components

Build docs developers (and LLMs) love