Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 714b713

Browse files
committed
Clarifying exactly how the theme’s form control class names work
Related to NativeScript/theme#133
1 parent 9959821 commit 714b713

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

ui/theme.md

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -463,54 +463,51 @@ You can use the following form-related class names to improve the look of forms
463463
</StackLayout>
464464
```
465465

466-
* `input-field`: A class name that should be applied to each individual field within a form.
467-
468-
``` XML
469-
<StackLayout class="form">
470-
<StackLayout class="input-field">
471-
<!-- The first field, for example “Email address” -->
472-
</StackLayout>
473-
<StackLayout class="input-field">
474-
<!-- The second field, for example “Password” -->
475-
</StackLayout>
476-
</StackLayout>
477-
```
466+
There are a few different ways you may want to display individual form fields within your form. Look over the list of class names below, and then review the subsequent examples to see those class names in action.
478467

479468
* `input`: A class name that applies the base stying to TextField UI components.
480469
* `input-border`: A class name that adds a border to a TextField UI component.
481470
* `input-rounded`: A class name that adds a rounded border to a TextField UI component.
471+
* `label`: A class name that applies the base styling to Label UI components.
472+
* `input-field`: A class name that can be applied to a parent container to align labels with their corresponding TextField UI controls.
473+
* `input-sides`: A class name that helps align a label and text field side by side.
474+
475+
Here’s a form with a number of different form control display options you can experiment with.
482476

483477
``` XML
484478
<StackLayout class="form">
479+
480+
<!-- Option 1: An input with no label, and a bottom border -->
485481
<StackLayout class="input-field">
486-
<TextField class="input"></TextField>
487-
</StackLayout>
488-
<StackLayout class="input-field">
489-
<TextField class="input input-border"></TextField>
482+
<TextField hint="Option 1" class="input" />
483+
<StackLayout class="hr-light"></StackLayout>
490484
</StackLayout>
485+
486+
<!-- Option 2: An input with a label on top, and a bottom border -->
491487
<StackLayout class="input-field">
492-
<TextField class="input input-rounded"></TextField>
488+
<Label text="Option 2" class="label font-weight-bold m-b-5" />
489+
<TextField class="input" />
490+
<StackLayout class="hr-light"></StackLayout>
493491
</StackLayout>
494-
</StackLayout>
495-
```
496492

497-
> **TIP** The NativeScript core theme handles styling disabled TextField components. To disable a TextField, set its `isEnabled` attribute to `false`. For example, `<TextField class="input" isEnabled="false"></TextField>`.
493+
<!-- Option 3: An label and input—positioned side by side -->
494+
<GridLayout class="input-field input-sides" rows="auto, auto" columns="*,*">
495+
<Label text="Option 3" class="label font-weight-bold" row="0" col="0" />
496+
<TextField class="input right" row="0" col="1" />
497+
<StackLayout class="hr-light" row="1" colSpan="2"></StackLayout>
498+
</GridLayout>
498499

499-
* `label`: A class name that applies the base styling to Label UI components.
500+
<!-- Option 4: An input with a simple border and no label -->
501+
<TextField hint="Option 4" class="input input-border" />
502+
503+
<!-- Option 5: An input with a rounded border and no label -->
504+
<TextField hint="Input rounded" class="input input-rounded" />
500505

501-
``` XML
502-
<StackLayout class="form">
503-
<StackLayout class="input-field">
504-
<Label class="label" text="Email:"></Label>
505-
<TextField class="input"></TextField>
506-
</StackLayout>
507-
<StackLayout class="input-field">
508-
<Label class="label" text="Password:"></Label>
509-
<TextField class="input"></TextField>
510-
</StackLayout>
511506
</StackLayout>
512507
```
513508

509+
> **TIP** The NativeScript core theme handles styling disabled TextField components. To disable a TextField, set its `isEnabled` attribute to `false`. For example, `<TextField class="input" isEnabled="false"></TextField>`.
510+
514511
### Images
515512

516513
The NativeScript core theme provides a few CSS class names for altering the appearance of images.

0 commit comments

Comments
 (0)