The id for the File Upload and the existing input you are choosing to wrap with our Kit with must match each other. This will ensure that the click on the button a.k.a, the underlying label's for, triggers the File Upload.
<%= pb_rails("title", props: { size: 4, text: "Which of the following vehicles do you own?" }) %> <br> <%= pb_rails("caption", props: { text: "Car" }) %> <%= pb_rails("toggle", props: { size: "sm", checked: false, name: "vehicle", value: "car" }) %> <br> <%= pb_rails("caption", props: { text: "Bike" }) %> <%= pb_rails("toggle", props: { size: "sm", checked: false, name: "vehicle", value: "bike" }) %>
<%= pb_rails("title", props: { size: 4, text: "Select one option:" }) %> <br> <%= pb_rails("caption", props: { text: "Walk" }) %> <%= pb_rails("toggle", props: { size: "sm" }) do %> <input type="radio" name="modes of transportation" value="walk"> <% end %> <br/> <%= pb_rails("caption", props: { text: "Bike" }) %> <%= pb_rails("toggle", props: { size: "sm" }) do %> <input type="radio" name="modes of transportation" value="bike"> <% end %> <br/> <%= pb_rails("caption", props: { text: "Ride" }) %> <%= pb_rails("toggle", props: { size: "sm" }) do %> <input type="radio" name="modes of transportation" value="ride"> <% end %>
For Form Pills with longer text, the truncate global prop can be used to truncate the label within each Form Pill. See here for more information on the truncate global prop.
NOTE: For Rails Form Pills (not ones embedded within a React-rendered Typeahead or MultiLevelSelect), a unique id is required to enable the Tooltip functionality displaying the text or tag section of the Form Pill.
<% names = [ { label: 'Alexander Nathaniel Montgomery', value: 'Alexander Nathaniel Montgomery' }, { label: 'Isabella Anastasia Wellington', value: 'Isabella Anastasia Wellington' }, { label: 'Christopher Maximilian Harrington', value: 'Christopher Maximilian Harrington' }, { label: 'Elizabeth Seraphina Kensington', value: 'Elizabeth Seraphina Kensington' }, { label: 'Theodore Jonathan Abernathy', value: 'Theodore Jonathan Abernathy' }, ] %> <%= pb_rails("typeahead", props: { html_options: { style: { maxWidth: "240px" }}, id: "typeahead-form-pill", is_multi: true, options: names, label: "Truncation Within Typeahead", pills: true, truncate: "1", }) %> <%= pb_rails("caption", props: { text: "Form Pill Truncation" }) %> <%= pb_rails("card", props: { max_width: "xs" }) do %> <%= pb_rails("form_pill", props: { name: "Princess Amelia Mignonette Grimaldi Thermopolis Renaldo", avatar_url: "https://randomuser.me/api/portraits/women/44.jpg", tabindex: 0, truncate: "1", id: "truncation-1" }) %> <%= pb_rails("form_pill", props: { icon: "badge-check", text: "icon and a very long tag to show truncation", tabindex: 0, truncate: "1", id: "truncation-2" }) %> <%= pb_rails("form_pill", props: { text: "form pill long tag no tooltip show truncation", tabindex: 0, truncate: "1", }) %> <% end %>
For Form Pills with longer text, the wrapped prop can be used to wrap the label within each Form Pill.
Note: Avoid using the wrapped and small props together, as their styles conflict and may cause functionality issues.
<% names = [ { label: 'Alexander Nathaniel Montgomery', value: 'Alexander Nathaniel Montgomery' }, { label: 'Isabella Anastasia Wellington', value: 'Isabella Anastasia Wellington' }, { label: 'Christopher Maximilian Harrington', value: 'Christopher Maximilian Harrington' }, { label: 'Elizabeth Seraphina Kensington', value: 'Elizabeth Seraphina Kensington' }, { label: 'Theodore Jonathan Abernathy', value: 'Theodore Jonathan Abernathy' }, ] %> <%= pb_rails("typeahead", props: { html_options: { style: { maxWidth: "240px" }}, id: "typeahead-form-pill", is_multi: true, options: names, label: "Wrapped Within Typeahead", pills: true, wrapped: true, }) %> <%= pb_rails("caption", props: { text: "Form Pill Wrapped Text" }) %> <%= pb_rails("card", props: { max_width: "xs" }) do %> <%= pb_rails("form_pill", props: { name: "Princess Amelia Mignonette Grimaldi Thermopolis Renaldo", avatar_url: "https://randomuser.me/api/portraits/women/44.jpg", tabindex: 0, wrapped: true, }) %> <%= pb_rails("form_pill", props: { icon: "badge-check", text: "icon and a very long tag to show wrapped text", tabindex: 0, wrapped: true, }) %> <%= pb_rails("form_pill", props: { text: "form pill long tag no tooltip show wrapped text", tabindex: 0, wrapped: true, }) %> <% end %>
By default textTransform = "none". If there is a need to enforce lowercase, please pass the textTransform = "lowercase prop.
The Status, Data, and Product colors highlighted above can be passed to the color prop. Primary is the default color. Form pills with a text tag, an avatar, or an icon with text tag can all receive the color prop.
<%= pb_rails("title", props: { text: "Status Colors", tag: "h4", size: 4, margin_bottom: "sm" }) %> <%= pb_rails("form_pill", props: { text: "Primary", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "neutral", text: "Neutral", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "success", text: "Success", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "warning", text: "Warning", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "error", text: "Error", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "info", text: "Info", tabindex: 0, }) %> <%= pb_rails("title", props: { text: "Data Colors", tag: "h4", size: 4, margin_bottom: "sm", margin_top: "md" }) %> <%= pb_rails("form_pill", props: { color: "data_1", text: "Data 1", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "data_2", text: "Data 2", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "data_3", text: "Data 3", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "data_4", text: "Data 4", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "data_5", text: "Data 5", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "data_6", text: "Data 6", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "data_7", text: "Data 7", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "data_8", text: "Data 8", tabindex: 0, }) %> <%= pb_rails("title", props: { text: "Product Colors", tag: "h4", size: 4, margin_bottom: "sm", margin_top: "md" }) %> <%= pb_rails("form_pill", props: { color: "windows", text: "Windows", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "siding", text: "Siding", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "roofing", text: "Roofing", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "doors", text: "Doors", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "gutters", text: "Gutters", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "solar", text: "Solar", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "insulation", text: "Insulation", tabindex: 0, }) %> <%= pb_rails("form_pill", props: { color: "accessories", text: "Accessories", tabindex: 0, }) %>
<% example_collection = [ OpenStruct.new(name: "Alabama", value: 1), OpenStruct.new(name: "Alaska", value: 2), OpenStruct.new(name: "Arizona", value: 3), OpenStruct.new(name: "Arkansas", value: 4), OpenStruct.new(name: "California", value: 5), OpenStruct.new(name: "Colorado", value: 6), OpenStruct.new(name: "Connecticut", value: 7), OpenStruct.new(name: "Delaware", value: 8), OpenStruct.new(name: "Florida", value: 9), OpenStruct.new(name: "Georgia", value: 10), ] %> <% example_dropdown_options = [ { label: 'United States', value: 'United States', id: 'us' }, { label: 'Canada', value: 'Canada', id: 'ca' }, { label: 'Pakistan', value: 'Pakistan', id: 'pk' }, ] %> <% treeData = [{ label: "Power Home Remodeling", value: "Power Home Remodeling", id: "100", expanded: true, children: [ { label: "People", value: "People", id: "101", expanded: true, children: [ { label: "Talent Acquisition", value: "Talent Acquisition", id: "102", }, { label: "Business Affairs", value: "Business Affairs", id: "103", children: [ { label: "Initiatives", value: "Initiatives", id: "104", }, { label: "Learning & Development", value: "Learning & Development", id: "105", }, ], }, { label: "People Experience", value: "People Experience", id: "106", }, ], }, { label: "Contact Center", value: "Contact Center", id: "107", children: [ { label: "Appointment Management", value: "Appointment Management", id: "108", }, { label: "Customer Service", value: "Customer Service", id: "109", }, { label: "Energy", value: "Energy", id: "110", }, ], }, ], }] %> <%= pb_form_with(scope: :example, url: "", method: :get) do |form| %> <%= form.typeahead :example_typeahead, props: { data: { typeahead_example1: true, user: {} }, label: true, placeholder: "Search for a user" } %> <%= form.text_field :example_text_field, props: { label: true } %> <%= form.text_field :example_text_field_2, props: { label: "Text Field Custom Label" } %> <%= form.phone_number_field :example_phone_number_field, props: { label: true, hidden_inputs: true} %> <%= form.intl_telephone :example_intl_telephone, props: { label: true, hidden_inputs: true } %> <%= form.email_field :example_email_field, props: { label: true } %> <%= form.number_field :example_number_field, props: { label: true } %> <%= form.search_field :example_search_field, props: { label: true } %> <%= form.password_field :example_password_field, props: { label: true } %> <%= form.url_field :example_url_field, props: { label: true } %> <%= form.text_area :example_text_area, props: { label: true } %> <%= form.dropdown_field :example_dropdown, props: { label: true, options: example_dropdown_options } %> <%= form.dropdown_field :example_dropdown_multi, props: { label: true, options: example_dropdown_options, multi_select: true } %> <%= form.select :example_select, [ ["Yes", 1], ["No", 2] ], props: { label: true } %> <%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true } %> <%= form.check_box :example_checkbox, data: { field1: "value1", field2: "value2" }, props: { text: "Example Checkbox", label: true }, checked_value: "yes", unchecked_value: "no", id: "checkbox-id", name: "checkbox-name", class: "checkbox-class" %> <%= form.date_picker :example_date_picker_1, props: { label: true } %> <%= form.star_rating_field :example_star_rating, props: { variant: "interactive", label: true } %> <%= form.time_zone_select_field :example_time_zone_select, ActiveSupport::TimeZone.us_zones, { default: "Eastern Time (US & Canada)" }, props: { label: true } %> <%= form.multi_level_select :example_multi_level_select, props: { id: "multi-level-select-form-default", tree_data: treeData, margin_bottom: "sm", label: "Example Multi Level Select field" } %> <%= form.time_picker :example_time_picker, props: { label: true } %> <%= form.actions do |action| %> <%= action.submit %> <%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %> <% end %> <% end %> <!-- form.typeahead user results example template --> <template data-typeahead-example-result-option> <%= pb_rails("user", props: { name: tag(:slot, name: "name"), orientation: "horizontal", align: "left", avatar_url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII=", avatar: true }) %> </template> <!-- form.typeahead JS example implementation --> <%= javascript_tag defer: "defer" do %> document.addEventListener("pb-typeahead-kit-search", function(event) { if (!event.target.dataset || !event.target.dataset.typeaheadExample1) return; fetch(`https://api.github.com/search/users?q=${encodeURIComponent(event.detail.searchingFor)}`) .then(response => response.json()) .then((result) => { const resultOptionTemplate = document.querySelector("[data-typeahead-example-result-option]") event.detail.setResults((result.items || []).map((user) => { const wrapper = resultOptionTemplate.content.cloneNode(true) wrapper.children[0].dataset.user = JSON.stringify(user) wrapper.querySelector('slot[name="name"]').replaceWith(user.login) wrapper.querySelector('img').dataset.src = user.avatar_url return wrapper })) }) }) document.addEventListener("pb-typeahead-kit-result-option-selected", function(event) { if (!event.target.dataset.typeaheadExample1) return; const selectedUserJSON = event.detail.selected.firstElementChild.dataset.user const selectedUserData = JSON.parse(selectedUserJSON) // set the input field's value event.target.querySelector('input[name=example_typeahead]').value = selectedUserData.login // log the selected option's dataset console.log('The selected user data:') console.dir(selectedUserData) // do even more with the data later - TBD event.target.dataset.user = selectedUserJSON }) <% end %>
Validation displays an error with red border and red text below indicating that the user must fill out the field.
<% example_collection = [ OpenStruct.new(name: "Alabama", value: 1), OpenStruct.new(name: "Alaska", value: 2), OpenStruct.new(name: "Arizona", value: 3), OpenStruct.new(name: "Arkansas", value: 4), OpenStruct.new(name: "California", value: 5), OpenStruct.new(name: "Colorado", value: 6), OpenStruct.new(name: "Connecticut", value: 7), OpenStruct.new(name: "Delaware", value: 8), OpenStruct.new(name: "Florida", value: 9), OpenStruct.new(name: "Georgia", value: 10), ] %> <% example_dropdown_options = [ { label: 'United States', value: 'United States', id: 'us' }, { label: 'Canada', value: 'Canada', id: 'ca' }, { label: 'Pakistan', value: 'Pakistan', id: 'pk' }, ] %> <% example_typeahead_options = [ { label: 'Orange', value: '#FFA500' }, { label: 'Red', value: '#FF0000' }, { label: 'Green', value: '#00FF00' }, { label: 'Blue', value: '#0000FF' }, ] %> <% treeData = [{ label: "Power Home Remodeling", value: "Power Home Remodeling", id: "100", expanded: true, children: [ { label: "People", value: "People", id: "101", expanded: true, children: [ { label: "Talent Acquisition", value: "Talent Acquisition", id: "102", }, { label: "Business Affairs", value: "Business Affairs", id: "103", children: [ { label: "Initiatives", value: "Initiatives", id: "104", }, { label: "Learning & Development", value: "Learning & Development", id: "105", }, ], }, { label: "People Experience", value: "People Experience", id: "106", }, ], }, { label: "Contact Center", value: "Contact Center", id: "107", children: [ { label: "Appointment Management", value: "Appointment Management", id: "108", }, { label: "Customer Service", value: "Customer Service", id: "109", }, { label: "Energy", value: "Energy", id: "110", }, ], }, ], }] %> <%= pb_form_with(scope: :example, method: :get, url: "", validate: true) do |form| %> <%= form.typeahead :example_typeahead_validation, props: { data: { typeahead_example2: true, user: {} }, label: true, placeholder: "Search for a user", required: true, validation: { message: "Please select a user." } } %> <%= form.typeahead :example_typeahead_validation_react, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead (React Rendered)", placeholder: "Search for a user", required: true, validation: { message: "Please select a color." } } %> <%= form.typeahead :example_typeahead_validation_react_2, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead 2 (React Rendered)", placeholder: "Search for a user", required: true } %> <%= form.text_field :example_text_field_validation, props: { label: true, required: true } %> <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true, required: true } %> <%= form.email_field :example_email_field_validation, props: { label: true, required: true } %> <%= form.number_field :example_number_field_validation, props: { label: true, required: true } %> <%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %> <%= form.password_field :example_password_field_validation, props: { label: true, required: true } %> <%= form.url_field :example_url_field_validation, props: { label: true, required: true } %> <%= form.text_area :example_text_area_validation, props: { label: true, required: true } %> <%= form.dropdown_field :example_dropdown_validation, props: { label: true, options: example_dropdown_options, required: true } %> <%= form.dropdown_field :example_dropdown_validation_multi, props: { label: true, options: example_dropdown_options, multi_select: true, required: true } %> <%= form.select :example_select_validation, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true, validation_message: "Please, select an option." } %> <%= form.collection_select :example_collection_select_validation, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %> <%= form.check_box :example_checkbox_validation, props: { text: "Example Checkbox Validation", label: true, required: true }, checked_value: "1", unchecked_value: "0" %> <%= form.date_picker :example_date_picker_2, props: { label: true, required: true, validation_message: "Please, select a date.", allow_input: true } %> <%= form.star_rating_field :example_star_rating_validation, props: { variant: "interactive", label: true, required: true } %> <%= form.time_zone_select_field :example_time_zone_select, ActiveSupport::TimeZone.us_zones, { default: "Eastern Time (US & Canada)" }, props: { label: true, blank_selection: "Select a Time Zone...", required: true } %> <%= form.multi_level_select :example_multi_level_select, props: { id: "multi-level-select-form", tree_data: treeData, margin_bottom: "sm", required: true, label: "Example Multi Level Select field" } %> <%= form.time_picker :example_time_picker_validation, props: { label: true, required: true, validation_message: "Please select a time." } %> <%= form.actions do |action| %> <%= action.submit %> <%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %> <% end %> <% end %> <!-- form.typeahead user results example template --> <template data-typeahead-example-result-option> <%= pb_rails("user", props: { name: tag(:slot, name: "name"), orientation: "horizontal", align: "left", avatar_url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII=", avatar: true }) %> </template> <!-- form.typeahead JS example implementation --> <%= javascript_tag defer: "defer" do %> document.addEventListener("pb-typeahead-kit-search", function(event) { if (!event.target.dataset || !event.target.dataset.typeaheadExample2) return fetch(`https://api.github.com/search/users?q=${encodeURIComponent(event.detail.searchingFor)}`) .then(response => response.json()) .then((result) => { const resultOptionTemplate = document.querySelector("[data-typeahead-example-result-option]") event.detail.setResults((result.items || []).map((user) => { const wrapper = resultOptionTemplate.content.cloneNode(true) wrapper.children[0].dataset.user = JSON.stringify(user) wrapper.querySelector('slot[name="name"]').replaceWith(user.login) wrapper.querySelector('img').dataset.src = user.avatar_url return wrapper })) }) }) document.addEventListener("pb-typeahead-kit-result-option-selected", function(event) { if (!event.target.dataset.typeaheadExample2) return const selectedUserJSON = event.detail.selected.firstElementChild.dataset.user const selectedUserData = JSON.parse(selectedUserJSON) // set the input field's value event.target.querySelector('input[name=example_typeahead_validation]').value = selectedUserData.login // log the selected option's dataset console.log('The selected user data:') console.dir(selectedUserData) // do even more with the data later - TBD event.target.dataset.user = selectedUserJSON }) <% end %>
Pressing Submit will trigger a loading state where the button content is replaced by a spinner icon and the submit button will be disabled.
<%= pb_form_with(scope: :example, url: "", method: :get, loading: true) do |form| %> <%= form.text_field :example_text_field_loading, props: { label: true } %> <%= form.actions do |action| %> <%= action.submit %> <%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %> <% end %> <% end %> <script> const loadingForm = document.querySelector(".pb_form_loading") if (loadingForm) { loadingForm.addEventListener("submit", function(event) { event.preventDefault(); const submitButton = event['submitter']; const cancelButton = event['target'].querySelector('button[type="reset"]'); if (submitButton) { let currentClass = submitButton.className; let newClass = currentClass.replace("pb_button_disabled pb_button_loading", "pb_button_enabled"); let cancelClass = cancelButton ? cancelButton.className : ""; let newCancelClass = cancelClass.replace("_disabled", "_enabled"); setTimeout(function() { submitButton.disabled = false; submitButton.className = currentClass; if (cancelButton) { cancelButton.disabled = false; cancelButton.className = cancelClass; } }, 5000); } }); } </script>
The required_indicator prop adds a red asterisk (*) to the input label, visually marking the field as required. This works with both label: true for auto-generated labels and label: "Custom Text" for custom labels.
While it's typically used alongside the required prop for HTML5 validation, you can use required_indicator independently if you're handling validation differently (e.g., client-side or backend validation).
<% tree_data = [ { label: "HQ", value: "hQ", id: "hq", }, { label: "Philadelphia", value: "philadelphia", id: "phl", children: [ { label: "Marketing & Sales PHL", value: "marketingAndSalesPhl", id: "marketingPHL", }, { label: "Installation Office PHL", value: "installationOfficePhl", id: "installationPHL", }, { label: "Warehouse PHL", value: "warehousePhl", id: "warehousePHL", }, ] }, { label: "New Jersey", value: "newJersey", id: "nj", children: [ { label: "New Jersey", value: "newJersey", id: "nj1", children: [ { label: "Marketing & Sales NJ", value: "marketingAndSalesNj", id: "marketingNJ", }, { label: "Installation Office NJ", value: "installationOfficeNj", id: "installationNJ", }, { label: "Warehouse NJ", value: "warehouseNj", id: "warehouseNJ", }, ], }, { label: "Princeton", value: "princeton", id: "princeton", children: [ { label: "Marketing & Sales Princeton", value: "marketingAndSalesPrinceton", id: "marketingPR", }, { label: "Installation Office Princeton", value: "installationOfficePrinceton", id: "installationPR", }, { label: "Warehouse Princeton", value: "warehousePrinceton", id: "warehousePR", }, ] }, ] }, { label: "Maryland", value: "maryland", id: "MD", children: [ { label: "Marketing & Sales MD", value: "marketingAndSalesMd", id: "marketingMD", }, { label: "Installation Office MD", value: "installationOfficeMd", id: "installationMD", }, { label: "Warehouse MD", value: "warehouseMd", id: "warehouseMD", }, ] }, { label: "Connecticut", value: "connecticut", id: "CT", children: [ { label: "Marketing & Sales CT", value: "marketingAndSalesCt", id: "marketingCT", }, { label: "Installation Office CT", value: "installationOfficeCt", id: "installationCT", }, { label: "Warehouse CT", value: "warehouseCt", id: "warehouseCT", }, ] }, ]; %> <% example_dropdown_options = [ { label: 'United States', value: 'United States', id: 'us' }, { label: 'Canada', value: 'Canada', id: 'ca' }, { label: 'Pakistan', value: 'Pakistan', id: 'pk' } ] %> <%= pb_form_with(scope: :example, url: "", method: :get, validate: true) do |form| %> <%= form.typeahead :example_typeahead_field, props: { label: true, required: true, required_indicator: true } %> <%= form.text_field :example_text_field, props: { label: true, required: true, required_indicator: true } %> <%= form.text_field :example_text_field_2, props: { label: "Text Field Custom Label", required: true, required_indicator: true } %> <%= form.phone_number_field :example_phone_number_field, props: { label: true, required: true, required_indicator: true } %> <%= form.email_field :example_email_field, props: { label: true, required: true, required_indicator: true } %> <%= form.number_field :example_number_field, props: { label: true, required: true, required_indicator: true } %> <%= form.search_field :example_search_field, props: { label: true, required: true, required_indicator: true } %> <%= form.password_field :example_password_field, props: { label: true, required: true, required_indicator: true } %> <%= form.url_field :example_url_field, props: { label: true, required: true, required_indicator: true } %> <%= form.text_area :example_text_area, props: { label: true, required: true, required_indicator: true } %> <%= form.text_area :example_text_area_2, props: { label: "Textarea Custom Label", required: true, required_indicator: true } %> <%# form.check_box :example_checkbox, props: { label: true, text: "Checkbox Label", required: true, required_indicator: true } %> <%= form.time_picker :example_time_picker_required_indicator, props: { label: true, required: true, required_indicator: true } %> <%= form.date_picker :example_date_picker_required_indicator, props: { label: true, required: true, required_indicator: true } %> <%= form.date_picker :example_date_picker_required_indicator_custom, props: { label: "Custom Date Picker Label", required: true, required_indicator: true } %> <%= form.select :example_select_required_indicator, [["Yes", 1], ["No", 2]], props: { label: true, required: true, required_indicator: true } %> <%= form.select :example_select_required_indicator_2, [["Yes", 1], ["No", 2]], props: { label: "Example Select Field", required: true, required_indicator: true } %> <%= form.multi_level_select :example_multi_level_select_required_indicator, props: { label: true, margin_y: 'sm', required: true, required_indicator: true, tree_data: tree_data } %> <%= form.multi_level_select :example_multi_level_select_required_indicator_custom, props: { label: "Custom Multi Level Select Label", margin_y: 'sm', required: true, required_indicator: true, tree_data: tree_data } %> <%= form.dropdown_field :example_dropdown, props: { label: true, options: example_dropdown_options, required: true, required_indicator: true } %> <%= form.dropdown_field :example_dropdown_2, props: { label: "Dropdown Custom Label", options: example_dropdown_options, required: true, required_indicator: true } %> <%= form.actions do |action| %> <%= action.submit %> <%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %> <% end %> <% end %>
<div> <%= pb_rails("form_group") do %> <%= pb_rails("text_input", props: { label: "First Name", placeholder: "Enter First Name", id: "first-name" }) %> <%= pb_rails("text_input", props: { label: "Middle Initial", placeholder: "Enter Middle Initial", id: "middle-initial" }) %> <%= pb_rails("text_input", props: { label: "Last Name", placeholder: "Enter Last Name", id: "last-name" }) %> <% end %> </div>
<div> <%= pb_rails("form_group") do %> <%= pb_rails("text_input", props: { label: "with label", placeholder: "Search", id: "search-with-label" }) %> <%= pb_rails("button", props: { text: "Submit", variant: "secondary" }) %> <% end %> <br/> <br/> <%= pb_rails("form_group") do %> <%= pb_rails("text_input", props: { placeholder: "Search" }) %> <%= pb_rails("button", props: { text: "Submit", variant: "secondary" }) %> <% end %> </div>
Full Width is a prop that can be added to any of the Form Group options. This prop allows the Form Group to stretch the full width of the div.
<div> <%= pb_rails("form_group", props: { full_width: true }) do %> <%= pb_rails("text_input", props: { label: "First Name", placeholder: "Enter First Name", id: "first-name-full-width" }) %> <%= pb_rails("text_input", props: { label: "Middle Initial", placeholder: "Enter Middle Initial", id: "middle-initial-full-width" }) %> <%= pb_rails("text_input", props: { label: "Last Name", placeholder: "Enter Last Name", id: "last-name-full-width" }) %> <% end %> <br/> <br/> <%= pb_rails("form_group", props: { full_width: true }) do %> <%= pb_rails("text_input", props: { placeholder: "Search" }) %> <%= pb_rails("button", props: { text: "Submit", variant: "secondary" }) %> <% end %> </div>
<%= pb_rails("flex", props: {orientation: "column", row_gap:"md"}) do %> <%= pb_rails("form_group") do %> <%= pb_rails("text_input", props: { placeholder: "Enter Artist Name" }) %> <%= pb_rails("select", props: { blank_selection: "Genre", options: [ { value: "Country" }, { value: "Pop" }, { value: "Rock" }, { value: "Hip-Hop/Rap" }, { value: "Classical" }, { value: "Gospel" }, { value: "Alternative" }, { value: "Indie" }, { value: "Other" }, ] }) %> <% end %> <%= pb_rails("form_group") do %> <%= pb_rails("select", props: { blank_selection: "Phone", options: [ { value: "Cell" }, { value: "Work" }, { value: "Home" }, ] }) %> <%= pb_rails("phone_number_input", props: { id: "phone" }) %> <% end %> <%= pb_rails("form_group") do %> <%= pb_rails("phone_number_input", props: { id: "phone2" }) %> <%= pb_rails("select", props: { blank_selection: "Phone", options: [ { value: "Cell" }, { value: "Work" }, { value: "Home" }, ] }) %> <% end %> <% end %>
<div> <%= pb_rails("form_group") do %> <%= pb_rails("selectable_card", props: { input_id: "cat1", name: "animal", value: "cat", multi: false }) do %> Cat <% end %> <%= pb_rails("selectable_card", props: { input_id: "dog1", name: "animal", value: "dog", multi: false }) do %> Dog <% end %> <% end %> </div>
<div> <%= pb_rails("form_group") do %> <%= pb_rails("selectable_card_icon", props: { icon: "basketball-ball", title_text: "Basketball", input_id: 7, multi: false, name: "select", }) %> <%= pb_rails("selectable_card_icon", props: { icon: "football-ball", title_text: "Football", input_id: 8, multi: false, name: "select", }) %> <% end %> </div>