# Input (/docs/netwizard/parameters/input)

> Collect a single line of text, such as a host name or user name, on the NetWizard configuration page.

Library: NetWizard

An input parameter displays a single-line text field on the configuration page. Use it to collect application settings such as server addresses, user names or identifiers.

![Input parameter](https://docs.softt.io/img/netwizard/nw-input.png)

## Constructor

```cpp
NetWizardParameter nw_input(&NW, NW_INPUT, name, value, placeholder, required);
```

<TypeTable
  type={{
    parent: { type: 'NetWizard*', description: 'NetWizard instance the parameter is added to.', required: true },
    type: { type: 'const int', description: '`NW_INPUT`.', required: true },
    name: { type: 'const char*', description: 'Label shown above the field.', required: true },
    value: { type: 'const char*', description: 'Initial value. Pass an empty string for none.', default: '""' },
    placeholder: { type: 'const char*', description: 'Hint shown while the field is empty.', default: '""' },
    required: { type: 'bool', description: 'Whether the user must fill in the field. See [Required and optional parameters](/docs/netwizard/parameters#required-and-optional-parameters).', default: 'true' },
  }}
/>

```cpp
NetWizardParameter nw_host(&NW, NW_INPUT, "MQTT Host", "", "mqtt.example.com");
```

## Methods

### `getValueStr()`

```cpp
String val = nw_host.getValueStr();
```

Returns the current value.

### `getValue()`

```cpp
String val;
nw_host.getValue(val);
```

Copies the current value into a `String`.

### `setValue()`

```cpp
nw_host.setValue("broker.example.com");
```

Sets the value shown in the portal.

See [Parameters](/docs/netwizard/parameters#methods) for the methods shared by all parameter types.

## Example

```cpp title="main.cpp"
#include <WebServer.h>
#include <NetWizard.h>

WebServer server(80);
NetWizard NW(&server);

NetWizardParameter nw_host(&NW, NW_INPUT, "MQTT Host", "", "mqtt.example.com");

void setup() {
  Serial.begin(115200);

  NW.onConfig([&]() {
    Serial.printf("MQTT host: %s\n", nw_host.getValueStr().c_str());
    return true;
  });

  NW.autoConnect("NetWizard Demo", "");
  server.begin();
}

void loop() {
  NW.loop();
}
```
