<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sujith</title>
    <description>The latest articles on DEV Community by Sujith (@sujith).</description>
    <link>https://dev.to/sujith</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1131467%2F744b52bc-fd8a-4d83-b59f-902f6bd7f453.jpeg</url>
      <title>DEV Community: Sujith</title>
      <link>https://dev.to/sujith</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sujith"/>
    <language>en</language>
    <item>
      <title>Generate suggestions for email input</title>
      <dc:creator>Sujith</dc:creator>
      <pubDate>Wed, 23 Aug 2023 12:23:40 +0000</pubDate>
      <link>https://dev.to/sujith/generate-suggestions-for-email-input-8am</link>
      <guid>https://dev.to/sujith/generate-suggestions-for-email-input-8am</guid>
      <description>&lt;p&gt;Providing input suggestions to the user can imporve your apps user expirence 2x more!&lt;/p&gt;

&lt;p&gt;Also, providing suggestions makes sure that the user have the ability to easily choose the options without much hussle. &lt;/p&gt;

&lt;p&gt;Recently while i was building an app i stumbled upon a similar use case where i needed to show some email suggestion when user is trying to register his/her account for the first time.&lt;/p&gt;

&lt;p&gt;I went through couple of UI designs that fits the most for my app.&lt;/p&gt;

&lt;p&gt;Let's see how we can easily create a suggestible email input just using html -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--deqgIuFN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2qk53bv9guiaerpkmaw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--deqgIuFN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2qk53bv9guiaerpkmaw.png" alt="Image description" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from the above code, i have created an input wrapper which contains a label and an input field&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;input type="email" size="40" list="defaultSuggestions" placeholder="johndoe@test.com"/&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here we are setting the attribute &lt;code&gt;type&lt;/code&gt; as email, &lt;code&gt;size&lt;/code&gt; is basically the width of the input field, &lt;code&gt;list&lt;/code&gt; is required in order to show the suggestion based on the key that we have given to the list attribute, &lt;code&gt;placeholder&lt;/code&gt; attribute enables you to provide a hint text about the values that need to be entered in an input field.&lt;/p&gt;

&lt;p&gt;I have also added my own styles to the input fields, feel free to add your own.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ly2lvAXK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xet9zvsniz4mhkj9f9im.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ly2lvAXK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xet9zvsniz4mhkj9f9im.png" alt="Image description" width="562" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next let's see how we can bring in the suggestion for our email input field. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1qF5ArzU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ywyd79uf13dbc8rb3yy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1qF5ArzU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ywyd79uf13dbc8rb3yy.png" alt="Image description" width="800" height="687"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;datalist&lt;/code&gt; attribute that you can see the above code is what makes the email input field to show the recommended options  that's available to choose from the dropdown.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;datalist&lt;/code&gt; contains an &lt;code&gt;id&lt;/code&gt; attribute which should be same as the name given to the email input attribute &lt;code&gt;list&lt;/code&gt;. In this example the &lt;code&gt;id&lt;/code&gt; is &lt;code&gt;"defaultSuggestions"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;datalist&lt;/code&gt; also contains child elements that's required to show the suggestions. &lt;code&gt;option&lt;/code&gt; tag lets you create different options or it can represent menu items in popups or dropdowns. &lt;code&gt;option&lt;/code&gt; tag takes &lt;code&gt;value&lt;/code&gt;as its attribute, the &lt;code&gt;value&lt;/code&gt; shows the suggestible values that will be used inside the email input.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AAnVch9f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3coqdqh42kcrr04hsehf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AAnVch9f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3coqdqh42kcrr04hsehf.png" alt="Image description" width="660" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's it, you have just created your email input suggestions.&lt;/p&gt;

&lt;p&gt;Click on the email input and you will see the magic!&lt;/p&gt;

&lt;p&gt;Cheers!👋&lt;/p&gt;

&lt;p&gt;Let's connect - &lt;a href="https://twitter.com/reachsujith"&gt;https://twitter.com/reachsujith&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>react</category>
      <category>css</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
