The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

Nova Text Copy Field

sixlive/nova-text-copy-field image

Nova Text Copy Field stats

Downloads
458.8K
Stars
71
Open Issues
9
Forks
16

View on GitHub →

Laravel Nova text field with click to copy support

Nova Text Copy Field

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.

Installation

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

Usage

Add the field to a resource.

use Sixlive\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')
->truncate(100)

Masking the field value

This works great for secrets like API Keys.

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

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);
})

or

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')
->showButtonOnlyOnHover()

Screenshots

Default State

Success State

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

Error State

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

Truncated Display Value

Masked Display Value

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Code Style

StyleCI will apply the Laravel preset.

Security

If you discover any security related issues, please email oss@tjmiller.co instead of using the issue tracker.

Credits

License

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

sixlive photo

Full stack capable, backend developer. 💚 Laravel, Vue, React, Docker, Node

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Sixlive Nova Text Copy Field Related Articles

How to Validate Your Laravel App's Config image

How to Validate Your Laravel App's Config

Read article
Securing Laravel logo

Securing Laravel

The essential security resource for Laravel devs, covering everything you need to keep your apps secure. Sign up to receive weekly security tips and monthly in depth articles, diving deep into security concepts you need to know!

Securing Laravel
LoadForge logo

LoadForge

Scalable load testing for web apps & APIs. Simulate real-world traffic and identify breaking points and performance limits with powerful, scalable load tests designed for Laravel.

LoadForge
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
CodeKudu logo

CodeKudu

Stand-ups, Retrospectives, and 360° Feedback for the entire team. 50% off with code LARAVELNEWS.

CodeKudu
Celebian logo

Celebian

Celebian is a social media marketing agency specializing in helping their clients go viral on TikTok. Whether you're looking to reach a bigger audience or gain more Tiktok followers, likes, and views, they've got you covered.

Celebian
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel