MYDS Logo

    MYDS

    Beta

    Input

    The input component is a text input field that allows users to input text.

    Usage

    import { Input } from "@govtechmy/myds-react/input";
    <Input />

    Examples

    Size

    Use the size prop to change the size of the input. The default size is small.

    Disabled

    Disable the input by setting the disabled prop to true.

    Uncontrolled vs Controlled State

    To use the input in an uncontrolled state, set the defaultValue prop to the initial state of the input.

    To use the input in the controlled state, utilize the value and onChange prop to handle the state programmatically.

    Input Icon

    You can add an icon to the input field by using the InputIcon component. The icon can be positioned on the left or right side of the input field. Both left and right icons can be used together.

    Input Addons

    You can add an addon to the input field by using the InputAddon component. The addon can be appended or prepended to the input field. This is useful for attaching submit buttons, currency symbols or any other control to the input field.

    RM

    Props

    Input

    PropTypeDefault
    size
    enum
    small
    placeholder
    string
    -
    defaultValue
    string
    -
    value
    string
    -
    onChange
    function
    -
    disabled
    boolean
    false

    InputIcon

    PropTypeDefault
    position
    left | right
    -
    children
    ReactNode
    -

    InputAddon

    PropTypeDefault
    children
    ReactNode
    -

    On this page