Laravel Nova text field with click to copy support

v2.0.5 2023-03-27 13:24 UTC

This package is auto-updated.

Last update: 2024-03-27 15:53:03 UTC


Latest Stable Version Total Downloads License PHP Version Require

A Laravel Nova text field with click to copy support. This field behaves just like a text field but adds the ability to copy the field value to your clipboard with just a click.

This package can also be found on Nova Packages.

animated screenshot


> composer require waynestate/nova-text-copy-field


Add the field to a resource.

use Waynestate\Nova\TextCopy\TextCopy;

public function fields(Request $request)
    return [
        TextCopy::make('Example Copy Field', 'example_copy_field'),

Truncating long strings

In some cases you may want to truncate the display of a fields value but allow still copy the full value. You can use the truncate() method to accomplish this.

TextCopy::make('Some Long Field')

Masking the field value

This works great for secrets like API Keys.

TextCopy::make('Some Secret String', 'some_secret_string')
    ->mask('❌') // default '*'

Copy button title

The title of the copy button defaults to the field name prefixed with 'Copy'. For example, TextCopy::make('Some Field', 'some_field') the button title will be "Copy Some Field".

If you would like to manually set the title you can use the copyButtonTitle() method.

TextCopy::make('Some Field', 'some_field')
    ->copyButtonTitle('Some alternative title')

Alternative copy value

You can choose to mutate and that is copied to the users clipboard. You can either pass a value or a Closure.

TextCopy::make('Some Secret String', 'some_long_string')
    ->copyValue(function ($value) {
        return substr($value, -6);


TextCopy::make('Some Secret String', 'some_long_string')
    ->copyValue('some fixed copy value')

Only displaying the button on hover

TextCopy::make('Some Secret String', 'some_long_string')


Default State

default default

Success State

When the field value has been successfully copied to the user's clipboard. success

Error State

When there is an error adding the field value to the user's clipboard. error

Truncated Display Value

truncated display

Masked Display Value

masked display


Please see CHANGELOG for more information on what has changed recently.


Please see CONTRIBUTING for details.


If you discover any security related issues, please email web@wayne.edu instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.