Input

The Input component is a basic form input component that supports multiple states and custom styles.

Three-Layer Configuration

The Input component supports a three-layer CSS variable configuration architecture:

Basic Usage

Disabled State

The input can be disabled, making it non-editable when disabled.

Custom Colors

Input colors can be dynamically overridden through Custom layer properties.

rust
1
2
3
4
5
6
Input {
    placeholder: "Custom styled input",
    text_color: Some("#ff0000".to_string()),        // Custom text color
    border_color: Some("#ff4f00".to_string()),       // Custom border color
    background_color: Some("rgba(255, 255, 255, 0.1)".to_string()), // Custom background color
}

CSS Variables Override

CSS variables can be overridden in batches through the css_vars property.

rust
1
2
3
4
5
6
7
8
Input {
    placeholder: "CSS Variables Override",
    css_vars: Some(vec![
        ("--hi-input-radius", "16px".to_string()),
        ("--hi-input-border-color-focus", "#22c55e".to_string()),
        ("--hi-input-shadow-focus", "0 0 0 2px rgba(34, 197, 94, 0.3)".to_string()),
    ]),
}

Animation Integration

Animation effects can be integrated with AnimationBuilder through the animation_id property.

rust
1
2
3
4
5
6
7
8
9
10
11
Input {
    placeholder: "Animated Input",
    animation_id: Some("animated-input".to_string()),
}

// Control animation with AnimationBuilder
AnimationBuilder::new()
    .style("--hi-input-border-color", "rgb(255, 79, 0)")
    .style("--hi-input-shadow-focus", "0 0 0 2px rgba(255, 79, 0, 0.3)")
    .duration(300)
    .apply_to_element("animated-input");

API

Input Props

PropertyDescriptionTypeDefault
sizeInput sizeInputSizeMedium
disabledWhether disabledboolfalse
readonlyWhether readonlyboolfalse
placeholderPlaceholder textOption<String>None
valueInput valueOption<String>None
input_typeInput typeOption<String>"text"
autofocusWhether to auto focusboolfalse
classCustom CSS classString""
prefix_iconPrefix iconOption<Element>None
suffix_iconSuffix iconOption<Element>None
oninputInput callbackOption<EventHandler<String>>None
onfocusFocus callbackOption<EventHandler<FocusEvent>>None
onblurBlur callbackOption<EventHandler<FocusEvent>>None
onkeydownKey press callbackOption<EventHandler<KeyboardEvent>>None
glowWhether to enable glow effectbooltrue
glow_blurGlow blur intensityGlowBlurMedium
glow_intensityGlow intensityGlowIntensitySoft
glow_colorGlow colorGlowColorGhost
Custom Layer Properties
text_colorCustom text colorOption<String>None
placeholder_colorCustom placeholder colorOption<String>None
border_colorCustom border colorOption<String>None
background_colorCustom background colorOption<String>None
animation_idAnimationBuilder animation IDOption<String>None
css_varsCSS variables batch overrideOption<Vec<(&'static str, String)>>None

CSS Variables Reference

Input CSS Variables

VariableDescriptionDefault
--hi-input-text-colorText colorvar(--hi-color-text-primary)
--hi-input-text-color-disabledDisabled text colorvar(--hi-color-text-disabled)
--hi-input-placeholder-colorPlaceholder colorvar(--hi-color-text-secondary)
--hi-input-placeholder-opacityPlaceholder opacity0.6
--hi-input-bgBackground colortransparent
--hi-input-bg-disabledDisabled backgroundrgba(255, 255, 255, 0.5)
--hi-input-border-colorBorder colorvar(--hi-color-border)
--hi-input-border-color-focusFocus border colorvar(--hi-color-primary)
--hi-input-border-color-disabledDisabled border colorvar(--hi-border-color-disabled)
--hi-input-border-color-errorError border colorvar(--hi-color-danger)
--hi-input-shadow-focusFocus shadow0 0 0 2px var(--hi-color-primary)
--hi-input-radiusBorder radiusvar(--hi-radius-md)
--hi-input-padding-xHorizontal padding0.75rem
--hi-input-padding-yVertical padding0.5rem
--hi-input-font-sizeFont sizevar(--hi-font-size-sm)

Related Documentation