Input
The input component is a versatile input field that supports various configurations and states. It can be used for standard text inputs, search fields, password inputs, and more.
Import
To use the input component, first import it into your project:
Usage
Here’s how you can use the input component in your Astro project:
Basic Usage
To create a basic input field, use the following code:
Disabled
To disable the input field, set the disabled
prop to true
.
Readonly
To make the input field readonly, set the readonly
prop
to true
.
Search
To style the input field as a search input, set the type
prop to search
.
Password
To use the input field for passwords, set the type
prop
to password
.
With Icon
You can include an icon in the input field using the icon
attribute. The icon will be displayed on the right side of the input
field. The icon can be selected from a list of available icons .
Helper Text
You can provide additional information using the helperText
prop.
Status
To indicate a specific state of the input field, use the status
attribute. Possible values are default
, success
, and error
. You can use helperText
to provide
additional context.
Props
Attribute | Type | Description | Default |
---|---|---|---|
type | string | The type of the input (text, search, password, etc.). | text |
label | string | The text label associated with the input field. | - |
placeholder | string | The placeholder text for the input field. | - |
disabled | boolean | Disables the input field. | false |
readonly | boolean | Makes the input field read-only. | false |
icon | string | The icon to display in the input field, on the right side. The icon can be selected from a list of available icons. | - |
helperText | string | Additional text to assist the user. | - |
status | default | success | error | The status of the input field. | default |
class | string | CSS class for custom styling. | - |
other | any | Any other props will be passed to the input element. | - |
Accessibility
-
Keyboard Accessibility: Ensure that the input field can be focused and used with the keyboard.
-
ARIA Attributes: Use appropriate ARIA attributes to describe the state of the input, such as
aria-invalid
for error states. -
Labeling: Provide clear labels for each input field to assist screen reader users.