> For the complete documentation index, see [llms.txt](https://crudstarter.gitbook.io/crudstarter-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://crudstarter.gitbook.io/crudstarter-docs/components.md).

# Components

This package uses laravel anonymous components to leverage the power of laravel and promote code re-usability.

## Form Components

### Input component

example:&#x20;

```html
<x-form.input type="text" col="6" :req="true" label="Blog Title" id="blog_title" name="blog_title" value="{{ old('blog_title') }}" />
```

<table data-full-width="true"><thead><tr><th width="132">Prop Name</th><th width="135">Default Value</th><th width="100">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>none</td><td>Yes</td><td>The name of the input field, used for form submission and validation.</td></tr><tr><td><code>id</code></td><td>Value of <code>$name</code> prop</td><td>No</td><td>The ID of the input field.</td></tr><tr><td><code>label</code></td><td>'Label'</td><td>No</td><td>The label text for the input field.</td></tr><tr><td><code>class</code></td><td>empty</td><td>No</td><td>Additional CSS classes to apply to the input field.</td></tr><tr><td><code>value</code></td><td>empty</td><td>No</td><td>The initial value of the input field.</td></tr><tr><td><code>type</code></td><td>'text'</td><td>No</td><td>The type of the input field (e.g., <code>text</code>, <code>email</code>, <code>password</code>).</td></tr><tr><td><code>message</code></td><td>empty</td><td>No</td><td>The validation error message to display if there's an error.</td></tr><tr><td><code>col</code></td><td>12</td><td>No</td><td>The Bootstrap column width for the input field.</td></tr><tr><td><code>req</code></td><td><code>false</code></td><td>No</td><td>A boolean indicating whether the field is required or not. If <code>true</code>, an asterisk (*) will be added next to the label.</td></tr><tr><td><code>labelDisplay</code></td><td><code>true</code></td><td>No</td><td>A boolean indicating whether to display the label or not.</td></tr><tr><td><code>tooltip</code></td><td><code>false</code></td><td>No</td><td>A boolean indicating whether to display a tooltip or not.</td></tr><tr><td><code>tooltip_text</code></td><td>'Tooltip on top'</td><td>No</td><td>The text to display in the tooltip.</td></tr></tbody></table>

### Button component

example:

```html
 <x-form.button class="btn btn-sm btn-dark" type="submit"><i class='bx bx-save bx-xs'></i> Save</x-form.button>
```

<table><thead><tr><th width="128">Prop Name</th><th width="133">Default Value</th><th width="104">Required</th><th>Description</th></tr></thead><tbody><tr><td>(Slot Content)</td><td>-</td><td>Yes</td><td>The content to be displayed inside the button element.</td></tr><tr><td><code>id</code></td><td>'id'</td><td>No</td><td>The ID of the button element.</td></tr><tr><td><code>class</code></td><td>empty</td><td>No</td><td>Additional CSS classes to apply to the button element.</td></tr><tr><td><code>type</code></td><td>'submit'</td><td>No</td><td>The type of the button (e.g., 'submit', 'button', 'reset').</td></tr></tbody></table>

### Textarea component

example:

```html
<x-form.textarea label="Description" :req="true" id="description" name="description" value="{{ old('description') }}" rows="5" cols="5"/>
```

<table><thead><tr><th width="131">Prop Name</th><th width="137">Default Value</th><th width="99">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>-</td><td>Yes</td><td>The name of the textarea field, used for form submission and validation.</td></tr><tr><td><code>id</code></td><td>Value of <code>$name</code> prop</td><td>No</td><td>The ID of the textarea field.</td></tr><tr><td><code>label</code></td><td>'Label'</td><td>No</td><td>The label text for the textarea field.</td></tr><tr><td><code>class</code></td><td>empty</td><td>No</td><td>Additional CSS classes to apply to the textarea field.</td></tr><tr><td><code>value</code></td><td>empty</td><td>No</td><td>The initial value of the textarea field.</td></tr><tr><td><code>message</code></td><td>empty</td><td>No</td><td>The validation error message to display if there's an error.</td></tr><tr><td><code>col</code></td><td>12</td><td>No</td><td>The Bootstrap column width for the textarea field.</td></tr><tr><td><code>req</code></td><td><code>false</code></td><td>No</td><td>A boolean indicating whether the field is required or not. If <code>true</code>, an asterisk (*) will be added next to the label.</td></tr></tbody></table>

### Checkbox

example:

```html
<x-form.checkbox label="Status" id="status" name="status" value="1" class="form-check-input" isEditMode="yes" :isChecked="'checked'" col="6" />
```

<table><thead><tr><th width="133">Prop Name</th><th width="134">Default Value</th><th width="100">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>-</td><td>Yes</td><td>The name of the checkbox field, used for form submission and validation.</td></tr><tr><td><code>id</code></td><td>Value of <code>$name</code> prop</td><td>No</td><td>The ID of the checkbox field.</td></tr><tr><td><code>label</code></td><td>'CheckBox'</td><td>No</td><td>The label text for the checkbox field.</td></tr><tr><td><code>class</code></td><td>empty</td><td>No</td><td>Additional CSS classes to apply to the checkbox field.</td></tr><tr><td><code>value</code></td><td>1</td><td>No</td><td>The value of the checkbox field when checked.</td></tr><tr><td><code>message</code></td><td>empty</td><td>No</td><td>The validation error message to display if there's an error.</td></tr><tr><td><code>isChecked</code></td><td>empty</td><td>No</td><td>A boolean or string value indicating whether the checkbox should be checked or not.</td></tr><tr><td><code>isEditMode</code></td><td>empty</td><td>No</td><td>A boolean or string value indicating whether the checkbox is in edit mode or not.</td></tr><tr><td><code>col</code></td><td>12</td><td>No</td><td>The Bootstrap column width for the checkbox field.</td></tr></tbody></table>

### Row Component

example:

```html
 <x-form.row>
       <x-form.input type="text" col="6" label="Title" id="title" name="title" :req="true" value="{{ old('title') }}" />
       <x-form.input type="text" col="6" label="Slug" id="slug" name="slug" :req="true" value="{{ old('slug') }}" />
</x-form.row>
```

<table><thead><tr><th width="153">Prop Name</th><th width="135">Default Value</th><th width="100">Required</th><th>Description</th></tr></thead><tbody><tr><td>(Slot Content)</td><td>-</td><td>Yes</td><td>The content to be displayed inside the div element.</td></tr><tr><td>(<code>$attributes</code>)</td><td>-</td><td>No</td><td>Additional HTML attributes to apply to the div element.</td></tr></tbody></table>

### Select Component

example:

```html
<x-form.select name="role_id" :options="$roles" label="Role" :model="$role->role_id"></x-form.select>
```

<table><thead><tr><th width="130">Prop Name</th><th width="133">Default Value</th><th width="100">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>-</td><td>Yes</td><td>The name of the select field, used for form submission and validation.</td></tr><tr><td><code>id</code></td><td>Value of <code>$name</code> prop</td><td>No</td><td>The ID of the select field.</td></tr><tr><td><code>label</code></td><td>'Select'</td><td>No</td><td>The label text for the select field.</td></tr><tr><td><code>class</code></td><td>'form-control'</td><td>No</td><td>Additional CSS classes to apply to the select field.</td></tr><tr><td><code>value</code></td><td>empty</td><td>No</td><td>The initial value of the select field (not used in this component).</td></tr><tr><td><code>message</code></td><td>empty</td><td>No</td><td>The validation error message to display if there's an error.</td></tr><tr><td><code>col</code></td><td>12</td><td>No</td><td>The Bootstrap column width for the select field.</td></tr><tr><td><code>req</code></td><td><code>false</code></td><td>No</td><td>A boolean indicating whether the field is required or not. If <code>true</code>, an asterisk (*) will be added next to the label.</td></tr><tr><td><code>labelDisplay</code></td><td><code>true</code></td><td>No</td><td>A boolean indicating whether to display the label or not.</td></tr><tr><td><code>optionDisplay</code></td><td><code>true</code></td><td>No</td><td>A boolean indicating whether to display a default "Select {label}" option or not.</td></tr><tr><td><code>model</code></td><td><code>null</code></td><td>No</td><td>The model value to be selected in the options.</td></tr><tr><td><code>_key</code></td><td><code>null</code></td><td>No</td><td>A key value used for selecting the default option when no model is provided.</td></tr><tr><td><code>options</code></td><td>-</td><td>Yes</td><td>An array of key-value pairs representing the options to be displayed in the select field.</td></tr><tr><td>(Slot Content)</td><td>-</td><td>No</td><td>Additional content to be displayed inside the select element.</td></tr></tbody></table>

### Enum Select

<table><thead><tr><th width="131">Prop Name</th><th width="136">Default Value</th><th width="98">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>-</td><td>Yes</td><td>The name of the select field, used for form submission and validation.</td></tr><tr><td><code>id</code></td><td>Value of <code>$name</code> prop</td><td>No</td><td>The ID of the select field.</td></tr><tr><td><code>label</code></td><td>'Select'</td><td>No</td><td>The label text for the select field.</td></tr><tr><td><code>class</code></td><td>'form-control text-14'</td><td>No</td><td>Additional CSS classes to apply to the select field.</td></tr><tr><td><code>value</code></td><td>empty</td><td>No</td><td>The initial value of the select field (not used in this component).</td></tr><tr><td><code>message</code></td><td>empty</td><td>No</td><td>The validation error message to display if there's an error.</td></tr><tr><td><code>col</code></td><td>12</td><td>No</td><td>The Bootstrap column width for the select field.</td></tr><tr><td><code>req</code></td><td><code>false</code></td><td>No</td><td>A boolean indicating whether the field is required or not. If <code>true</code>, an asterisk (*) will be added next to the label.</td></tr><tr><td><code>model</code></td><td><code>null</code></td><td>No</td><td>The model value to be selected in the options.</td></tr><tr><td><code>optionDisplay</code></td><td><code>true</code></td><td>No</td><td>A boolean indicating whether to display a default "Select {label}" option or not.</td></tr><tr><td><code>labelDisplay</code></td><td><code>true</code></td><td>No</td><td>A boolean indicating whether to display the label or not.</td></tr><tr><td><code>options</code></td><td>-</td><td>Yes</td><td>An array of objects representing the options to be displayed in the select field, where each object has a <code>value</code> and a <code>name</code> property.</td></tr></tbody></table>

## Sidebar Components

### Single-Level Sidebar Component&#x20;

To create a sidebar item for your Dashboard:

Use this code:

```html
<x-sidebar-item 
    route="{{ route('home') }}"
    name="Dashboard" 
    uri="home"
>
    <i class="menu-icon tf-icons bx bx-home-circle"></i>
</x-sidebar-item>
```

This code does the following:

* Sets the route to 'home'
* Displays "Dashboard" as the name
* Uses '/home' as the URL

### Multi-Level Sidebar

To create a sidebar item with multiple subitems:

Use this structure:

```html
<x-sidebar-multilist-head 
    icon="bx bxs-report" 
    name="Reports" 
    :routes="[
        'admin/package/reports',
        'admin/package/filters',
    ]"
>
    <x-sidebar-item 
        route="{{ route('admin.package-reports.filters') }}"
        name="Package Filter" 
        uri="admin/package/filters"
    >
    </x-sidebar-item>

    <x-sidebar-item 
        route="{{ route('admin.package-reports.index') }}"
        name="Package Report" 
        uri="admin/package/reports"
    >
    </x-sidebar-item>
</x-sidebar-multilist-head>
```

This code does the following:

* Creates a main sidebar item called "Reports" with a report icon
* Specifies two routes that will be part of this multihead item
* Adds two subitems: "Package Filter" and "Package Report"
* Each subitem has its own route, name, and URI
