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

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:

Closure Parameters

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

Visibility Control

Components provide powerful visibility control methods:

hidden()

Hide the component based on a condition.
Example:

visible()

Show the component based on a condition.
Example:

isHidden()

Check if the component is hidden.

isVisible()

Check if the component is visible.

Disability Control

disabled()

Disable the component.
Example:

isDisabled()

Check if the component is disabled.

Layout Control

columnSpan()

Set how many columns the component should span.
Example:

columns()

Set the number of columns for child components.
Example:

grow()

Allow the component to grow to fill available space.

maxWidth()

Set the maximum width for the component.
Example:

Child Components

schema()

Set the child components.
Example:

Actions

Components can have associated actions:

actions()

Set the actions for the component.
Example:

State Binding

statePath()

Set the state path for the component.
Example:

getStatePath()

Get the state path.

getState()

Get the current state.

getRawState()

Get the raw state before type casting.

Model Binding

model()

Set the Eloquent model for the component.

getModel()

Get the Eloquent model.

getRecord()

Get the current record (alias for getModel).

Livewire Integration

getLivewire()

Get the parent Livewire component.

Key and ID

key()

Set a unique key for the component.

getKey()

Get the component key.

id()

Set the HTML ID.

getId()

Get the HTML ID.

Extra Attributes

extraAttributes()

Set additional HTML attributes.
Example:

Utilities

makeGetUtility()

Create a Get utility for accessing component state.

makeSetUtility()

Create a Set utility for modifying component state.

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