Area where user can enter small amount of text. Commonly used in forms.
Note: This kit does not handle form validation logic.
Add an id to your Text Input so that clicking the label will move focus directly to the input.
<%= pb_rails("text_input", props: { label: "First Name", placeholder: "Enter first name", value: "Timothy Wenhold", data: { say: "hi", yell: "go" }, aria: { something: "hello"}, id: "unique_id" }) %> <%= pb_rails("text_input", props: { label: "Last Name", placeholder: "Enter last name", id: "last-name" }) %> <%= pb_rails("text_input", props: { label: "Phone Number", type: "phone", placeholder: "Enter phone number", id: "phone" }) %> <%= pb_rails("text_input", props: { label: "Email Address", type: "email", placeholder: "Enter email address", id: "email" }) %> <%= pb_rails("text_input", props: { label: "Zip Code", type: "number", placeholder: "Enter zip code", id: "zip" }) %>
Text Input w/ Error shows that the input must be filled out (i.e. when used in a form it signals a user to fix an error).
<%= pb_rails("text_input", props: { add_on: { alignment: "left", border: true, icon: "user" }, error: raw(pb_rails("icon", props: { icon: "warning" }) + " Please enter a valid email address"), label: "Email Address", placeholder: "Enter email address", type: "email" }) %> <%= pb_rails("text_input", props: { add_on: { alignment: "left", border: true, icon: "user" }, label: "Confirm Email Address", placeholder: "Confirm email address", type: "email" }) %>
<%= pb_rails("text_input", props: { label: "Add On With Defaults", add_on: { icon: "bat" } }) %> <%= pb_rails("text_input", props: { label: "Right-Aligned Add On With Border", add_on: { icon: "user", alignment: 'right', border: true } }) %> <%= pb_rails("text_input", props: { label: "Right-Aligned Add On With No Border", add_on: { icon: "percent", alignment: 'right', border: false } }) %> <%= pb_rails("text_input", props: { label: "Left-Aligned Add On With No Border", add_on: { icon: "percent", alignment: 'left', border: false } }) %> <%= pb_rails("text_input", props: { label: "Left-Aligned Add On With Border", add_on: { icon: "user", alignment: 'left', border: true } }) %>
The mask prop lets you style your inputs while maintaining the value that the user typed in.
It uses a hidden input field to submit the unformatted value as it will have the proper name attribute. It will also copy the id field with a "#{your-id-sanitized}"
<%= pb_rails("text_input", props: { label: "Currency", mask: "currency", margin_bottom: "md", name: "currency_name", placeholder:"$0.00" }) %> <%= pb_rails("text_input", props: { label: "ZIP Code", mask: "zip_code", margin_bottom: "md", placeholder: "12345" }) %> <%= pb_rails("text_input", props: { label: "Postal Code", mask: "postal_code", placeholder: "12345-6789", margin_bottom: "md", }) %> <%= pb_rails("text_input", props: { label: "SSN", mask: "ssn", margin_bottom: "md", placeholder: "123-45-6789" }) %> <%= pb_rails("text_input", props: { label: "Credit Card", mask: "credit_card", margin_bottom: "md", placeholder: "1234 5678 9012 3456" }) %> <%= pb_rails("text_input", props: { label: "CVV", mask: "cvv", margin_bottom: "md", placeholder: "123" }) %> <%= pb_rails("title" , props: { text: "Hidden Input Under The Hood", padding_bottom: "sm" })%> <%= pb_rails("text_input", props: { label: "Currency", mask: "currency", margin_bottom: "md", name: "currency_name", id: "example-currency", value: "$99.99", }) %> <style> #example-currency-sanitized {display: flex !important;} </style>
Set this prop to false or "off" to remove autocomplete from text inputs. You can also set it to a string, but browsers will often defer to other attributes like name.
<%= pb_rails("text_input", props: { autocomplete: false, label: "autocomplete='off'", name: "firstName", placeholder: "Enter first name", }) %> <%= pb_rails("text_input", props: { label: "no autocomplete attribute (let browser decide- basically 'on')", name: "lastName", placeholder: "Enter last name" }) %> <%= pb_rails("text_input", props: { autocomplete: true, label: "autocomplete='on'", name: "phone", type: "phone", placeholder: "Enter phone number" }) %> <%= pb_rails("body", props: { margin_bottom: "sm" }) do %> The following have the same autocomplete attributes (email), but have different name attributes (email and emailAlt). Many browsers will open autocomplete based on name attributes instead of autocomplete: <% end %> <%= pb_rails("text_input", props: { autocomplete: "email", label: "autocomplete='email' name='email'", name: "email", placeholder: "Enter email address" }) %> <%= pb_rails("text_input", props: { autocomplete: "email", label: "autocomplete='email' name='emailAlt'", name: "emailAlt", type: "email", placeholder: "Enter email address" }) %>
The requiredIndicator/required_indicator prop displays a red asterisk (*) next to the label, visually indicating that the field is required. This is purely visual and does not enforce validation.
You can use requiredIndicator/required_indicator with any validation approach: HTML5 validation via the required prop, client-side validation, or backend validation. For this reason, it works independently and doesn't need to be paired with the required prop.
Use the emojiMask / emoji_mask prop to prevent users from entering emoji characters (🐸 🐈 🏄♂️) in typed or pasted content. It allows accented characters and other non-ASCII letters (é, ü, 文).
Do not use for large amounts of text (use Textarea instead). Avoid using a text input without validation if input is required and using with validation if not required.
| Props | Type | Values |
|---|---|---|
align_content |
enum | responsive
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
align_items |
enum | responsive
|
start
end
center
|
border_radius |
enum
|
none
xs
sm
md
lg
xl
rounded
|
cursor |
enum
|
auto
default
none
contextMenu
help
pointer
progress
wait
cell
|
dark |
boolean
|
true
false
|
flex |
enum | responsive
|
auto
initial
0
1
2
3
4
5
6
7
8
9
10
11
12
none
|
flex_direction |
enum | responsive
|
row
column
rowReverse
columnReverse
|
flex_wrap |
enum | responsive
|
wrap
nowrap
wrapReverse
|
justify_content |
enum | responsive
|
start
end
center
spaceBetween
spaceAround
spaceEvenly
|
line_height |
enum
|
loosest
looser
loose
normal
tight
tighter
tightest
|
margin_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_bottom |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_x |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin_y |
array
|
none
xxs
xs
sm
md
lg
xl
|
margin |
array
|
none
xxs
xs
sm
md
lg
xl
|
width |
string
|
|
min_width |
string
|
|
max_width |
string
|
|
gap |
string | responsive
|
|
column_gap |
string | responsive
|
|
row_gap |
string | responsive
|
|
number_spacing |
enum
|
tabular
|
order |
enum | responsive
|
none
first
1
2
3
4
5
6
7
8
9
10
11
12
|
overflow_x |
enum
|
scroll
visible
hidden
auto
|
overflow_y |
enum
|
scroll
visible
hidden
auto
|
overflow |
enum
|
scroll
visible
hidden
auto
|
padding_right |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_left |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_top |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_bottom |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_x |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding_y |
array
|
none
xxs
xs
sm
md
lg
xl
|
padding |
array
|
none
xxs
xs
sm
md
lg
xl
|
position |
enum
|
relative
absolute
fixed
sticky
static
|
shadow |
enum
|
none
deep
deeper
deepest
|
text_align |
enum | responsive
|
start
end
left
right
center
justify
justifyAll
matchParent
|
truncate |
enum
|
none
1
2
3
4
5
|
vertical_align |
enum | responsive
|
baseline
super
top
middle
bottom
sub
text-top
text-bottom
|
z_index |
enum | responsive
|
1
2
3
4
5
6
7
8
9
10
max
|
top |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
inset |
boolean
|
true
false
|
right |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
bottom |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
left |
enum | object
|
xxs
xs
sm
md
lg
xl
xxl
|
height |
string
|
|
max_height |
string
|
|
min_height |
string
|
|
hover |
object
|
|
group_hover |
boolean
|
true
false
|
| Props | Type | Values | Default |
|---|---|---|---|
disabled |
boolean
|
true
false
|
false
|
emoji_mask |
boolean
|
true
false
|
false
|
error |
string
|
||
inline |
boolean
|
true
false
|
false
|
name |
string
|
||
label |
string
|
||
mask |
enum
|
currency
zipCode
postalCode
ssn
|
|
on_change |
reactnode
|
||
placeholder |
string
|
||
required |
boolean
|
true
false
|
false
|
required_indicator |
boolean
|
true
false
|
false
|
type |
string
|
text
|
|
value |
string | number
|
||
auto_complete |
boolean | string
|
||
autocomplete |
string
|
true
|
|
input_options |
string
|
||
validation |
string
|
||
add_on |
string
|