Url
A URL input field with validation
The url field is a standard text field with the type url
and a custom URL icon. It comes with built-in validation for URLs.

Example
fields:
url:
label: URL
type: url
Field properties
Property | Type | Default | Description |
---|---|---|---|
after |
– | Optional text that will be shown after the input |
|
autocomplete |
string | url |
Sets the HTML5 autocomplete attribute |
autofocus |
bool | – | Sets the focus on this field when the form loads. Only the first field with this label gets |
before |
– | Optional text that will be shown before the input |
|
default |
– | Default value for the field, which will be used when a page/file/user is created |
|
disabled |
bool | – | If |
help |
– | Optional help text below the field |
|
icon |
string | url |
Changes the link icon |
label |
– | The field label can be set as string or associative array with translations |
|
maxlength |
int | – | Maximum number of allowed characters |
minlength |
int | – | Minimum number of required characters |
pattern |
string | – | A regular expression, which will be used to validate the input |
placeholder |
– | Sets custom placeholder text, when the field is empty |
|
required |
bool | – | If |
translate |
bool | true |
If |
when |
– | Conditions when the field will be shown (since 3.1.0) |
|
width |
string | 1/1 |
The width of the field in the field grid. Available widths: |
How to use in templates/snippets
Output the field value as simple string:
<?= $page->url() ?>
Convert to a
tag:
<?= $page->url()->toLink() ?>
See the docs for the toLink()
method for further options.
For more field manipulations, check out Kirby's field methods.