Comments (4)
Thank you for the issue! The alignment
property can be applied to ion-checkbox
to align the checkbox at the top: https://stackblitz.com/edit/angular-k51j4b-ti2q2v?file=src%2Fapp%2Fexample.component.html
There does seem to be an issue where the checkbox doesn't have the same margin as the label when placed inside of an item, but other than that, is this the behavior you are looking for?
from ionic-framework.
This issue also seems to occur if you use the legacy label syntax and it is contained within an ion-item, I have had to use the following workaround to get the alignment correct. The "toggleCheckbox" click event is needed on the ion-label because if the whole thing is not wrapped in an ion-item then clicking the label does not check the box.
HTML
<div class="checklistItem" *ngFor="let item of checklistItems">
<div class="checkbox">
<ion-checkbox [(ngModel)]="item.Checked" (ngModelChange)="change(item, $event)" labelPlacement="end"></ion-checkbox>
<ion-label class="ion-text-wrap" (click)="toggleCheckbox(item)">{{item.Name}}</ion-label>
</div>
</div>
CSS
.checkbox {
display: flex;
justify-content: flex-start;
align-items: flex-start;
}
ion-checkbox {
margin: 2px 5px 5px 0;
}
ion-label {
margin-top: 3px;
margin-bottom: 0;
cursor: pointer;
user-select: none;
}
Typescript
toggleCheckbox(item) {
// Toggle the checked state of the item
item.Checked = !item.Checked;
// Call change method to handle the checkbox change
this.change(item, null);
}
change(item, event) {
// DO STUFF
}
StackBlitz example
https://stackblitz.com/edit/angular-k51j4b-kdzzsu?file=src%2Fapp%2Fexample.component.html%3AL6,src%2Fapp%2Fexample.component.css,src%2Fapp%2Fexample.component.ts
from ionic-framework.
@brandyscarney Yes thank you, that is the behaviour I was looking for, I think I must of dismissed that option when looking at the docs because they were showing horizontal alignment when using "stacked" labels so didn't think it would apply to vertical alignment as well.
Maybe the docs could be updated to include an example with labelPlacement "start" and "end" to show it also works with vertical alignment.
The alignment issue when using ion-item isn't too much of a problem for me because I can remove ion-item from my code, other people that do need ion-item should be able to fix the alignment with the following CSS:
ion-checkbox::part(label) {
margin-top: 2px;
}
from ionic-framework.
Thanks for the quick response! I agree that the documentation could be improved. I created an issue to update the examples to include this usage here: ionic-team/ionic-docs#3818.
Iβve also marked this as a bug to fix the margin issue when used inside an item, as itβs a pretty simple fix. Thanks for providing a workaround that can be used until the fix is implemented. πβ
from ionic-framework.
Related Issues (20)
- bug: Alerts/dialog messages cannot be modified using any aria overrides
- bug: aria-label ignored on ion-select-option when using TalkBack
- feat: Extend ion-range CSS shadowparts for individual knob styling with dualKnobs active
- bug: IonInput default autocapitalize value disrespects system keyboard settings and relevant browser defaults
- bug: ion-refresher functionality broken in React + console error HOT 4
- bug: popover arrow changes after scroll to the end of the page
- bug: Inputs with icons are strange
- bug: ion-segment-buttons activating improperly after opening contextmenu (right mouse click) on Mac HOT 1
- feat: Show popover on text input without click event HOT 1
- bug: FocusManagerPriority, unable to navigate to previously clicked link
- bug: ion-tab-bar is not working when used as a standalone Vue component after the v8.3.0/v8.3.1 update HOT 1
- bug: Ionic cap run fails with error "Invalid target ID: ?"
- feat: Add "keyboard-showing" class to ion-app or app-root
- bug: App within ion-router-outlet not properly mounted with vue test-utils
- feat: allow slot on ion-select-option
- bug: Ionic Gesture - mismatched gesture details in the last onMove handler and the onEnd handler.
- bug: Extraneous Non-Props Attributes Passed to <ion-menu> Component Cannot Be Inherited
- bug: Unintended Voiceover Output in Default ion-select Popup
- bug: radio on android TV not working as expected
- bug: ionic-core and ionicons use different stencil versions which results in bundle warning
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ionic-framework.