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.

624 lines
19 KiB

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