Back to Fluentui

SearchBox Migration

packages/react-components/react-search/library/docs/MIGRATION.md

4.40.2-hotfix211.2 KB
Original Source

SearchBox Migration

Migrations from v0

Prop/conceptv0Proposal
imperative APIn/an/a
supported native propsSupportedIntrinsicInputProps (see below)React.InputHTMLAttributes
setting native props on root?root slot
root element access?ref on root slot
primary element accessreftop-level ref
underlinedappearance
fluid (full width)fluid?: booleandefault behavior
inlineinline?: booleancustom styles
labellabel?: ShorthandValue<InputLabelProps>,handled by Field
label positionlabelPosition?: 'above' | 'inline' | 'inside'handled by Field
descriptionuse FormFieldhandled by Field
error messageuse FormFieldhandled by Field
icon at start of fieldicon?: ShorthandValue<BoxProps> + iconPosition: 'start'contentBefore slot
icon at end of fieldicon?: ShorthandValue<BoxProps> + iconPosition: 'end'contentAfter and dismiss slots
valuevalue?: string | numbervalue?: string
defaultValuedefaultValue?: string | string[]defaultValue?: string
onChange(ev?: React.ChangeEvent<HTMLInputElement>, data: { ...props, value }) => void(ev: ChangeEvent<HTMLInputElement>, data: { value: string }) => void
onClear(ev?: any) => void(ev?: any) => void on dismiss slot
onSearch(newValue: any) => voidnot supported
container classNametop-level className
input classNameinput.className?: className on the Input's input slot
aria-label'aria-label'?: string'aria-label'?: string
clearableclearable?: booleandismiss slot
style overridesstyles?: ComponentSlotStyles<...>className, slot classNames
ts
// packages/fluentui/react-northstar/src/utils/htmlPropsUtils.tsx
type SupportedIntrinsicInputProps = {
  [K in HtmlInputProps]?: K extends keyof JSX.IntrinsicElements['input'] ? JSX.IntrinsicElements['input'][K] : any;
};
// HtmlInputProps: a subset of React and HTML native props

// packages/fluentui/react-northstar/src/components/Box/Box.tsx
interface BoxProps extends UIComponentProps<BoxProps>, ContentComponentProps, ChildrenComponentProps {
  /** Accessibility behavior if overridden by the user. */
  accessibility?: Accessibility<never>;
}

Migrations from v8

Prop/conceptv8v9
imperative APIcomponentRefn/a
supported native propsReact.AllHTMLAttributes (input or textarea)React.InputHTMLAttributes
setting native props on rootroot slot
root element accesselementRefref on root slot
primary element accessnot possibletop-level ref
underlinedunderlined?: booleanappearance
borderlessborderless?: booleanappearance or custom styles
fluid (full width)default behaviordefault behavior
labellabel?: string, onRenderLabelhandled by Field
label positionn/a (use styling)handled by Field
descriptiondescription?: string, onRenderDescriptionhandled by Field
error messagesee Spec-variants.mdhandled by Field
content outside before fieldprefix?: string, onRenderPrefix
content outside after fieldsuffix?: string, onRenderSuffix
icon at start of fieldn/acontentBefore slot
icon at end of fieldiconProps?: IIconPropscontentAfter slot
valuevalue?: stringvalue?: string
defaultValuedefaultValue?: stringdefaultValue?: string
onChange(ev?: React.ChangeEvent<HTMLInputElement>, value) => void(ev: ChangeEvent<HTMLInputElement>, data: { value: string }) => void
onClear(ev?: any) => void(ev?: any) => void on dismiss slot
onSearch(newValue: any) => voidnot supported
onEscape(ev?: any) => voidnot supported
disableAnimationdisableAnimation?: booleandefault behavior
container classNameclassName?: stringtop-level className
input classNameinputClassName?: stringclassName on the Input's input slot
aria-labelariaLabel?: string'aria-label'?: string
showIconshowIcon?: booleandefault behavior
iconPropsiconProps?: Pick<IIconProps, Exclude<keyof IIconProps, 'className'>>contentBefore, dismiss, and contentAfter props
clearButtonPropsclearButtonProps?: IButtonPropsdismiss props
style overridesstyles?: IStyleFunctionOrObject<...>className, slot classNames

Native Props

Native props following standard behavior in both libraries + v9:

  • disabled?: boolean
  • readOnly?: boolean
  • autoComplete?: string
  • and most other native props not specified