I'm developing a dropdown, where you click or focus the input, a white container should display at the bottom of the input, the problem is that, the focus is not working and i don't know why ( i hate css :/ )
So this is the code
This is the structure
<NavbartPart1SearchBar>
<input type="text" placeholder="Buscar en Facebook" maxLength={100} />
{/* Dropdown */}
<NavbarPart1Dropdown> </NavbarPart1Dropdown>
</NavbartPart1SearchBar>
export const NavbarPart1Dropdown = styles.div`
display: none;
position: absolute;
width: 100%;
height: 20vh;
background: white;
`;
export const NavbartPart1SearchBar = styles.div`
position: relative;
input{
width: 255px;
font-size: 1.53rem;
font-weight: 300;
padding: 1.23rem 1.75rem;
border-radius: 2.1rem;
background: #F0F2F5;
&:focus ${NavbarPart1Dropdown} {
display: flex;
}
}
`;
So as you can see, input has a focus event, when i focus on it, i add display flex to the other container, but it won't work, do you see any problems with my code?
Know let me show you how it should look
Do you see the black part ? i want that to appear when focus, so, if you can help me, you're cool !
You can select the next sibling element with + in CSS. So the following should work:
input:focus + ${NavbarPart1Dropdown} { display: block; }
I've been digging through the Ant-Design node_module trying to change the default color and default width of an active tab but have had no luck. Anyone know how to override it?
The problem is that I don't know which element has the border to begin with. Any help is very welcomed.
you can go with:
.ant-tabs-tab.ant-tabs-tab-active {
border-bottom: 2px solid #BF2D30 !important;
z-index: 2;
}
UPDATE
This style will do as expected.
.ant-tabs-ink-bar {
height: 5px;
background: red !important;
}
Check https://pro.ant.design/docs/style#Override-the-component-style on how to override style .
Refer dis answer too Antd: How to override style of a single instance of a component
To figure out on what needs to be changed on your own, Inspect the element in browser.
You need use tabBarStyle props.
See docs: https://ant.design/components/tabs/
I solve this problem with this code:
import './styles.less';
const [tabIndex, setTabIndex] = useState('0');
const borderClass = ['redBorder', 'greenBorder', 'blueGreyBorder'];
<Tabs
className={`tabs ${borderClass[tabIndex]}`}
defaultActiveKey={tabIndex}
onChange={onSetTabIndex}
>
// And in the styles.less:
` .tabs {
margin-top: 17px;
width: 100%;
}
.redBorder{
.ant-tabs-ink-bar {
background-color: #e94747;
}
}
.greenBorder{
.ant-tabs-ink-bar {
background-color: #24ad52;
}
}
.blueGreyBorder{
.ant-tabs-ink-bar {
background-color: #5b708b;
}
}`
with the state we can change the class and use the cascade css to solve our problem
I'm developing a reactjs project by ant-design (antd) library. I want to use Carousel component in my project. When I put the background color of the content -which should be shown inside the carousel- to #FFF, the bullet navigation buttons will be disappeared. How should I change the color of the bullets? This is a normal Carousel:
import { Row, Col, Carousel } from 'antd';
export default class Temp extends Component {
render(){
return (
<Carousel vertical autoplay>
<div>{this.ContentDesign()}</div>
<div>{this.ContentDesign()}</div>
<div>{this.ContentDesign()}</div>
<div>{this.ContentDesign()}</div>
</Carousel>
)}
and this is my CSS:
.ant-carousel .slick-slide {
overflow: hidden;
height: 160px;
}
Thanks :)
Just stumbled upon this question over a year later, but hopefully, this will be of help to someone. To style Ant Design components, you can open the inspect tool in your browser and find the class name used on the part you want to style.
So for example, if you want to style the bullet points for the carousel, you look in the inspect tool and will see that they have the class names: .ant-carousel .slick-dots li button and .ant-carousel .slick-dots li.slick-active button for the active bullet point.
So to change the colour of the bullet point you simply have to override what is already set. Example of this:
.ant-carousel .slick-dots li button {
background: #ff4ef6;
opacity: 0.4;
}
.ant-carousel .slick-dots li.slick-active button {
opacity: 1;
background: #ff4ef6;
}
Code Sandbox: https://codesandbox.io/s/elegant-rgb-1e2fo?file=/index.css
Assuming that you are adding color directly to .ant-carousel .slick-slide (which is wrong),
You should add color code to css like dis... Differentiate color based on your requirement
.ant-carousel .slick-slide {
overflow: hidden;
height: 160px;
background: #364d79;
}
.ant-carousel .slick-slide div {
color: #fff;
}
I am attempting to override the default max-width of the snackbar component in Angular Material.
The CSS applied by Angular Material is shown below:
.mat-snack-bar-container {
border-radius: 2px;
box-sizing: border-box;
display: block;
margin: 24px;
max-width: 568px;
min-width: 288px;
padding: 14px 24px;
transform: translateY(100%) translateY(24px);
}
I have tried overriding using the same style in my style.css file but this style is overridden by the default style.
.mat-snack-bar-container {
max-width: 800px;
}
I have found an answer to a similar question but I know the answer to that question is now deprecated (/deep/ is deprecated).
Is there a best practices solution to this?
To do this properly, you need to set the View Encapsulation to None on your component:
#Component({
templateUrl: './my.component.html' ,
styleUrls: ['./my.component.css'],
encapsulation: ViewEncapsulation.None,
})
Then in your component css you can just do this:
.mat-snack-bar-container {
max-width: 800px;
}
From the official docs:
View Encapsulation = None means that Angular does no view
encapsulation. Angular adds the CSS to the global styles. The scoping
rules, isolations, and protections discussed earlier don't apply. This
is essentially the same as pasting the component's styles into the
HTML.
Put css in your styles.scss or styles.css
.snackbar {
max-width: 90% !important;
margin-left: auto !important; // center align from left
margin-right: auto !important; // center align from right
margin-bottom: 1rem !important;
padding: 10px !important; // spacing between the text and boundary
background-color: green;
color: white;
.mat-button-wrapper {
color: black !important; // action text color
}
}
Note: make sure you have set !important with every style, without it, style wouldn't work.
in component.ts
this.snackbar.open(this.resMsg.message, 'OK', {
panelClass: 'snackbar'
})
Verified for #angular/material v7.0.x:
CSS !important modifier does the trick.
Put this is src/styles.scss (the app's global css):
.mat-snack-bar-container {
max-width: 100% !important;
}
Also we tweak its font:
/* Overrides SnackBar CSS in Material Design's .mat-simple-snackbar class */
/* Original sizes: font: 24px, height: 47.952px */
.mat-simple-snackbar {
display: flex;
font-size: 28px !important; // 28px is double, 42px for triple
min-height: 70px !important; // 70px for double, 90px for triple
align-items: center !important;
justify-content: center !important;
}
As of June 30, 2019, using Angular Material 8.0.1 with Angular 8.0.3, the following SCSS and typescript seems to work for overriding the color of the action button in an Angular Material snackbar *without using !important *:
styles.scss (not the extremely long duration, which allowed me to inspect the styling before it disappeared):
$snackBarTextColor: white;
$snackBarBackgroundNormal: #087a51;
$snackBarActionColor: lightgray;
.snackBarInfo {
background-color: $snackBarBackgroundNormal;
color: $snackBarTextColor;
}
.mat-simple-snackbar > span {
font-weight: bold;
}
.mat-simple-snackbar-action {
.mat-button {
.mat-button-wrapper {
color: $snackBarActionColor;
}
}
}
app.module.ts:
import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '#angular/material/snack-bar';
providers: [
{
provide: MAT_SNACK_BAR_DEFAULT_OPTIONS,
useValue: {
duration: 41000,
horizontalPosition: 'center',
verticalPosition: 'bottom',
panelClass: 'snackBarInfo'
}
}
]
I remember working in a project with web-designers, and they had a money-jar, where devs had to put a coin in if they used the !important statement. ;)
The other solutions did not work for me, unless i set the .cdk-overlay-pane (using material 11):
.cdk-overlay-pane {
width: 100%;
}
.mat-snack-bar-container {
max-width: 100%;
width: 100%;
}
Not sure when Material introduced this (must be a new thing judging by all the answers to this thread), but you can now override the mat-snack-bar-container's styles by passing a parameter in the _snackBar.open(), like this:
component.ts
openSnackBar(message: string, action: string) {
this._snackBar.open(message, action {
panelClass: 'my-custom-container-class',
});
}
component.scss
::ng-deep .my-custom-container-class{
max-width: 100% !important;
min-width: 0% !important;
min-height: 0 !important;
padding: 0 !important;
margin: 32px !important;
box-shadow: none;
}
I'm afraid you still have to use the ng-deep and the !importants; but at least you no longer need to do ViewEncapsulation None.
The way to go.
encapsulation: ViewEncapsulation.None
Here is a stackblick to demonstrate
Angular 10 and without special tricks:
use panelClass when opening the snackbar, for example:
this.snackBar.open("VeryLongTextWithoutThePossibilityOfBreakingAutomatically", "X", {
duration: 0,
panelClass: 'notif-error'
});
duration: 0 is only for debugging.
write this into your style.css
.notif-error {
background-color: red;
}
.mat-snack-bar-container.notif-error {
max-width: 100%;
}
Now because of css-specificity, this will be the most specific rule.
Beware that there should not be space between .mat-snack-bar-container and .notif-error.
This rule will apply to elements which has both the .mat-snack-bar-container and .notif-error classes.
This also works when your .notif-error class is empty.
Using vw works for me,on both bigger and small screen size
.mat-snack-bar-container {
margin-right: auto !important;
margin-left: auto !important;
width: 80vw !important;
max-width: 100vw !important;
}
FYI Starting with Angular Material v15 with the migradtion to MDC, the class .mat-snack-bar-container has been renamed to
.mat-mdc-snack-bar-container
I also had to use some of the new inner MDC snackbar classes to properly recolor the snackbar starting in v15:
SCSS:
// Classname used in the MatSnackBarConfig obj of MatSnackBar.open():
// panelClass: ['my-snackbar-class']
my-snackbar-class.mat-mdc-snack-bar-container {
.mdc-snackbar__surface {
// Background color of entire snackbar:
background-color: red;
.mdc-snackbar__label {
// Color of snackbar text:
color: white;
}
button {
// Color of snackbar button text:
color: white !important;
}
}
}
So I am providing the resources for my celllist via the constructor. Everything seems to work, I have provided my own style sheet:
.cellListWidget {
color: #021650;
background-color: #021650;
}
.cellListEvenItem {
cursor: pointer;
zoom: 1;
background: red;
}
.cellListOddItem {
cursor: pointer;
zoom: 1;
background: blue;
}
.cellListKeyboardSelectedItem {
background: #ffc;
}
.cellListSelectedItem {
background-color: green;
color: white;
height: auto;
overflow: visible;
}
I must not understand it quite right because the background color I tried to set for the widget does not seem to take any effect. The rest of the styles work though, even item, odd item, selected item, etc.
Just to clarify, I want to change the color of the whole column this list is on, it items in the list are obviously styled, but the list takes up more vertical space than there are items, so where there are no items, is just a grey color which I want to change.
The solution I found was to not style the cell list, but the flowpanel that the cell list was on.