class Select extends InputTriggerBase

Select Component.

A powerful select input supporting arrays, Eloquent collections, remote search, and object mapping.

Traits

Trait HasPresets.

Trait HasErrorBag.

Properties

$size
$options
$selected
string|null $icon
$placeholder
bool $searchable
$label
bool $multiple
bool $clearable
bool $remote
string|null $remoteUrl
$color
$initialValue
int $perPage
$customError
string|null $hint
string|null $help
string|null $optionLabel

Field map for option label.

string|null $optionValue

Field map for option value.

string|null $optionDescription

Field map for option description.

string|null $optionIcon

Field map for option icon.

string|null $optionAvatar

Field map for option avatar.

bool $autosave
string|null $autosaveMethod
string|null $autosaveKey
int $autosaveDebounce
string|null $emptyMessage
bool $isEmpty
bool $spinner
bool $defer
bool $fitTrigger
bool $userSearchable
bool $userClearable
static array<int, array{_value: mixed, label: string|null, icon: string|null, avatar: string|null, description: string|null}> $pendingSlotOptions

Methods

array
getComponentPresets(string|null $componentName = null, ComponentAttributeBag|null $attributes = null)

Compute component presets based on context.

array
loadPresets(string $componentName)

No description

array
loadComponentDefaults(string $componentName)

No description

bool
detectHasVariants(array $colors)

No description

array
computeSupports(array $sizes, array $colorsArray, array $defaults, array $magicProps)

No description

array
resolveSize(array $supports, array $sizes, array $defaults, array $magicProps)

No description

array
resolveVariant(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, bool $hasVariants)

No description

array
resolveColor(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, string|null $variant, bool $hasVariants)

No description

array
resolveFill(array $supports, array $attributes, array $defaults)

No description

string
buildCacheKey(string $component, array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill)

No description

void
syncInstanceProps(array $supports, string|null $size, string|null $variant, string|null $color)

No description

array
buildPresetNames(array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill, string $sizeOrigin, string $variantOrigin, string $colorOrigin, string $fillOrigin)

No description

void
debugWarnings(array $supports, array $sizePreset, array $colorPreset, string $componentName, string|null $variant, string|null $color)

No description

array
getErrorState(ComponentAttributeBag|null $attributes = null, ViewErrorBag|MessageBag|null $errors = null, string|null $error = null)

Determine the error state for a specific field.

array
getWireModelState(ComponentAttributeBag|null $attributes = null)

Analyze wire:model attributes to determine binding state.

array
getSizePreset(string|null $componentName = null, array|ComponentAttributeBag|null $attributes = null, string $defaultSize = 'md')

Resolve the size preset for the component.

__construct($options = null, $selected = null, $icon = null, $placeholder = null, $searchable = true, $label = null, $multiple = false, $clearable = true, $remote = false, $remoteUrl = null, $size = null, $color = null, $initialValue = null, $perPage = 15, $customError = null, $hint = null, $help = null, $autosave = false, $autosaveMethod = 'savePreference', $autosaveKey = null, $autosaveDebounce = 300, $optionLabel = 'label', $optionValue = 'value', $optionDescription = 'description', $optionIcon = 'icon', $optionAvatar = 'avatar', $emptyMessage = null, $spinner = true, $defer = false, $fitTrigger = true)

Create a new Select component instance.

View
render()

Get the view / contents that represent the component.

static string|null
renderIcon(string|null $icon)

Pre-render an icon string into HTML.

array<string, array{_value: mixed, label: string|null, icon: string|null, avatar: string|null, description: string|null}>
normalizeOptions(mixed $options)

Normalize options into a standard array format.

Details

in HasPresets at line 21
array getComponentPresets(string|null $componentName = null, ComponentAttributeBag|null $attributes = null)

Compute component presets based on context.

Parameters

string|null $componentName

Component key.

ComponentAttributeBag|null $attributes

Attributes bag.

Return Value

array

[colorPreset, sizePreset, shouldFill, presetNames]

in HasPresets at line 59
protected array loadPresets(string $componentName)

No description

Parameters

string $componentName

Return Value

array

in HasPresets at line 73
protected array loadComponentDefaults(string $componentName)

No description

Parameters

string $componentName

Return Value

array

in HasPresets at line 88
protected bool detectHasVariants(array $colors)

No description

Parameters

array $colors

Return Value

bool

in HasPresets at line 116
protected array computeSupports(array $sizes, array $colorsArray, array $defaults, array $magicProps)

No description

Parameters

array $sizes
array $colorsArray
array $defaults
array $magicProps

Return Value

array

in HasPresets at line 137
protected array resolveSize(array $supports, array $sizes, array $defaults, array $magicProps)

No description

Parameters

array $supports
array $sizes
array $defaults
array $magicProps

Return Value

array

in HasPresets at line 174
protected array resolveVariant(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, bool $hasVariants)

No description

Parameters

array $supports
array $colorsArray
array $componentPresets
array $defaults
array $magicProps
bool $hasVariants

Return Value

array

in HasPresets at line 223
protected array resolveColor(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, string|null $variant, bool $hasVariants)

No description

Parameters

array $supports
array $colorsArray
array $componentPresets
array $defaults
array $magicProps
string|null $variant
bool $hasVariants

Return Value

array

in HasPresets at line 293
protected array resolveFill(array $supports, array $attributes, array $defaults)

No description

Parameters

array $supports
array $attributes
array $defaults

Return Value

array

in HasPresets at line 338
protected string buildCacheKey(string $component, array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill)

No description

Parameters

string $component
array $supports
string|null $size
string|null $variant
string|null $color
bool $shouldFill

Return Value

string

in HasPresets at line 349
protected void syncInstanceProps(array $supports, string|null $size, string|null $variant, string|null $color)

No description

Parameters

array $supports
string|null $size
string|null $variant
string|null $color

Return Value

void

in HasPresets at line 365
protected array buildPresetNames(array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill, string $sizeOrigin, string $variantOrigin, string $colorOrigin, string $fillOrigin)

No description

Parameters

array $supports
string|null $size
string|null $variant
string|null $color
bool $shouldFill
string $sizeOrigin
string $variantOrigin
string $colorOrigin
string $fillOrigin

Return Value

array

in HasPresets at line 384
protected void debugWarnings(array $supports, array $sizePreset, array $colorPreset, string $componentName, string|null $variant, string|null $color)

No description

Parameters

array $supports
array $sizePreset
array $colorPreset
string $componentName
string|null $variant
string|null $color

Return Value

void

in HasErrorBag at line 24
array getErrorState(ComponentAttributeBag|null $attributes = null, ViewErrorBag|MessageBag|null $errors = null, string|null $error = null)

Determine the error state for a specific field.

Checks both the session error bag and specific error attributes. Looks up errors by wire:model value or name attribute.

Parameters

ComponentAttributeBag|null $attributes

Component attributes.

ViewErrorBag|MessageBag|null $errors

Global error bag.

string|null $error

Specific error message override.

Return Value

array

[hasError, firstErrorMessage]

in BeartropyComponent at line 33
array getWireModelState(ComponentAttributeBag|null $attributes = null)

Analyze wire:model attributes to determine binding state.

Detects if wire:model is present and if it uses dot notation (e.g., user.name).

Parameters

ComponentAttributeBag|null $attributes

Component attributes.

Return Value

array

[hasWireModel, wireModelValue, hasDotNotation, parsedDotNotationValue]

in BeartropyComponent at line 64
array getSizePreset(string|null $componentName = null, array|ComponentAttributeBag|null $attributes = null, string $defaultSize = 'md')

Resolve the size preset for the component.

Checks:

  1. Explicit $this->size.
  2. Magic attributes (e.g., <x-button sm />).
  3. Default size.

Parameters

string|null $componentName

Component name (used for context).

array|ComponentAttributeBag|null $attributes

Attributes array or bag.

string $defaultSize

Default size key.

Return Value

array

The resolved size preset configuration.

at line 122
__construct($options = null, $selected = null, $icon = null, $placeholder = null, $searchable = true, $label = null, $multiple = false, $clearable = true, $remote = false, $remoteUrl = null, $size = null, $color = null, $initialValue = null, $perPage = 15, $customError = null, $hint = null, $help = null, $autosave = false, $autosaveMethod = 'savePreference', $autosaveKey = null, $autosaveDebounce = 300, $optionLabel = 'label', $optionValue = 'value', $optionDescription = 'description', $optionIcon = 'icon', $optionAvatar = 'avatar', $emptyMessage = null, $spinner = true, $defer = false, $fitTrigger = true)

Create a new Select component instance.

Parameters

$options
$selected
$icon
$placeholder
$searchable
$label
$multiple
$clearable
$remote
$remoteUrl
$size
$color
$initialValue
$perPage
$customError
$hint
$help
$autosave
$autosaveMethod
$autosaveKey
$autosaveDebounce
$optionLabel
$optionValue
$optionDescription
$optionIcon
$optionAvatar
$emptyMessage
$spinner
$defer
$fitTrigger

at line 364
View render()

Get the view / contents that represent the component.

Return Value

View

at line 215
static string|null renderIcon(string|null $icon)

Pre-render an icon string into HTML.

Handles emoji, raw SVG/IMG markup, short text, and Heroicon names.

Parameters

string|null $icon

Raw icon value.

Return Value

string|null

Rendered HTML or the original string.

at line 254
protected array<string, array{_value: mixed, label: string|null, icon: string|null, avatar: string|null, description: string|null}> normalizeOptions(mixed $options)

Normalize options into a standard array format.

Handles:

  • Eloquent Collections.
  • Associative arrays (key => label).
  • Indexed arrays.
  • Array of Options (objects/arrays).

Uses configured field mappings (optionLabel, optionValue) to extract data.

Parameters

mixed $options

Raw options data.

Return Value

array<string, array{_value: mixed, label: string|null, icon: string|null, avatar: string|null, description: string|null}>