Skip to main content

Component | URL Input

Render a url input box.

ui.urlInput("url-input-key", { 
label: "Enter a url",
onEnter: (value) => console.log(value)
})

This component is a light wrapper on top of ui.textInput with url validation built in.

Learn more about working with inputs.

API reference

Function signature

ui.urlInput(
id: string,
properties?: Partial<{
label: string,
description: string,
required: boolean,
initialValue: string | null,
validate: (value: string | null) => string | void,
onEnter: (value: string | null) => void,
style: Style
}>
)

Parameters

id

required string
A unique identifier for the component. This is necessary so that Compose can properly pass user actions back to the component.

properties.label

optional string

The label to display above the url input. If not provided, the label will be inferred from the id.


properties.description

optional string

A description to display between the label and url input box.


properties.required

optional boolean

Validate that the url input is not empty before submitting the form it's part of or calling it's onEnter hook. Defaults to true.


properties.initialValue

optional string | null

The initial value of the url input. Defaults to null. You can also update the value of the url input at any time using the page.setInputs() method.


properties.validate

optional (value: string | null) => string | void
Validate the url input value before submitting it. If the function returns a string, it will be displayed as an error message.

properties.onEnter

optional (value: string | null) => void
A callback function that is called when the user presses enter in the url input.

properties.style

optional Style

Directly style the underlying element using CSS. See the styling guide for more details on available style properties.