Field #2986
seanmalbert
started this conversation in
Components
Field
#2986
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Field component
Related Issues:
#3128
Prop Documentation
Just from this first pass, two things are clear:
error?: boolean- Adds css class 'error' (red outline to field) , sets aria-invalid to true, and renders error message if providederrorMessage?: string- Text rendered in red below field when error occursclassName?: string- css classes passed to component parent div, in addition to 'field' css classcontrolClassName?: string- css classes passed to direct parent div of input component, in addition to 'control' css classcaps?: boolean- capitalizes field label by adding 'field-label--caps' css class to labelClasses arrayprimary?: boolean- sets label color to primary color by adding tailwind's 'text-primary' class to labelClasses arrayreaderOnly?: boolean- makes field only visible to screen-readers by adding tailwind's 'sr-only' class to labelClasses arraytype?: stringid?: string- used for htmlFor field on label and id for input elementname: string- used for htmlFor field on label and id for input component if props.is not defined. If it is, it is only used for the name field for input elementnote?: string | JSX.Element- grayed-out helper text, rendered above label if radio or checkbox and below, if notsubNote?: string- grayed-out helper text, rendered below field itself for all typeslabel?: string- text which all labelClasses are applied to, conditionally rendered by input based on type (see above)defaultValue?: string | number- starting value in field input, passed directly to input elementonDrop?: (e: React.DragEvent<HTMLElement>) => boolean- custom function to handle when field is dropped, passed directly to input elementonPaste?: (e: React.ClipboardEvent) => boolean- custom function to handle when field is pasted into, passed directly to input elementonChange?: (e: React.ChangeEvent<HTMLInputElement>) => void- custom function to handle when field input is changed, passed directly to input elementplaceholder?: string-text grayed out in background of input to guide users, doesn't register as field valueregister?: UseFormMethods["register"]-react hook form method, allows for validationvalidation?: RegisterOptions-used with 'register' to set validation rules on specific fieldsdisabled?: boolean- doesn't allow any input, passed directly to input elementprepend?: string- displayed at beginning of input fieldNOTE only seems to work with text input, and with $ or 2 character or less strings.
Area for improvement
inputProps?: Record<string, unknown>- custom props added directly to the input elementdescribedBy?: string- sets aria-describedby field on input elementgetValues?: UseFormMethods["getValues"]- react hook form helper, used to format currency values and not used for other typesArea for improvement
setValue?: UseFormMethods["setValue"]- react hook form helper, used to format currency values and not used for other typesArea for improvement
dataTestId?: string- used for identifying field component in testing, passed directly to input elementhidden?: boolean- hides input itself but leaves other element such as labeling, passed directly to input elementBeta Was this translation helpful? Give feedback.
All reactions