企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## form 组件 > input[type="text/password/number/range"], textarea ``` form .form-group label input(type="text").form-control small.form-text.text-muted ``` ![](https://box.kancloud.cn/87c5410fea0fc0763e45b011fb67b4a1_613x572.png) > select ``` form .form-group label(for="xx") select.form-control(id="xx") option xxx .form-group label(for="xx2") select.form-control(id="xx2", multiple) option xxxx ``` ![](https://box.kancloud.cn/da2d363582704ab8afdfa056678b48fd_815x247.png) > fieldset ``` fieldset.form-group legend xxx .form-group label input.form-control .form-check label.form-check-label input(type="radio").form-check-input ``` ![](https://box.kancloud.cn/4118b4da03b56f8bc0871aa7ebd57e2b_590x146.png) > input[type="file"] ``` form .form-group label input(type="file").form-control-file ``` ![](https://box.kancloud.cn/4aee097ca7471d1ff0afb7bc22f7e8bf_665x101.png) > Inline forms ``` form.form-inline .form-group label xx input.form-control button(type="submit").btn.btn-primary xx ``` ![](https://box.kancloud.cn/5e65d8b1125ef3990ee23be1c5155425_703x82.png) > Hidden labels ``` form.form-inline .form-group label.sr-only xx input.form-control button(type="submit").btn.btn-primary xx ``` ![](https://box.kancloud.cn/c6c38e6263132c6c1a94328247d1fef8_664x60.png) ``` form.form-inline .form-group label.sr-only xx .input-group .input-group-addon $ input.form-control .input-group-addon .00 button(type="submit").btn.btn-primary xx ``` ![](https://box.kancloud.cn/b8e023e0d425c8da7ead55f314077f0d_582x76.png) > Using the Grid ```jade form .form-group.row label(for="xx").col-sm-2.col-form-label .col-sm-10 input#xx.form-control fieldset.form-group.row legend.col-sm-2.col-form-legend Radios .col-sm-10 .form-check label.form-check-label input(type="radio").form-check-input xxx .form-check label.form-check-label input(type="radio").form-check-input xxx .form-group.row label.col-sm-2 .col-sm-10 .form-check label.form-check-label input(type="checkbox").form-check-input xxx .form-group.row .offset-sm-2.col-sm-10 button(type="submit").btn.btn-primary xxx ``` ![](https://box.kancloud.cn/97a51ae65ef12f62d2988aadf614ff72_799x365.png) Grid-based form layouts also support large and small inputs. ``` form .form-group.row label.col-sm-2.col-form-label.col-form-label-lg(for="xx") .col-sm-10 input#xx.form-control.form-control-lg(type="email") .form-group.row label.col-sm-2.col-form-label.col-form-label-sm(for="xx") .col-sm-10 input#xx.form-control.form-control-sm(type="email") ``` ![](https://box.kancloud.cn/212f9fef416eb88aaa36cf8bcd9bc66e_801x140.png) ### Checkboxes and radios > default ``` form .form-check label.form-check-label input(type="checkbox/radio").form-check-input ``` ![](https://box.kancloud.cn/762c15c6c6df77e65ac4127c67d5f812_499x78.png) ![](https://box.kancloud.cn/63300c29adb15c8bf86a82860513d42e_587x112.png) > inline ``` form .form-check-inline label.form-check-label input(type="checkbox/radio").form-check-input xx ``` ![](https://box.kancloud.cn/46b74dee275abb3ab4d11849a07cd8d5_177x55.png) ![](https://box.kancloud.cn/f730760df69be0eeffbc5ceff0b5b997_179x44.png) --- > Static controls ``` form .form-group.row label.col-sm-2.col-form-label .col-sm-10 p.form-control-static.mb-0 .form-group.row label.col-sm-2.col-form-label .col-sm-10 input.form-control ``` ![](https://box.kancloud.cn/974b5725fed95cf25ee1525db7be5cf7_811x130.png) ``` form.form-inline .form-group label.sr-only xx p.form-control-static.mb-0 xxx .form-group label.sr-only xx input(type="password").form-control button.btn.btn-primary xxx ``` ![](https://box.kancloud.cn/df30bc8ecce51551c905270114ba2cc8_584x71.png) --- ### Disabled states Add the disabled boolean attribute on an input to prevent user interactions. Disabled inputs appear lighter and add a not-allowed cursor. ```html <input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled> ``` Add the disabled attribute to a <fieldset> to disable all the controls within. ``` form fieldset(disabled="") .form-group label input.form-control button.btn.btn-default xx ``` ![](https://box.kancloud.cn/a41523a4aa6728fbe14ea8989b654adb_810x267.png) **注意**: While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don’t fully support the disabled attribute on a <fieldset>. Use custom JavaScript to disable the fieldset in these browsers. --- ### Readonly inputs Add the readonly boolean attribute on an input to prevent modification of the input’s value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor. ```html <input class="form-control" type="text" placeholder="Readonly input here…" readonly> ``` --- ### Control sizing Set heights using classes like .form-control-lg, and set widths using grid column classes like .col-lg-*. ``` input.form-control.form-control-lg input.form-control.form-control input.form-control-sm ``` ![](https://box.kancloud.cn/0a589d1142c037437886f09c70612e50_806x162.png) ![](https://box.kancloud.cn/4b3c74975f82cb69e12a4b69b65ff536_803x167.png) --- ### Help text Block-level help text in forms can be created using .form-text (previously known as .help-block in v3). Inline help text can be flexibly implemented using any inline HTML element and utility classes like .text-muted. > Block level Block help text—for below inputs or for longer lines of help text—can be easily achieved with .form-text. This class includes display: block and adds some top margin for easy spacing from the inputs above. ``` label(for="xx") input(type="password", aria-describedby="yy")#xx.form-control p#yy.form-text.text-muted lorem... ``` ![](https://box.kancloud.cn/29bb6cf23b467961583048d7ea72e922_807x141.png) > Inline Inline text can use any typical inline HTML element (be it a <small>, <span>, or something else). ``` form.form-inline .form-group label(for="xx") input(type="password", aria-describedby="yy")#xx.form-control small#yy.text-muted lorem... ``` ![](https://box.kancloud.cn/5a38eaf4eee5ddde543c82e4635c406b_565x68.png) --- ### Validation ``` .form-group.has-success/warning/danger label.form-control-label input.form-control.form-control-success/warning/danger .form-control-feedback small.form-text.text-muted .form-check.has-success/warning/danger label.form-check-label input(type="checkbox/radio").form-check-input xxx ``` ![](https://box.kancloud.cn/d12dc324097574f166a7fd6ea532f8dc_838x418.png) ![](https://box.kancloud.cn/5575209af08c022194d018c86bfcc3b2_242x111.png) --- ### Custom forms > checkbox ``` label.custom-control.custom-checkbox input(type="checkbox").custom-control-input span.custom-control-indicator span.custom-control-discription Check this custom checkbox ``` ![](https://box.kancloud.cn/6b6e4c6aea1c53374f28e2f2c0e7735d_300x59.png) > radio ``` label.custom-control.custom-radio input(type="radio").custom-control-input span.custom-control-indicator span.custom-control-discription Check this custom radio ``` ![](https://box.kancloud.cn/db50fed75796751a708510078dcb3d9c_556x66.png)