You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.8 KiB

4 years ago
  1. +++
  2. title = "Label"
  3. description = "Provide accessible captions for form controls."
  4. categories = ["experience"]
  5. tags = []
  6. html_attributes = ["for", "form"]
  7. custom_attributes = ["text"]
  8. snippets_used = ["label", "text input", "form group", "help block"]
  9. [[copyright]]
  10. owner = "Josh Habdas"
  11. date = "2019"
  12. license = "agpl-3.0-or-later"
  13. +++
  14. Explicit label association with [Text Input](../text-input):
  15. ```html
  16. {{</* hackcss-label for="query" text="Search query:" /*/>}}
  17. {{</* hackcss-textinput type="search" id="query" */>}}
  18. ```
  19. {{< hackcss-label for="query" text="Search query:" />}}
  20. {{< hackcss-textinput type="search" id="query" >}}
  21. Implicit label association using [Text Input](../text-input) and [Help Block](../help-block):
  22. ```html
  23. {{</* hackcss-form >}}
  24. {{< hackcss-label >}}
  25. {{< hackcss-helpblock text="Enter your Associate Tag:" />}}
  26. {{< hackcss-textinput name="AssociateTag" required="true" pattern="^\b\w*\b-20$" placeholder="associate-20" >}}
  27. {{< /hackcss-label >}}
  28. {{< /hackcss-form */>}}
  29. ```
  30. {{< hackcss-form >}}
  31. {{< hackcss-label >}}
  32. {{< hackcss-helpblock text="Enter your Associate Tag:" />}}
  33. {{< hackcss-textinput name="AssociateTag" required="true" pattern="^\b\w*\b-20$" placeholder="associate-20" >}}
  34. {{< /hackcss-label >}}
  35. {{< /hackcss-form >}}
  36. Combined with [Form Group](../form-group) to show [Text Input](../text-input) success state:
  37. ```html
  38. {{</* hackcss-formgroup state="success" >}}
  39. {{< hackcss-label for="fullname" text="Full Name:" />}}
  40. {{< hackcss-textinput id="fullname" value="Edgar Allan Poe" required="true" >}}
  41. {{< /hackcss-formgroup */>}}
  42. ```
  43. {{< hackcss-formgroup state="success" >}}
  44. {{< hackcss-label for="fullname" text="Full Name:" />}}
  45. {{< hackcss-textinput id="fullname" value="Edgar Allan Poe" required="true" >}}
  46. {{< /hackcss-formgroup >}}
  47. See [Form Group](../form-group) for additional control states.