# Trix

## Without file uploads

There are two versions of the Trix field, with and without attachments. \
The sponsor version has support for file uploads.

## Requirements

Requires you to have `@stack('styles')` in head, and `@stack('scripts')` **after** Livewire and Alpine script tags

{% tabs %}
{% tab title="Preview" %}
![](https://github.com/tanthammar/tall-forms/wiki/simple-trix.png)
{% endtab %}

{% tab title="Component" %}

```php
Trix::make('Trix')
    ->default('The initial value of the trix input') // Example: $this->model->foo
    ->includeExternalScripts() //will only be included once if multiple Trix fields.
    ->rules('nullable|string')
```

{% endtab %}

{% tab title="Headless" %}

```php
//Livewire
public null|string $trix = "Trix input default";
```

```markup
<x-tall-trix
    :field="Trix::blade('Trix text editor', 'trix')"
    :value="$trix"
/>
```

{% endtab %}
{% endtabs %}

## Methods

### ->includeExternalScripts()

* Push external (cdn-links) for required scripts and styles to the layout
* Omit, if you import the scripts manually
* Only pushed once, even if you add multiple Trix fields to the same form.

### ->default($value)

Use this method to set the initial Trix input value. Use `$this->model` to access existing model values.
