Skip to content
GitHub11 stars

A text input component for forms and user data entry with built-in styling and accessibility features.

Your API key is encrypted and stored securely.

<Field>
    <FieldLabel for="input-demo-api-key">API Key</FieldLabel>
    <Input id="input-demo-api-key" Type="password" placeholder="sk-..." />
    <FieldDescription>Your API key is encrypted and stored securely.</FieldDescription>
</Field>

Installation

dnx Blazix.Cli add input

Usage

<Input />

Basic

<Input placeholder="Enter text" />

Field

Use Field, FieldLabel, and FieldDescription to create an input with a label and description.

Choose a unique username for your account.

<Field>
    <FieldLabel for="input-field-username">Username</FieldLabel>
    <Input id="input-field-username" Type="text" placeholder="Enter your username" />
    <FieldDescription>Choose a unique username for your account.</FieldDescription>
</Field>

Field Group

Use FieldGroup to show multiple Field blocks and to build forms.

We'll send updates to this address.

<FieldGroup>
    <Field>
        <FieldLabel for="fieldgroup-name">Name</FieldLabel>

Disabled

Use the Disabled parameter to disable the input. To style the disabled state, add the data-disabled attribute to the Field component.

This field is currently disabled.

<Field data-disabled>
    <FieldLabel for="input-demo-disabled">Email</FieldLabel>
    <Input id="input-demo-disabled" Type="email" placeholder="Email" Disabled="true" />
    <FieldDescription>This field is currently disabled.</FieldDescription>
</Field>

Invalid

Use the aria-invalid parameter to mark the input as invalid. To style the invalid state, add the data-invalid attribute to the Field component.

This field contains validation errors.

<Field data-invalid="true">
    <FieldLabel for="input-invalid">Invalid Input</FieldLabel>
    <Input id="input-invalid" placeholder="Error" aria-invalid="true" />
    <FieldDescription>This field contains validation errors.</FieldDescription>
</Field>

File

Use the type="file" parameter to create a file input.

Select a picture to upload.

<Field>
    <FieldLabel for="picture">Picture</FieldLabel>
    <Input id="picture" Type="file" />
    <FieldDescription>Select a picture to upload.</FieldDescription>
</Field>

Inline

Use Field with orientation="horizontal" to create an inline input. Pair with Button to create a search input with a button.

<Field Orientation="FieldOrientation.Horizontal">
    <Input Type="search" placeholder="Search..." />
    <Button>Search</Button>
</Field>

Grid

Use a grid layout to place multiple inputs side by side.

<FieldGroup Class="grid max-w-sm grid-cols-2">
    <Field>
        <FieldLabel for="first-name">First Name</FieldLabel>

Required

Use the required attribute to indicate required inputs.

This field must be filled out.

<Field>
    <FieldLabel for="input-required">
        Required Field
        <span class="text-destructive">*</span>
    </FieldLabel>
    <Input id="input-required" placeholder="This field is required" required />
    <FieldDescription>This field must be filled out.</FieldDescription>
</Field>

Badge

Use Badge in the label to highlight a recommended field.

<Field>
    <FieldLabel for="input-badge">
        Webhook URL
        @(" ")
        <Badge Variant="BadgeVariant.Secondary" Class="ml-auto">Beta</Badge>
    </FieldLabel>
    <Input id="input-badge" Type="url" placeholder="https://api.example.com/webhook" />
</Field>

Input Group

To add icons, text, or buttons inside an input, use the InputGroup component. See the Input Group component for more examples.

https://
<Field>
    <FieldLabel for="input-group-url">Website URL</FieldLabel>
    <InputGroup>
        <InputGroupInput id="input-group-url" placeholder="example.com" />
        <InputGroupAddon><InputGroupText>https://</InputGroupText></InputGroupAddon>
        <InputGroupAddon Align="InputGroupAddonAlign.InlineEnd"><Icon Data="LucideIcons.Info" /></InputGroupAddon>
    </InputGroup>
</Field>

Button Group

To add buttons to an input, use the ButtonGroup component. See the Button Group component for more examples.

<Field>
    <FieldLabel for="input-button-group">Search</FieldLabel>
    <ButtonGroup>
        <Input id="input-button-group" placeholder="Type to search..." />
        <Button Variant="ButtonVariant.Outline">Search</Button>
    </ButtonGroup>
</Field>

Form

A full form example with multiple inputs, a select, and a button.

We'll never share your email with anyone.

<form class="w-full max-w-sm">
    <FieldGroup>
        <Field>

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

مفتاح API الخاص بك مشفر ومخزن بأمان.

<Field>
    <FieldLabel for="input-rtl-api-key">@T.ApiKey</FieldLabel>
    <Input id="input-rtl-api-key" Type="password" placeholder="sk-..." />