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.

153 lines
5.7 KiB

4 years ago
  1. +++
  2. title = "Button"
  3. description = "Add colorful buttons to forms and pages."
  4. categories = ["experience"]
  5. tags = ["controls"]
  6. html_attributes = ["id", "value", "name", "class", "onclick", "tabindex", "target", "disabled", "form"]
  7. custom_attributes = ["type", "text", "isghost", "isblock", "action", "method"]
  8. snippets_used = ["button", "button group", "throbber", "form", "external"]
  9. [[copyright]]
  10. owner = "Josh Habdas"
  11. date = "2019"
  12. license = "agpl-3.0-or-later"
  13. +++
  14. Different types:
  15. ```html
  16. {{</* hackcss-button text="Default" /*/>}}
  17. {{</* hackcss-button text="Primary" type="primary" /*/>}}
  18. {{</* hackcss-button text="Success" type="success" /*/>}}
  19. {{</* hackcss-button text="Info" type="info" /*/>}}
  20. {{</* hackcss-button text="Warning" type="warning" /*/>}}
  21. {{</* hackcss-button text="Error" type="error" /*/>}}
  22. ```
  23. {{< hackcss-button text="Default" />}}
  24. {{< hackcss-button text="Primary" type="primary" />}}
  25. {{< hackcss-button text="Success" type="success" />}}
  26. {{< hackcss-button text="Info" type="info" />}}
  27. {{< hackcss-button text="Warning" type="warning" />}}
  28. {{< hackcss-button text="Error" type="error" />}}
  29. Ghost types:
  30. ```html
  31. {{</* hackcss-button isghost="true" text="Default" /*/>}}
  32. {{</* hackcss-button isghost="true" text="Primary" type="primary" /*/>}}
  33. {{</* hackcss-button isghost="true" text="Success" type="success" /*/>}}
  34. {{</* hackcss-button isghost="true" text="Info" type="info" /*/>}}
  35. {{</* hackcss-button isghost="true" text="Warning" type="warning" /*/>}}
  36. {{</* hackcss-button isghost="true" text="Error" type="error" /*/>}}
  37. ```
  38. {{< hackcss-button isghost="true" text="Default" />}}
  39. {{< hackcss-button isghost="true" text="Primary" type="primary" />}}
  40. {{< hackcss-button isghost="true" text="Success" type="success" />}}
  41. {{< hackcss-button isghost="true" text="Info" type="info" />}}
  42. {{< hackcss-button isghost="true" text="Warning" type="warning" />}}
  43. {{< hackcss-button isghost="true" text="Error" type="error" />}}
  44. Block-level:
  45. ```html
  46. {{</* hackcss-button type="primary" isghost="true" isblock="true" text="Block Level Button" /*/>}}
  47. ```
  48. {{< hackcss-button type="primary" isghost="true" isblock="true" text="Block Level Button" />}}
  49. Text in body:
  50. ```html
  51. {{</* hackcss-button >}}Default{{< /hackcss-button */>}}
  52. {{</* hackcss-button type="primary" >}}<i>HTML</i>{{< /hackcss-button */>}}
  53. {{%/* hackcss-button type="success" %}}~~Markdown~~{{% /hackcss-button */%}}
  54. {{</* hackcss-button isghost="true" text="Comment" >}}Hidden comment{{< /hackcss-button */>}}
  55. ```
  56. {{< hackcss-button >}}Default{{< /hackcss-button >}}
  57. {{< hackcss-button type="primary" >}}<i>HTML</i>{{< /hackcss-button >}}
  58. {{% hackcss-button type="success" %}}~~Markdown~~{{% /hackcss-button %}}
  59. {{< hackcss-button isghost="true" text="Comment" >}}Hidden comment{{< /hackcss-button >}}
  60. In [Button Group](../button-group):
  61. ```html
  62. {{</* hackcss-buttongroup >}}
  63. {{< hackcss-button isghost="true" type="success" text="Left" >}}
  64. {{< hackcss-button isghost="true" type="success" text="Middle" >}}
  65. {{< hackcss-button isghost="true" type="success" text="Right" >}}
  66. {{< /hackcss-buttongroup */>}}
  67. ```
  68. {{< hackcss-buttongroup >}}
  69. {{< hackcss-button isghost="true" type="success" text="Left" />}}
  70. {{< hackcss-button isghost="true" type="success" text="Middle" />}}
  71. {{< hackcss-button isghost="true" type="success" text="Right" />}}
  72. {{< /hackcss-buttongroup >}}
  73. Print preview:
  74. ```html
  75. {{</* hackcss-button type="info" isghost="true" onclick="print()" >}}
  76. <svg viewBox="0 0 32 32" width="16" height="16" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  77. <path d="M7 25 L2 25 2 9 30 9 30 25 25 25 M7 19 L7 30 25 30 25 19 Z M25 9 L25 2 7 2 7 9 M22 14 L25 14" />
  78. </svg>
  79. {{< /hackcss-button */>}}
  80. ```
  81. {{< hackcss-button type="info" isghost="true" onclick="print()" >}}
  82. <svg viewBox="0 0 32 32" width="16" height="16" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  83. <path d="M7 25 L2 25 2 9 30 9 30 25 25 25 M7 19 L7 30 25 30 25 19 Z M25 9 L25 2 7 2 7 9 M22 14 L25 14" />
  84. </svg>
  85. {{< /hackcss-button >}}
  86. [Loading](../throbber) indication:
  87. ```html
  88. {{</* hackcss-button type="info" isghost="true" >}}
  89. Loading&hellip; {{< hackcss-throbber >}}
  90. {{< /hackcss-button */>}}
  91. ```
  92. {{< hackcss-button type="info" isghost="true" >}}
  93. Loading&hellip; {{< hackcss-throbber >}}
  94. {{< /hackcss-button >}}
  95. [External](../external) navigation:
  96. ```html
  97. {{</* external rel="shortlink" href="https://go.habd.as/mavic-air" >}}
  98. {{< hackcss-button type="success" text="Open" />}}
  99. {{< /external */>}}
  100. ```
  101. {{< external rel="shortlink" href="https://go.habd.as/mavic-air" >}}
  102. {{< hackcss-button type="success" text="Open" />}}
  103. {{< /external >}}
  104. [Form](../form) control:
  105. ```html
  106. {{</* hackcss-form action="javascript:alert('Form Alert')" >}}
  107. {{< hackcss-buttongroup formactions="true" >}}
  108. {{< hackcss-button text="Custom Action" action="javascript:alert('Custom Alert')" isghost="true" type="primary" />}}
  109. {{< hackcss-button disabled="true" isghost="true" text="Disabled" />}}
  110. {{< /hackcss-buttongroup >}}
  111. {{< /hackcss-form */>}}
  112. ```
  113. {{< hackcss-form action="javascript:alert('Form Alert')" >}}
  114. {{< hackcss-buttongroup formactions="true" >}}
  115. {{< hackcss-button text="Custom Action" action="javascript:alert('Custom Alert')" isghost="true" type="primary" />}}
  116. {{< hackcss-button disabled="true" isghost="true" text="Disabled" />}}
  117. {{< /hackcss-buttongroup >}}
  118. {{< /hackcss-form >}}
  119. ```html
  120. {{</* hackcss-form id="owner" action="javascript:alert('Form Alert')" /*/>}}
  121. {{</* hackcss-button form="owner" text="Form Action" type="primary" isghost="true" /*/>}}
  122. ```
  123. {{< hackcss-form id="owner" action="javascript:alert('Form Alert')" />}}
  124. {{< hackcss-button form="owner" text="Form Action" type="primary" isghost="true" />}}