LaraUI - V1.0

Select

The <x-xf::select> component is a customizable Blade component for rendering HTML <select> dropdowns in Laravel forms. It supports dynamic option rendering, default selection, sizing, and enhanced customization using attributes and styling classes.

📄 <x-xf::select>

📘 Description

The <x-xf::select> component provides a reusable and flexible way to generate dropdown select menus in Laravel Blade views. It supports dynamic option lists, default selected values via checked or value, size customization, and custom HTML attributes for enhanced styling or behavior.

Ideal for selecting from lists like countries, categories, roles, and more — this component integrates seamlessly with Laravel's form model binding and old() input retention.

✅ Usage Example

<x-xf::select 
    name="country" 
    :options="['us' => 'USA', 'ca' => 'Canada']" 
    label="Select Country" 
    checked="ca" 
    size="md" 
    :attr="['required' => true]" 
    class="mb-4"
/>

🔑 Props

Name Type Required Default Description
name string The name of the select field. Required for form submission and binding.
options array Key-value array of selectable options (key = value, value = label).
attr array [] Additional HTML attributes (e.g., multiple, disabled).
size string 'md' Controls input size: sm, md, or lg.
label string|null null Optional label displayed above the select dropdown.
checked mixed null Value(s) to mark as selected in the dropdown.
value mixed null Alternative to checked for selected value. Useful with model binding.
class string|null null CSS class for additional styling.

🛡 Features

  • ✅ Clean and dynamic dropdown rendering
  • ✅ Supports single or multiple selection
  • ✅ Fully customizable via attributes and classes
  • ✅ Integrates with old() and model binding