Bỏ qua để đến nội dung

Props

Mọi prop đều không bắt buộc. Mới là prop có từ 1.0. Các callback before*, on*, after* có thể trả về promise, callback sau sẽ chờ.

Prop Kiểu Mặc định
defaultValue string '' Chữ lúc mới hiện.
value string Mới. Chữ trong ô. Ô đổi theo mỗi khi prop đổi, và báo việc xoá chữ qua onChangeText.
placeholder string 'Search' Hiện khi ô trống.
cancelTitle ReactNode 'Cancel' Chữ trên nút Cancel.
autoFocus boolean false Focus lúc mount, và mỗi khi prop chuyển sang true.
editable boolean true Có cho sửa chữ không.
blurOnSubmit boolean true Bỏ focus khi bấm phím return.
returnKeyType string 'search' Như TextInput.
keyboardType string 'default' Như TextInput.
keyboardAppearance 'default' | 'light' | 'dark' 'default' Màu bàn phím iOS.
autoCapitalize string Như TextInput.
selectionColor string Màu con trỏ và vùng chọn.
textInputProps TextInputProps Mới. Mọi prop khác của TextInput, ví dụ maxLength.
Prop Kiểu Mặc định
showCancelButton boolean true Mới. Hiện nút Cancel khi ô mở.
useClearButton boolean true Hiện nút xoá (×).
keyboardShouldPersist boolean false Giữ bàn phím khi tìm và khi bấm Cancel.
collapseOnBlur boolean false Mới. Thu lại khi mất focus, chữ vẫn giữ.
searchDelay number Mới. Tự tìm sau khi ngừng gõ bấy nhiêu ms.
animated boolean true Mới. false để tắt animation.
animationDuration number 200 Mới. Mili giây.
placeholderAlign 'center' | 'left' 'center' Mới. Vị trí nghỉ của icon và placeholder.
direction 'ltr' | 'rtl' 'ltr' Lật bố cục.
Prop Kiểu Mặc định
beforeFocus () => any Trước khi ô mở.
onFocus (text) => any Ô nhận focus.
afterFocus () => any Sau onFocus.
beforeBlur () => any Mới. Trước onBlur.
onBlur (text) => any Mới. Ô mất focus.
afterBlur () => any Mới. Sau onBlur.
beforeSearch (text) => any Trước khi đóng bàn phím.
onSearch (text) => any Phím return, search() hoặc searchDelay.
afterSearch (text) => any Sau onSearch.
onChangeText (text) => any Người dùng gõ. Khi có value, gọi cả lúc chữ bị xoá.
beforeDelete () => any Trước khi nút xoá làm trống ô.
onDelete () => any Đã bấm nút xoá.
afterDelete () => any Sau onDelete.
beforeCancel () => any Trước khi Cancel xoá chữ và thu ô.
onCancel () => any Đã bấm Cancel. Mất focus không gọi hàm này.
afterCancel () => any Sau onCancel.
onEndEditing (text) => any Mới. Kết thúc sửa chữ.
onLayout (event) => void Ô vừa được layout.
Prop Kiểu Mặc định
backgroundColor string 'grey' Nền của ô.
containerStyle ViewStyle Mới. Khung ngoài: margin, flex, border. Padding giữ là 5.
inputStyle TextStyle Ô nhập.
inputHeight number 30 Nếu không có thì lấy inputStyle.height.
inputBorderRadius number 5 Bo góc ô nhập.
placeholderTextColor string 'grey' Cũng là màu chữ, trừ khi có inputStyle.color.
titleCancelColor string '#fff' Màu chữ Cancel.
tintColorSearch string 'grey' Màu icon tìm mặc định.
tintColorDelete string 'grey' Màu icon xoá mặc định.
iconSearch ReactElement Thay icon tìm.
iconDelete ReactElement Thay icon xoá.
cancelButtonWidth number measured Chỗ cho nút Cancel. Đo theo chữ, tối thiểu 70.
cancelButtonStyle TextStyle Cả khung và chữ Cancel. Nên dùng hai prop dưới.
cancelButtonViewStyle ViewStyle Khung nút Cancel.
cancelButtonTextStyle TextStyle Chữ nút Cancel.
contentWidth number window Bề rộng tạm tính trước lần layout đầu.
middleWidth number half Tâm tạm tính trước lần layout đầu.
Prop Kiểu Mặc định
searchIconCollapsedMargin number 25 Icon cách tâm, khi thu.
searchIconExpandedMargin number 10 Icon cách mép, khi mở.
placeholderCollapsedMargin number 15 Placeholder cách tâm, khi thu. Đặt bằng nửa bề rộng để vào giữa.
placeholderExpandedMargin number 20 Chữ cách mép, khi mở.
positionRightDelete number Nút xoá cách mép cuối.
Prop Kiểu Mặc định
shadowVisible boolean false iOS và web.
shadowColor string '#000'
shadowRadius number 4
shadowOffsetWidth number 0
shadowOffsetHeightCollapsed number 2
shadowOffsetHeightExpanded number 4
shadowOpacityCollapsed number 0.12
shadowOpacityExpanded number 0.24
Prop Kiểu Mặc định
maxFontSizeMultiplierForInput number Mới. Giới hạn cỡ chữ hệ thống cho ô nhập.
maxFontSizeMultiplierForCancel number Mới. Tương tự cho nút Cancel.
clearButtonAccessibilityLabel string 'Clear' Mới. Trình đọc màn hình đọc chữ này.
testID string Mới. Khung ngoài.
inputTestID string Mới. Ô nhập.
searchIconTestID string Mới. Icon tìm.
clearButtonTestID string Mới. Nút xoá.
cancelButtonTestID string Mới. Nút Cancel.