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.

583 lines
18 KiB

10 years ago
  1. ---
  2. layout : 'default'
  3. css : 'form'
  4. title : 'Form'
  5. description : 'A form is a collection of user input elements'
  6. type : 'UI Collection'
  7. ---
  8. <script src="/javascript/form.js"></script>
  9. <%- @partial('header') %>
  10. <div class="main container">
  11. <div class="peek">
  12. <div class="ui vertical pointing secondary menu">
  13. <a class="active item">Types</a>
  14. <a class="item">Elements</a>
  15. <a class="item">States</a>
  16. <a class="item">Variations</a>
  17. <a class="item">Groups</a>
  18. </div>
  19. </div>
  20. <h2 class="ui dividing header">Types</h2>
  21. <div class="example">
  22. <h4 class="ui header">Form:</h4>
  23. <p>
  24. Forms always include fields, and fields always contain form elements. Fields themselves may also include:
  25. <a href="/elements/input.html">inputs</a>, standard form fields, <a href="/elements/label.html">labels</a>, <a href="/modules/dropdown.html">selection dropdowns</a>, textareas, as well as:
  26. <a href="/modules/checkbox.html">checkboxes</a>, and <a href="/collections/message.html">message blocks</a>.
  27. </p>
  28. <p>Validation messages use <a href="/collections/message.html">messages</a> which are formatted for use inside forms.</p>
  29. <div class="ui ignored warning message">
  30. <p>If you are looking for form validation, you should check out <a href="/modules/form.html">form validation</a>.</p>
  31. </div>
  32. <div class="ui ignored info message">
  33. <p>This example uses a <a href="/elements/segment.html">ui segment</a> to add the padding and background color. This is not required.</p>
  34. </div>
  35. <div class="ui form segment">
  36. <div class="field">
  37. <label>Username</label>
  38. <div class="ui left labeled icon input">
  39. <input type="text" placeholder="Username">
  40. <i class="user icon"></i>
  41. <div class="ui corner label">
  42. <i class="icon asterisk"></i>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="field">
  47. <label>Password</label>
  48. <div class="ui left labeled icon input">
  49. <input type="password">
  50. <i class="lock icon"></i>
  51. <div class="ui corner label">
  52. <i class="icon asterisk"></i>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="ui error message">
  57. <div class="header">We noticed some issues</div>
  58. </div>
  59. <div class="ui blue submit button">Login</div>
  60. </div>
  61. </div>
  62. <h2 class="ui dividing header">Elements</h2>
  63. <div class="example">
  64. <h4 class="ui header">Field</h4>
  65. <p>A field is a form element containing a label and an input</p>
  66. <div class="ui form">
  67. <div class="field">
  68. <label>User Input</label>
  69. <input type="text">
  70. </div>
  71. </div>
  72. </div>
  73. <div class="example">
  74. <h4 class="ui header">Text Area</h4>
  75. <p>A textarea uses the default form element</p>
  76. <div class="ui form">
  77. <div class="field">
  78. <label>User Text</label>
  79. <textarea></textarea>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="no example">
  84. <h4 class="ui header">Checkbox</h4>
  85. <p><a href="/modules/checkbox.html">UI Checkboxes</a> are styled forms of standard form checkboxes.</p>
  86. <div class="evaluated code" data-type="javascript" data-label="true">
  87. $('.ui.checkbox')
  88. .checkbox()
  89. ;
  90. </div>
  91. <div class="ui form">
  92. <div class="inline field">
  93. <div class="ui checkbox">
  94. <input type="checkbox" />
  95. <label>Checkbox</label>
  96. </div>
  97. </div>
  98. <div class="inline field">
  99. <div class="ui slider checkbox">
  100. <input type="checkbox" />
  101. <label>Slider</label>
  102. </div>
  103. <label></label>
  104. </div>
  105. <div class="inline field">
  106. <div class="ui toggle checkbox">
  107. <input type="checkbox" />
  108. <label>Toggle</label>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="no form example">
  114. <h4 class="ui header">Select</h4>
  115. <p>A selection dropdown, a type of <a href="/modules/dropdown.html">ui dropdown</a> can be used to allow for a selection from multiple choices</p>
  116. <div class="evaluated code" data-type="javascript" data-label="true">
  117. $('.ui.selection.dropdown')
  118. .dropdown()
  119. ;
  120. </div>
  121. <div class="ui selection dropdown">
  122. <input type="hidden" name="gender">
  123. <div class="default text">Gender</div>
  124. <i class="dropdown icon"></i>
  125. <div class="menu">
  126. <div class="item" data-value="male">Male</div>
  127. <div class="item" data-value="female">Female</div>
  128. </div>
  129. </div>
  130. </div>
  131. <div class="no example">
  132. <h4 class="ui header">Radio Box</h4>
  133. <p>Radio boxes are styled forms of standard form radio controls.</p>
  134. <div class="evaluated code" data-type="javascript" data-label="true">
  135. $('.ui.radio.checkbox')
  136. .checkbox()
  137. ;
  138. </div>
  139. <div class="ui form">
  140. <div class="grouped inline fields">
  141. <div class="field">
  142. <div class="ui radio checkbox">
  143. <input type="radio" name="fruit" checked />
  144. <label>Apples</label>
  145. </div>
  146. </div>
  147. <div class="field">
  148. <div class="ui radio checkbox">
  149. <input type="radio" name="fruit" />
  150. <label>Oranges</label>
  151. </div>
  152. </div>
  153. <div class="field">
  154. <div class="ui radio checkbox">
  155. <input type="radio" name="fruit" />
  156. <label>Pears</label>
  157. </div>
  158. </div>
  159. <div class="field">
  160. <div class="ui radio checkbox">
  161. <input type="radio" name="fruit" />
  162. <label>Grapefruit</label>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. <div class="example">
  169. <h4 class="ui header">Text Block</h4>
  170. <p>Text blocks have special meaning inside a form tag. Any info, error, or warning message blocks found inside a form are hidden by default.</p>
  171. <div class="ui form">
  172. <div class="ui message">
  173. <div class="header">We had some issues</div>
  174. <ul class="list">
  175. <li>Please enter your first name</li>
  176. <li>Please enter your last name</li>
  177. </ul>
  178. </div>
  179. </div>
  180. </div>
  181. <h2 class="ui dividing header">States</h2>
  182. <h3 class="ui header">Form</h3>
  183. <div class="example">
  184. <h4 class="ui header">Loading</h4>
  185. <p>If a form is in loading state, it will automatically show a loading indicator:</p>
  186. <div class="ui loading form segment">
  187. <div class="two fields">
  188. <div class="field">
  189. <label>First Name</label>
  190. <input placeholder="First Name" type="text">
  191. </div>
  192. <div class="field">
  193. <label>Last Name</label>
  194. <input placeholder="Last Name" type="text">
  195. </div>
  196. </div>
  197. <div class="field">
  198. <label>Gender</label>
  199. <div class="ui fluid selection dropdown">
  200. <div class="text">Select</div>
  201. <i class="dropdown icon"></i>
  202. <input type="hidden" name="gender">
  203. <div class="menu">
  204. <div class="item" data-value="male">Male</div>
  205. <div class="item" data-value="female">Female</div>
  206. </div>
  207. </div>
  208. </div>
  209. <div class="field">
  210. <label>Username</label>
  211. <input placeholder="Username" type="text">
  212. </div>
  213. <div class="field">
  214. <label>Password</label>
  215. <input type="password">
  216. </div>
  217. <div class="inline field">
  218. <div class="ui checkbox">
  219. <input type="checkbox" />
  220. <label>I agree to the terms and conditions</label>
  221. </div>
  222. </div>
  223. <div class="ui blue submit button">Submit</div>
  224. </div>
  225. </div>
  226. <div class="example">
  227. <h4 class="ui header">Error</h4>
  228. <p>If a form is in an error state, it will automatically show any error message blocks:</p>
  229. <div class="ui error form segment">
  230. <div class="ui error message">
  231. <div class="header">Action Forbidden</div>
  232. <p>You can only sign up for an account once with a given e-mail address.</p>
  233. </div>
  234. <div class="two fields">
  235. <div class="field">
  236. <label>First Name</label>
  237. <input placeholder="First Name" type="text">
  238. </div>
  239. <div class="field">
  240. <label>Last Name</label>
  241. <input placeholder="Last Name" type="text">
  242. </div>
  243. </div>
  244. <div class="field">
  245. <label>Gender</label>
  246. <div class="ui fluid selection dropdown">
  247. <div class="text">Select</div>
  248. <i class="dropdown icon"></i>
  249. <input type="hidden" name="gender">
  250. <div class="menu">
  251. <div class="item" data-value="male">Male</div>
  252. <div class="item" data-value="female">Female</div>
  253. </div>
  254. </div>
  255. </div>
  256. <div class="field">
  257. <label>Username</label>
  258. <input placeholder="Username" type="text">
  259. </div>
  260. <div class="field">
  261. <label>Password</label>
  262. <input type="password">
  263. </div>
  264. <div class="inline field">
  265. <div class="ui checkbox">
  266. <input type="checkbox" />
  267. <label>I agree to the Terms and Conditions</label>
  268. </div>
  269. </div>
  270. <div class="ui blue submit button">Submit</div>
  271. </div>
  272. </div>
  273. <div class="example">
  274. <h4 class="ui header">Warning</h4>
  275. <p>If a form is in warning state, it will automatically show any warning message block:</p>
  276. <div class="ui warning form segment">
  277. <div class="ui warning message">
  278. <div class="header">Could you check something!</div>
  279. <ul class="list">
  280. <li>You forgot your <b>first name</b></li>
  281. <li>And also your <b>last name</b></li>
  282. </ul>
  283. </div>
  284. <div class="two error fields">
  285. <div class="field">
  286. <label>First Name</label>
  287. <input placeholder="First Name" type="text">
  288. <div class="ui red pointing above ui label">Enter a first name</div>
  289. </div>
  290. <div class="field">
  291. <label>Last Name</label>
  292. <input placeholder="Last Name" type="text">
  293. <div class="ui red pointing above ui label">Enter a last name</div>
  294. </div>
  295. </div>
  296. <div class="field">
  297. <label>Username</label>
  298. <input placeholder="Username" type="text">
  299. </div>
  300. <div class="field">
  301. <label>Password</label>
  302. <input type="password">
  303. </div>
  304. <div class="inline field">
  305. <div class="ui checkbox">
  306. <input type="checkbox" />
  307. <label>I agree to the Terms and Conditions</label>
  308. </div>
  309. </div>
  310. <div class="ui blue submit button">Submit</div>
  311. </div>
  312. </div>
  313. <h3 class="ui header">Form Fields</h3>
  314. <div class="example">
  315. <h4 class="ui header">Error</h4>
  316. <p>Individual fields may contain an error state</p>
  317. <div class="ui form segment">
  318. <div class="two fields">
  319. <div class="field error">
  320. <label>First Name</label>
  321. <input placeholder="First Name" type="text">
  322. </div>
  323. <div class="field">
  324. <label>Last Name</label>
  325. <input placeholder="Last Name" type="text">
  326. </div>
  327. </div>
  328. <div class="field error">
  329. <label>Gender</label>
  330. <div class="ui fluid selection dropdown">
  331. <div class="text">Select</div>
  332. <i class="dropdown icon"></i>
  333. <input type="hidden" name="gender">
  334. <div class="menu">
  335. <div class="item" data-value="male">Male</div>
  336. <div class="item" data-value="female">Female</div>
  337. </div>
  338. </div>
  339. </div>
  340. </div>
  341. </div>
  342. <div class="example">
  343. <h4 class="ui header">Disabled</h4>
  344. <p>Individual fields may be disabled or read only</p>
  345. <div class="ui form segment">
  346. <div class="two fields">
  347. <div class="field">
  348. <label>First Name</label>
  349. <input placeholder="Read Only" readonly="readonly" type="text">
  350. </div>
  351. <div class="disabled field">
  352. <label>Last Name</label>
  353. <input placeholder="Disabled" disabled="disabled" type="text">
  354. </div>
  355. </div>
  356. </div>
  357. </div>
  358. <h2 class="ui dividing header">Variations</h2>
  359. <h3 class="ui header">Forms</h3>
  360. <div class="example">
  361. <h4 class="ui header">Fluid</h4>
  362. <p>A form can take the width of its container</p>
  363. <div class="ui fluid form segment">
  364. <div class="two fields">
  365. <div class="field">
  366. <label>First Name</label>
  367. <input placeholder="First Name" type="text">
  368. </div>
  369. <div class="field">
  370. <label>Last Name</label>
  371. <input placeholder="Last Name" type="text">
  372. </div>
  373. </div>
  374. <div class="ui blue submit button">Submit</div>
  375. </div>
  376. </div>
  377. <div class="example">
  378. <h4 class="ui header">Size</h4>
  379. <p>A form can also be small or large</p>
  380. <div class="ui small form segment">
  381. <div class="two fields">
  382. <div class="field">
  383. <label>First Name</label>
  384. <input placeholder="First Name" type="text">
  385. </div>
  386. <div class="field">
  387. <label>Last Name</label>
  388. <input placeholder="Last Name" type="text">
  389. </div>
  390. </div>
  391. <div class="ui blue small submit button">Submit</div>
  392. </div>
  393. <br><br>
  394. <div class="ui large form segment">
  395. <div class="two fields">
  396. <div class="field">
  397. <label>First Name</label>
  398. <input placeholder="First Name" type="text">
  399. </div>
  400. <div class="field">
  401. <label>Last Name</label>
  402. <input placeholder="Last Name" type="text">
  403. </div>
  404. </div>
  405. <div class="ui blue submit button">Submit</div>
  406. </div>
  407. </div>
  408. <div class="example">
  409. <h4 class="ui header">Inverted</h4>
  410. <p>A form on a dark background may have to invert its color scheme</p>
  411. <div style="background-color: #333333; padding: 15px;">
  412. <div class="ui inverted form">
  413. <div class="ui info message">
  414. <div class="header">We had some issues</div>
  415. <ul class="list">
  416. <li>Please enter your first name</li>
  417. <li>Please enter your last name</li>
  418. </ul>
  419. </div>
  420. <div class="two fields">
  421. <div class="field">
  422. <label>First Name</label>
  423. <input placeholder="First Name" type="text">
  424. </div>
  425. <div class="field">
  426. <label>Last Name</label>
  427. <input placeholder="Last Name" type="text">
  428. </div>
  429. </div>
  430. <div class="inline field">
  431. <div class="ui checkbox">
  432. <input type="checkbox" />
  433. <label>I agree to the terms and conditions</label>
  434. </div>
  435. </div>
  436. <div class="ui blue submit button">Submit</div>
  437. </div>
  438. </div>
  439. </div>
  440. <h3 class="ui header">Fields</h3>
  441. <div class="example">
  442. <h4 class="ui header">Inline</h4>
  443. <p>A field can have its label next to instead of above it.</p>
  444. <div class="ui form">
  445. <div class="inline field">
  446. <label>Last name</label>
  447. <input type="text" placeholder="Full Name">
  448. </div>
  449. </div>
  450. </div>
  451. <div class="example">
  452. <h4 class="ui header">Date</h4>
  453. <p>A field can let users know they are for dates</p>
  454. <div class="ui form">
  455. <div class="date field">
  456. <label>Birthday</label>
  457. <input type="text" placeholder="xx/xx/xxxx">
  458. </div>
  459. </div>
  460. </div>
  461. <h2 class="ui dividing header">Groups</h2>
  462. <div class="example">
  463. <h4 class="ui header">Fields</h4>
  464. <p>Fields can exist together side by side</p>
  465. <div class="ui ignored positive icon message">
  466. <i class="mobile icon"></i>
  467. <div class="content">
  468. <h3 class="header">Responsive Element</h3>
  469. <p>Grouped fields automatically receive responsive styling, swapping to one field per row for mobile.</p>
  470. </div>
  471. </div>
  472. <div class="ui form">
  473. <div class="ui three fields">
  474. <div class="field">
  475. <label>First name</label>
  476. <input type="text" placeholder="First Name">
  477. </div>
  478. <div class="field">
  479. <label>Middle name</label>
  480. <input type="text" placeholder="Middle Name">
  481. </div>
  482. <div class="field">
  483. <label>Last name</label>
  484. <input type="text" placeholder="Last Name">
  485. </div>
  486. </div>
  487. </div>
  488. </div>
  489. <div class="example">
  490. <h4 class="ui header">Grouped Fields</h4>
  491. <p>Fields can be grouped to show related choices</p>
  492. <div class="ui form">
  493. <div class="grouped inline fields">
  494. <div class="field">
  495. <div class="ui radio checkbox">
  496. <input type="radio" name="fruit" />
  497. <label></label>
  498. </div>
  499. <label> Apples</label>
  500. </div>
  501. <div class="field">
  502. <div class="ui radio checkbox">
  503. <input type="radio" name="fruit" />
  504. <label></label>
  505. </div>
  506. <label> Oranges</label>
  507. </div>
  508. <div class="field">
  509. <div class="ui radio checkbox">
  510. <input type="radio" name="fruit" />
  511. <label></label>
  512. </div>
  513. <label> Pears</label>
  514. </div>
  515. <div class="field">
  516. <div class="ui radio checkbox">
  517. <input type="radio" name="fruit" />
  518. <label></label>
  519. </div>
  520. <label> Grapefruit</label>
  521. </div>
  522. </div>
  523. </div>
  524. </div>
  525. <div class="example">
  526. <h4 class="ui header">Inline</h4>
  527. <p>Multiple fields may be inline in a row</p>
  528. <div class="ui form">
  529. <div class="inline fields">
  530. <div class="field">
  531. <label>Phone Number</label>
  532. <input type="text" placeholder="(xxx)">
  533. </div>
  534. <div class="field">
  535. <input type="text" placeholder="xxx">
  536. </div>
  537. <div class="field">
  538. <input type="text" placeholder="xxxx">
  539. </div>
  540. </div>
  541. </div>
  542. </div>
  543. </div>