Search code examples
laravellaravel-5.6laravel-nova

Laravel Nova - Display text area content without option show content


I would like to display text area resource field content always without showing option "Show Content" or display it by default.

enter image description here

Is it possible?


Solution

  • As of v1.1.4

    There is now an option to always show.

    Textarea::make('Title')->alwaysShow()
    

    As of v1.0.19

    You cannot. If you take a look at the TextareaField.vue (nova/resources/js/components/Detail/TextareaField.vue):

    <template>
        <panel-item :field="field">
            <template slot="value">
                <excerpt :content="field.value" />
            </template>
        </panel-item>
    </template>
    

    Then if you take a look at Excerpt.vue (nova/resources/js/components/Excerpt.vue):

    <div v-if="hasContent">
        <div v-if="expanded" class="markdown leading-normal" v-html="content" />
    
        <a
            @click="toggle"
            class="cursor-pointer dim inline-block text-primary font-bold"
            :class="{ 'mt-6': expanded }"
            aria-role="button"
        >
            {{ showHideLabel }}
        </a>
    </div>
    

    And the props of the vue:

    props: {
        content: {
            type: String,
        },
    },
    
    data: () => ({ expanded: false }),
    

    There's no option to pass the expanded attribute.