want to draw shadow on bottom of tabs
<Tabs
onChange={this.handleTabChange}
value={this.state.slideIndex}
style={?}
>
<Tab label="Label" value={0} style={or here?} ></Tab>
</Tabs>
how to write the styles
thanks
If you're referring to Material UI, I believe Tabs do not have a zDepth property as the AppBar does. Best to fold the Tab component into the AppBar.
You can add it manually, however, with:
style={{boxShadow: '0 1px 6px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.12)'}}
Related
I'm doing a mobile app using Ionic 6.1.4 and Capacitor 3.5.1.
Android, looks good by default, black background and white icons on any screen.
iOS, always has whatever the background color I have in the ion-content with black icons. Is always like this on any screen. In my app, I have 2 screens with a dark background and the ion-content with the attribute fullscreen.
iOS, as I said, I have two screen with a very dark background, let's replicate it using a black background. See how the icons are not visible anymore?
Component:
<ion-header class="ion-no-border">
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button color="white"></ion-menu-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true">
</ion-content>
Style:
ion-toolbar {
--background: transparent;
}
ion-content {
--background: black;
}
How can I change iOS Status Bar to always have a style just like Android?
or even better, how can I leave the Status Bar untouched on iOS (app not modifying the Status Bar at all)?
I have tried:
.ios {
ion-header {
margin-top: var(--ion-safe-area-top);
}
ion-toolbar {
margin-top: var(--ion-safe-area-top);
--padding-top: var(--ion-safe-area-top);
padding-top: var(--ion-safe-area-top);
}
}
But this just moves all the content down and Status Bar is keeping the background color of my app.
I was thinking to use the plugin called #capacitor/status-bar to change the Status Bar style just on iOS, but it's not so simple in my case. Since I have 2 screens with dark background, I will need to make the Status Bar Dark when enter, and when onDestroy is called, make it back to Light so my other screens which have white background looks good too. I think this is a tedious process. I think there must be a way to avoid this.
My goal is to keep the Status Bar on iOS always the same and with a color that makes the icons visible. I would prefer leaving the Status Bar untouched just like Android do.
I don't know about Capacitor, but I know that on Cordova for iOS, you need to include viewport-fit=cover in the <meta name="viewport" content="..."> tag of your index.html to do this, e.g.
<meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
This works for me when using the cordova-plugin-statusbar plugin, anyway.
Well, I suggest trying one of the followings:
If you are using Cordova, use the cordova-status-bar plugin and try setting the statusBar color in the config.xml:
<preference name="StatusBarBackgroundColor" value="#000000" />
or
<preference name="StatusBarBackgroundColor" value="#ffffff" />
setting it to a value in hex color, probably you want it black, and then setting the text and icons to light or lightcontent as you did in Android by using:
<preference name="StatusBarStyle" value="lightcontent" />
If you are using Capacitor, install the Capacitor plugin
npm install #capacitor/status-bar
npx cap sync
and then set the color of the background and text using
import { StatusBar, Style } from '#capacitor/status-bar';
// iOS only
window.addEventListener('statusTap', function () {
console.log('statusbar tapped');
});
const setStatusBarStyleDark = async () => {
await StatusBar.setStyle({ style: Style.Dark });
};
Finally, if none of that works, or you just want to change it on iOS try setting it in the global.scss as you were doing but also changing the backgound color and the color:
.ios {
ion-header {
margin-top: var(--ion-safe-area-top);
background-color: black;
color: white;
}
ion-toolbar {
margin-top: var(--ion-safe-area-top);
--padding-top: var(--ion-safe-area-top);
padding-top: var(--ion-safe-area-top);
background-color: black;
color: white;
}
}
I am developing an application using Ionic 4 and I am using ion-select. I want to customize the select icon, but the style is not applied.
<ion-select interface="popover"
(ionChange)="onSelectionChanged()"
[(ngModel)]="item.Value">
<ion-select-option *ngFor="let option of options" [value]="option.Value">
{{ option.Title }}
</ion-select-option>
</ion-select>
This is the style written in the .scss file, but it is not applied. I've also checked the documentation, but I couldn't find a solution.
.select-icon .select-icon-inner {
margin-top: 0 !important;
border-right: 7px solid transparent !important;
border-left: 7px solid transparent !important;
border-top: 7px solid !important;
}
If you're talking about the little arrow on the right, it seems that it is not possible at least fot the moment, see
issue here
You can use a button and a modal though.
When upgraded to Ionic 5, the padding attribute is not working anymore as in Ionic 4:
<ion-content color="primary" padding></ion-content>
Any fixes?
Story in Ionic v4:
Use of attributes got deprecated in Ionic v4 and if you would have noticed in developers console, Ionic 4 was throwing warnings of using these attributes to style.
Story in Ionic v5:
In Ionic v5, these attributes got removed permanently and got replaced with CSS classes. So even if those attributes there in your code, no effect will be there.
As per the Breaking Changes https://github.com/ionic-team/ionic/blob/v5.0.0/BREAKING.md#css:
We originally added CSS utility attributes for styling components because it was a quick and easy way to wrap text or add padding to an element. Once we added support for multiple frameworks as part of our "Ionic for everyone" approach, we quickly determined there were problems with using CSS attributes with frameworks that use JSX and Typescript. In order to solve this we added CSS classes. Rather than support CSS attributes in certain frameworks and classes in others, we decided to remove the CSS attributes and support what works in all of them, classes, for consistency. In addition to this, changing to classes prefixed with ion avoids conflict with native attributes and user's CSS. In the latest version of Ionic 4, there are deprecation warnings printed in the console to show what the new classes are, and the documentation has been updated since support for classes was added to remove all references to attributes
Solution:
You need to replace all your attributes to CSS classes. For example:
Before
<ion-header text-center></ion-header>
<ion-content padding></ion-content>
After
<ion-header class="ion-text-center"></ion-header>
<ion-content class="ion-padding"></ion-content>
For your case, replace
<ion-content color="primary" padding></ion-content>
to
<ion-content color="primary" class="ion-padding"></ion-content>
Try this,
<ion-content color="primary" class="ion-padding"></ion-content>
According to the official documentation, you can use these CSS custom properties to set padding of ion-content component:
--padding-bottom Bottom padding of the content
--padding-end Right padding if direction is left-to-right, and left padding if direction is right-to-left of the content
--padding-start Left padding if direction is left-to-right, and right padding if direction is right-to-left of the content
--padding-top Top padding of the content
In the SCSS file associated with your component, add:
ion-content {
--padding-bottom: 10px;
--padding-end: 10px;
--padding-start: 20px;
--padding-top: 20px;
}
This should add padding inside the content area.
ion-item {
--padding-start: 10px;
--padding-end: 10px;
--padding-top: 0px;
--padding-bottom: 0px;
--inner-padding-top: 0px;
--inner-padding-bottom: 0px;
--inner-padding-start: 0px;
--inner-padding-end: 0px;
--border-width: 0;
--inner-border-width: 0;
--border-color: transparent;
}
ion-header {
--min-height: auto;
}
In ionic 4 and Ionic 5 the use of padding like this:
<ion-content color="primary" class="ion-padding"></ion-content>
and see https://ionicframework.com/docs/layout/css-utilities
http://ingoodtastemag.com/
On an iPhone, the button is round with a gradient. However, on every other desktop browser and Android that we've tested so far, it is square. I want the button to stay square. What CSS resets do I need for this?
This rounded corner is the default property of the Safari browser and iOS 5 devices. To overwrite it, use the following styling for your button:
-webkit-appearance: none;
border-radius: 0;
To keep your own border radius while removing the iOS styling
-webkit-appearance: none;
-webkit-border-radius: none;
border-radius: 10px;
You must remove webkit's border-radius to get your own style back, but you can still add your own border-radius after you remove theirs.
You could try to use this property on your button attribute.
border-radius: 0
I use in a gwt application a LayoutPanel with two Buttons inside it. The LayoutPanle has height of 35px; while the Buttons have height of 25px; I want to align vertically the Buttons in the middle of Panel. Much as I have tried, no common styling approach seems to work on it. Either setting vertical-align: middle on the Panel styling or or on the Buttons styling, the Buttons remain top-aligned. What is the proper approach in this case to bring eventually the Buttons in the middle, other than wrapping a HorizontalPanel for each Button inside the LayoutPanel and applying the verticalAlignment on the HorizontalPanel? Here is my code in Uibinder:
<g:LayoutPanel styleName="{style.buttonsBar}">
<g:layer left="30px" width="70px">
<g:Button ui:field="createButton" styleName="{style.crdelButton}">Create</g:Button>
</g:layer>
<g:layer right="30px" width="70px">
<g:Button ui:field="deleteButton" styleName="{style.crdelButton}">Delete</g:Button>
</g:layer>
</g:LayoutPanel>
If you panel is always 35px high, you have two options:
(1) Set margin on buttons to
margin: 5px 0;
(2) Set the following style to your LayoutPanel:
line-height: 35px;