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.

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