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 staticmake() 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:The operation context (e.g., ‘create’, ‘edit’, ‘view’)
Alias for context
Utility for getting component state
The Livewire component instance
The Eloquent model instance
The current record
Utility for setting component state
The current component state
Visibility Control
Components provide powerful visibility control methods:hidden()
Hide the component based on a condition.visible()
Show the component based on a condition.isHidden()
Check if the component is hidden.isVisible()
Check if the component is visible.Disability Control
disabled()
Disable the component.isDisabled()
Check if the component is disabled.Layout Control
columnSpan()
Set how many columns the component should span.columns()
Set the number of columns for child components.grow()
Allow the component to grow to fill available space.maxWidth()
Set the maximum width for the component.Child Components
schema()
Set the child components.Actions
Components can have associated actions:actions()
Set the actions for the component.State Binding
statePath()
Set the state path for the component.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.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 relationshipBelongsToModel- Model bindingCanBeConcealed- Concealment logicCanBeDisabled- Disability controlCanBeGridContainer- Grid layout supportCanBeHidden- Visibility controlCanBeLiberatedFromContainerGrid- Grid liberationCanBeRepeated- Repeater supportCanGrow- Growth controlCanOrderColumns- Column orderingCanPartiallyRender- Partial renderingCanPoll- Polling supportCanSpanColumns- Column spanningCloneable- Component cloningHasActions- Action supportHasChildComponents- Child component managementHasColumns- Column configurationHasEntryWrapper- Entry wrapper (infolists)HasExtraAttributes- Extra HTML attributesHasFieldWrapper- Field wrapper (forms)HasGap- Gap configurationHasHeadings- Heading supportHasId- ID managementHasInlineLabel- Inline label supportHasKey- Key managementHasMaxWidth- Width constraintsHasMeta- Metadata storageHasState- State managementHasStateBindingModifiers- State binding modifiers