# Input A native text field with optional content at the start and end. Supports standard input attributes, events, form submission, controlled values, and refs. ```jsx featured Email ``` [View Source](https://github.com/LocusInc/locus-ui/tree/main/packages/locus-ui/src/components/input) ## Anatomy ```jsx code no-header } endSlot={}> ``` ## Examples ### Labels Use an `Input.Label` child with `position="top"`, `"left"`, `"right"`, `"bottom"`, or `"inside"`, following the same pattern as Select and Checkbox. The default is `top`. Place the label directly inside `Input.Root`; it is automatically associated with the native input, including when you supply your own `id`. ```jsx Email Name Username City Search ``` ### Slots Use `startSlot` and `endSlot` for icons, text, or other components. Components inside slots retain their own spacing. Interactive slot content stays keyboard accessible. Give icon buttons an accessible name, use `type="button"` for actions that should not submit a form, and hide decorative icons with `aria-hidden="true"`. ```jsx } endSlot={ URL } /> } /> ``` #### Slot Variants Wrap either slot's content in `Input.Slot` to give it an independent `outlined`, `solid`, `muted`, or `clear` treatment. Slots inherit the `Input.Root` variant by default; set a slot’s `variant` to override it, including `variant="clear"` for an unstyled slot. Slots keep zero margin and padding by default; use spacing props such as `px="2"` when you want padding. Outlined slots draw only an inner divider in the field’s border color, and solid slots use the base solid background. Muted slots inherit the field’s accent color unless you set their own `color`. The field clips slot content to its outer rounded corners. ```jsx {["outlined", "solid", "muted", "clear"].map((variant) => ( https:// } endSlot={ URL } /> ))} ``` #### Inheriting the Field Variant The start slot below inherits the field’s variant. The end slot explicitly uses `clear`. ```jsx {["outlined", "solid", "muted", "clear"].map((variant) => ( https://} endSlot={ URL } /> ))} ``` #### Custom Slot Styles `Input.Slot` accepts `className`, `style`, standard div attributes, a forwarded ref, and the shared color, margin, and padding props. The `.input-slot-content` class styles the slot content; `.input-slot[data-side="start"]` and `.input-slot[data-side="end"]` identify the layout wrappers. ```jsx $ } endSlot={ USD } /> ``` ### Variants The default variant is `outlined`. Color, size, radius, margin, and padding use the same props as other components. ```jsx {["outlined", "solid", "muted", "clear"].map((variant) => ( ))} ``` ### Sizes Use `size="xs"`, `"sm"`, `"md"`, `"lg"`, or `"xl"` for the visual size. Use `htmlSize` to set the native input width in characters. ```jsx {["xs", "sm", "md", "lg", "xl"].map((size) => ( ))} ``` ### States Use native `disabled` and `readOnly` props. Set `aria-invalid` and associate error text with `aria-describedby` for invalid values. Set `disabled` on any slot buttons separately when they should be disabled too. ```jsx Enter a valid email address. ``` ### Controlled Values and Refs Use `value` with `onChange` for controlled inputs or `defaultValue` for uncontrolled inputs. The forwarded ref points to the native input. ```jsx ```