Skip to content

Textinput

Textinput components are Input Fields that allow the user to enter string chains.

textinput.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'input',
type: 'textinput',
path: 'listName',
label: 'First Name',
},
],
});

Use this props to customize your Textinput component.

proptypevalue
placeholderstringA placeholder text to display when the text input has no value
hintstringA description to display below the text input
iconstringA css class to display an icon
autocompletestring'on', 'off', or a space-separated list of W3C autofill tokens

Use the property placeholder to add a placeholder.

textinput.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'input',
type: 'textinput',
path: 'listName',
label: 'First Name',
props: {
placeholder: 'Enter your first name',
},
},
],
});

Use the property hint to add a description.

textinput.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'input',
type: 'textinput',
path: 'password',
label: 'Street Address',
props: {
hint: 'Your street address as stated in your Document ID',
},
},
],
});

Use the property icon to add an icon to the textinput. The value of icon represents a set of CSS classes separated by spaces.

textinput.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'input',
type: 'textinput',
path: 'phoneNumber',
label: 'Phone Number',
props: {
icon: 'phone_callback',
},
},
{
kind: 'input',
type: 'textinput',
path: 'email',
label: 'Email',
props: {
icon: 'alternate_email',
},
},
],
});

Textinputs can be styled as explained in the Styling Guide.

Following you will find a list with the CSS Variables and a quick description of what you will style.

CSS VariableDescription
--gui-space-gap--innerLabel gap and margin bottom
--gui-paddingInput padding
--gui-color-borderInput border color
--gui-radiusInput radius
--gui-color-bgInput background color
--gui-color-fgInput text color
--gui-color-primaryInput border color and outline on focus
--gui-color-errorInput border color when invalid
--gui-space-gapIcon left padding
--gui-icon-space-gapIcon right padding
--gui-font-size--smallHint font size
--gui-color-fg--secondaryHint font color

This is the anatomy of the Textinput Component in case you want to use your CSS styles.

textinput.html
<gui-textinput>
<label for="fieldUid">
Label
<div class="gui-textinput__hint" id="fieldUid_hint">Hint</div>
</label>
<div class="gui-widget">
<input
type="text"
id="fieldUid"
class="gui-textinput__icon gui-textinput__icon--right"
disabled
readonly
placeholder="Custom placeholder"
aria-required="true"
aria-describedby="fieldUid_hint"
/>
<span class="gui-textinput__icon gui-textinput__icon--right"></span>
</div>
</gui-textinput>