Fa'atulagaina
Tu'u atu i au fomu ni fa'atulagaga—mai le laina fa'ata'atia i le fa'ata'atiaga i le fa'atinoga o fa'asologa masani-ma a tatou filifiliga fa'atulagaina.
Fomu
O vaega uma o fomu fanua e tatau ona nofo i se <form>
elemene. O le Bootstrap e leai se sitaili fa'aletonu mo le <form>
elemene, ae o lo'o i ai ni fa'amatalaga mamana mamana e tu'uina atu e ala i le fa'aletonu.
- E fou ile su'ega fomu? Mafaufau e toe iloilo le MDN pepa pepa mo se aotelega ma lisi atoa o uiga avanoa.
<button>
s i totonu o se<form>
faaletonu i letype="submit"
, o lea ia taumafai e faʻamaonia ma faʻaaofia i taimi uma setype
.
Talu ai e fa'aoga le Bootstrap display: block
ma width: 100%
toetoe o a tatou fa'atonuga uma, o le a le mafai ona fa'aputu fa'aputu i luga le sa'o o fomu. E mafai ona fa'aoga vasega fa'aopoopo e fesuia'i ai lea fa'atulagaina i luga ole fa'avae fa'avae.
Utilities
Ole fa'aoga ole pito ole auala pito sili lea ona faigofie e fa'aopoopo ai nisi fausaga ile fomu. Latou te tu'uina atu fa'avae fa'avasegaina o fa'ailoga, fa'atonuga, fa'ailoga fa'ailoga, ma fe'au fa'amaonia. Matou te fautuaina le pipii i margin-bottom
mea aoga, ma faʻaaoga se faʻatonuga e tasi i le fomu mo le tutusa.
Lagona le saoloto e fausia au fomu e tusa lava pe e te manaʻo ai, faʻatasi ai ma <fieldset>
le s, <div>
s, poʻo le toetoe lava o isi elemene.
<div class="mb-3">
<label for="formGroupExampleInput" class="form-label">Example label</label>
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input placeholder">
</div>
<div class="mb-3">
<label for="formGroupExampleInput2" class="form-label">Another label</label>
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input placeholder">
</div>
Fa'asologa o pepa
E mafai ona fausia ni fomu e sili atu ona lavelave e fa'aaoga ai a tatou vasega fa'avasega. Fa'aoga mea nei mo fa'asologa o fomu e mana'omia ai le tele o koluma, felafolafoa'iga lautele, ma isi fa'aogaga fa'aopoopo. Mana'omia le $enable-grid-classes
suiga o le Sass ina ia fa'aagaina (fa'aletonu).
<div class="row">
<div class="col">
<input type="text" class="form-control" placeholder="First name" aria-label="First name">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name" aria-label="Last name">
</div>
</div>
Alavai
E ala i le fa'aopoopoina o vasega fa'aliliuga alavai , e mafai ona e pulea le lautele o alavai i totonu fa'apea fo'i le laina i totonu e pei o le itu o poloka. E manaʻomia foʻi le $enable-grid-classes
suiga o le Sass ina ia faʻaagaina (faʻaletonu).
<div class="row g-3">
<div class="col">
<input type="text" class="form-control" placeholder="First name" aria-label="First name">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name" aria-label="Last name">
</div>
</div>
E mafai fo'i ona faia fa'atonuga sili atu ona lavelave i le faiga fa'ata.
<form class="row g-3">
<div class="col-md-6">
<label for="inputEmail4" class="form-label">Email</label>
<input type="email" class="form-control" id="inputEmail4">
</div>
<div class="col-md-6">
<label for="inputPassword4" class="form-label">Password</label>
<input type="password" class="form-control" id="inputPassword4">
</div>
<div class="col-12">
<label for="inputAddress" class="form-label">Address</label>
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
</div>
<div class="col-12">
<label for="inputAddress2" class="form-label">Address 2</label>
<input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
</div>
<div class="col-md-6">
<label for="inputCity" class="form-label">City</label>
<input type="text" class="form-control" id="inputCity">
</div>
<div class="col-md-4">
<label for="inputState" class="form-label">State</label>
<select id="inputState" class="form-select">
<option selected>Choose...</option>
<option>...</option>
</select>
</div>
<div class="col-md-2">
<label for="inputZip" class="form-label">Zip</label>
<input type="text" class="form-control" id="inputZip">
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="gridCheck">
<label class="form-check-label" for="gridCheck">
Check me out
</label>
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</form>
Faiga faalava
Fausia fomu fa'ata'atia i le fa'asologa e ala i le fa'aopoopoina o le .row
vasega e fa'atupu vaega ma fa'aoga .col-*-*
vasega e fa'ailoa ai le lautele o au fa'ailoga ma fa'atonuga. Ia mautinoa e fa'aopoopo .col-form-label
fo'i i lau <label>
s ina ia fa'atotonugalemu i luga ma a latou fa'atonuga fa'atatau.
I nisi o taimi, atonu e te manaʻomia le faʻaogaina o le pito poʻo le padding utilities e fatu ai lena faʻaoga lelei e te manaʻomia. Mo se fa'ata'ita'iga, ua matou 'ave'esea le fa'ailoga o padding-top
lo'o i luga o la matou fa'aputuga fa'aigoa o le leitio e fa'aoga lelei ai le laina fa'avae.
<form>
<div class="row mb-3">
<label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3">
</div>
</div>
<div class="row mb-3">
<label for="inputPassword3" class="col-sm-2 col-form-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3">
</div>
</div>
<fieldset class="row mb-3">
<legend class="col-form-label col-sm-2 pt-0">Radios</legend>
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
<label class="form-check-label" for="gridRadios1">
First radio
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
<label class="form-check-label" for="gridRadios2">
Second radio
</label>
</div>
<div class="form-check disabled">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
<label class="form-check-label" for="gridRadios3">
Third disabled radio
</label>
</div>
</div>
</fieldset>
<div class="row mb-3">
<div class="col-sm-10 offset-sm-2">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="gridCheck1">
<label class="form-check-label" for="gridCheck1">
Example checkbox
</label>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
Fa'ailoga fa'ailoga fa'asaga'i
Ia mautinoa e fa'aoga .col-form-label-sm
po'o .col-form-label-lg
lou <label>
s po'o <legend>
le s e mulimuli sa'o le tele o le .form-control-lg
ma .form-control-sm
.
<div class="row mb-3">
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm">
</div>
</div>
<div class="row mb-3">
<label for="colFormLabel" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label">
</div>
</div>
<div class="row">
<label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg">
</div>
</div>
Fa'avasegaina o koluma
E pei ona fa'aalia i fa'ata'ita'iga talu ai, o la matou fa'asologa fa'asologa e mafai ai ona e tu'u so'o se numera o .col
s i totonu ole .row
. O le a latou vaevae tutusa le lautele avanoa i le va oi latou. E mafai fo'i ona e filifilia se vaega o au koluma e fa'aalu ai le tele pe itiiti le avanoa, ae o le vaega o totoe .col
e vaelua tutusa le vaega o totoe, ma vasega fa'apitoa koluma e pei o .col-sm-7
.
<div class="row g-3">
<div class="col-sm-7">
<input type="text" class="form-control" placeholder="City" aria-label="City">
</div>
<div class="col-sm">
<input type="text" class="form-control" placeholder="State" aria-label="State">
</div>
<div class="col-sm">
<input type="text" class="form-control" placeholder="Zip" aria-label="Zip">
</div>
</div>
Otometi-fa'atele
O le fa'ata'ita'iga o lo'o i lalo o lo'o fa'aogaina ai se fa'aoga flexbox e fa'atotonu tu'utonu ai mea i totonu ma suiga .col
ina .col-auto
ia na'o le tele o avanoa e fa'aoga ai e au koluma pe a mana'omia. I se isi auala, o le koluma e fua lava i luga o mea o loʻo i totonu.
<form class="row gy-2 gx-3 align-items-center">
<div class="col-auto">
<label class="visually-hidden" for="autoSizingInput">Name</label>
<input type="text" class="form-control" id="autoSizingInput" placeholder="Jane Doe">
</div>
<div class="col-auto">
<label class="visually-hidden" for="autoSizingInputGroup">Username</label>
<div class="input-group">
<div class="input-group-text">@</div>
<input type="text" class="form-control" id="autoSizingInputGroup" placeholder="Username">
</div>
</div>
<div class="col-auto">
<label class="visually-hidden" for="autoSizingSelect">Preference</label>
<select class="form-select" id="autoSizingSelect">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
<div class="col-auto">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="autoSizingCheck">
<label class="form-check-label" for="autoSizingCheck">
Remember me
</label>
</div>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
E mafai ona e toe fa'afefiloi lea fa'atasi ma vasega o koluma fa'apitoa.
<form class="row gx-3 gy-2 align-items-center">
<div class="col-sm-3">
<label class="visually-hidden" for="specificSizeInputName">Name</label>
<input type="text" class="form-control" id="specificSizeInputName" placeholder="Jane Doe">
</div>
<div class="col-sm-3">
<label class="visually-hidden" for="specificSizeInputGroupUsername">Username</label>
<div class="input-group">
<div class="input-group-text">@</div>
<input type="text" class="form-control" id="specificSizeInputGroupUsername" placeholder="Username">
</div>
</div>
<div class="col-sm-3">
<label class="visually-hidden" for="specificSizeSelect">Preference</label>
<select class="form-select" id="specificSizeSelect">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
<div class="col-auto">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="autoSizingCheck2">
<label class="form-check-label" for="autoSizingCheck2">
Remember me
</label>
</div>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
Fa'atumu laina
Fa'aoga .row-cols-*
vasega e fai ai fa'ata'ita'iga fa'ata'amilosaga tali. E ala i le fa'aopoopoina o vasega fa'aleleia alavai , o le a iai a matou alavai i itu fa'alava ma tu'usa'o. I luga o va'aiga va'ai fe'avea'i vaapiapi, .col-12
e fesoasoani le fa'aputuina o fa'atonuga ma isi mea. O .align-items-center
le fa'aogaina o elemene foliga i le ogatotonu, ma .form-check
fa'aoga lelei ai.
<form class="row row-cols-lg-auto g-3 align-items-center">
<div class="col-12">
<label class="visually-hidden" for="inlineFormInputGroupUsername">Username</label>
<div class="input-group">
<div class="input-group-text">@</div>
<input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="Username">
</div>
</div>
<div class="col-12">
<label class="visually-hidden" for="inlineFormSelectPref">Preference</label>
<select class="form-select" id="inlineFormSelectPref">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="inlineFormCheck">
<label class="form-check-label" for="inlineFormCheck">
Remember me
</label>
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>