I want to make a dark mode but i cant find any information on how to change the color of the checkmark (its currently black on black), can anyone help me?
I have tried:
.choiceBox .context-menu {
-fx-text-fill: #ffffff;
-fx-border-color: #ffffff;
}
.choiceBox .menu-item:focused {
-fx-text-fill: #ffffff;
-fx-background-color: #222222;
}
.choiceBox .menu-item > .label {
-fx-text-fill: #ffffff;
}
.choiceBox .menu-item:focused > .label {
-fx-text-fill: #ffffff;
}
.choiceBox > .label {
-fx-text-fill: #ffffff;
-fx-border-color: #ffffff;
}
It's called "arrow". This changes it to yellow:
.choice-box > .open-button > .arrow,
.combo-box-base > .arrow-button > .arrow {
-fx-background-color: yellow, yellow;
-fx-background-insets: 0 0 -1 0, 0;
-fx-padding: 0.166667em 0.333333em 0.166667em 0.333333em; /* 2 4 2 4 */
-fx-shape: "M 0 0 h 7 l -3.5 4 z";
}
I have a TabPane for which I have set a style through CSS. However, I would like to have the different style fot the TabPane on another screen(for selected and unselected tabs). The following code is what I have working when I was using a common style for all the TabPane.
.tab-pane .tab-header-area .tab-header-background {
-fx-opacity: 0;
}
.tab-pane
{
-fx-tab-min-width:90px;
}
.tab{
-fx-background-insets: 0 1 0 1,0,0;
}
.tab-pane .tab
{
-fx-background-color: #abe0ff;
}
.tab-pane .tab:selected
{
-fx-background-color: #015A7C;
}
.tab .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: #3c3c3c;
-fx-font-size: 14px;
-fx-font-weight: bold;
}
.tab:selected .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: white;
}
.tab-pane:top *.tab-header-area {
-fx-background-insets: 0, 0 0 1 0;
/* -fx-padding: 0.416667em 0.166667em 0.0em 0.833em; /* 5 2 0 10 */
-fx-padding: 0.416667em 0.166667em 0.0em 0.0em; /* overridden as 5 2 0 0 */
}
In the case of trying to set it to different colors, I tried the following which was an unsuccessful attempt :
.MyTabPane > .tab-pane .tab-header-area .tab-header-background {
-fx-opacity: 0;
}
.MyTabPane > .tab-pane
{
-fx-tab-min-width:90px;
}
.MyTabPane > .tab{
-fx-background-insets: 0 1 0 1,0,0;
}
.MyTabPane > .tab-pane .tab
{
-fx-background-color: #e8e8e8;
}
.MyTabPane > .tab-pane .tab:selected
{
-fx-background-color: #c0c0c0;
}
.MyTabPane > .tab .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: #3c3c3c;
-fx-font-size: 14px;
-fx-font-weight: bold;
}
.MyTabPane > .tab:selected .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: white;
}
.MyTabPane > .tab-pane:top *.tab-header-area {
-fx-background-insets: 0, 0 0 1 0;
/* -fx-padding: 0.416667em 0.166667em 0.0em 0.833em; /* 5 2 0 10 */
-fx-padding: 0.416667em 0.166667em 0.0em 0.0em; /* overridden as 5 2 0 0 */
}
This is from my FXML :
<TabPane fx:id="tabPane" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" GridPane.rowIndex="1" styleClass="MyTabPane">
Can someone please point me in the right direction.
I also tried following this idea, but couldn't get it through for the color of unselected tab: How do you set JavaFX TabPane CSS in code?
P.S. I am pretty new to CSS. I apologize if it is a silly question. Any suggestions are welcome.
Create a simple TabPane and add style class:
TabPane tabPane = new TabPane();
tabPane.getStyleClass().add("MyTabPane");
Tab tab1 = new Tab("Page 1", new Label("Page 1"));
Tab tab2 = new Tab("Page 2", new Label("Page 2"));
Tab tab3 = new Tab("Page 3", new Label("Page 3"));
tabPane.getTabs().addAll(tab1, tab2, tab3);
In CSS:
.MyTabPane .tab-pane .tab-header-area .tab-header-background {
-fx-opacity: 0;
}
.MyTabPane .tab-pane {
-fx-tab-min-width: 90px;
}
.MyTabPane .tab {
-fx-background-insets: 0 1 0 1, 0, 0;
}
.MyTabPane .tab-pane .tab {
-fx-background-color: #e8e8e8;
}
.MyTabPane .tab-pane .tab:selected {
-fx-background-color: #c0c0c0;
}
.MyTabPane .tab .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: #3c3c3c;
-fx-font-size: 14px;
-fx-font-weight: bold;
}
.MyTabPane .tab:selected .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: red;
}
.MyTabPane .tab-pane:top *.tab-header-area {
-fx-background-insets: 0, 0 0 1 0;
/* -fx-padding: 0.416667em 0.166667em 0.0em 0.833em; /* 5 2 0 10 */
-fx-padding: 0.416667em 0.166667em 0.0em 0.0em; /* overridden as 5 2 0 0 */
}
Anybody facing this issue can refer the following code. Turns out I was not using the selector correctly :
FXML :
<TabPane fx:id="tabPane" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" GridPane.rowIndex="1" styleClass="MyTabPane">
CSS :
.MyTabPane
{
-fx-tab-min-width:90px;
}
.tab{
-fx-background-insets: 0 1 0 1,0,0;
}
.MyTabPane .tab
{
-fx-background-color: #e8e8e8;
}
.MyTabPane .tab:selected
{
-fx-background-color: #c0c0c0;
}
.tab .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: #3c3c3c;
-fx-font-size: 14px;
-fx-font-weight: bold;
}
.tab:selected .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: white;
}
.MyTabPane:top *.tab-header-area {
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.416667em 0.166667em 0.0em 0.0em; /* overridden as 5 2 0 0 */
}
I would like to apply the default "focus" style tab to my selected tab. Mainly I am trying to accomplish keeping the thin blue border around the tab regardless of whether or not the user is focused on the tab, but instead as long as it is the tab they have selected. I included an example of how it looks now when I am focused on something else and how I would like it to look when I am focused on something else.
/*Overrides the default and removes the 10px padding from the left most tab */
.tab-pane:top *.tab-header-area {
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.416667em 0.166667em 0.0em 0.0em; /* overridden as 5 2 0 0 */
}
.tab-header-background {
-fx-background-color: transparent;
}
.tab-pane{
-fx-tab-min-width:90px;
}
.tab-pane .tab{
-fx-background-insets: 0 0 0 0,0,0;
-fx-background-color: #c6c6c6;
}
.tab-pane .tab:selected{
-fx-background-color: #3c3c3c;
}
.tab .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: #828282;
-fx-font-size: 12px;
-fx-font-weight: bold;
}
.tab:selected .tab-label {
-fx-alignment: CENTER;
-fx-text-fill: #96b946;
}
In my modena.css that selector looks like:
.tab-pane:focused > .tab-header-area > .headers-region > .tab:selected .focus-indicator {
...
}
Just use it without :focused:
.tab-pane > .tab-header-area > .headers-region > .tab:selected .focus-indicator {
-fx-border-width: 1, 1;
/*-fx-border-color: -fx-focus-color, -fx-faint-focus-color;*/
-fx-border-color: red;
-fx-border-insets: -4 -4 -6 -5, -2 -2 -5 -3;
-fx-border-radius: 2, 1;
}
While working with JavaFX, I found the focus border to be hindering on some visual nodes, like buttons and certain panes. Other questions on this topic on SO often suggest adding the following css (overriding the defaults from Modena.css, the default stylesheet for JavaFX 8) to your style file:
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
At first glance, this removes the focus borders, but after some use I found that some UI elements were missing more than just that blue glow. After going through modena, I found that this is because of the way a lot of the nodes are drawn: many of them have a background color consisting of multiple boxes stacked on top of each other with different insets and radii, resulting in a border-like look.
I have also found that this background color derives from the previously mentioned properties for drawing a border. Hence setting the colors to transparent has the unintended effect that certain nodes (like panes, comboboxes, ...) show a border when not focused, but not anymore when they are focused, due to the way the background color is derived for the :focused pseudo-class.
Is it possible to remove the focus border (and faint focus border) so they retain the look of an unfocused element when they are in fact focused?
I've compiled a solution where the focus border is removed by combining what I found on SO by overriding more parts of modena: I've chosen to override the properties of the ":focused" pseudo-class by those of the non-focused defaults for button-like and pane-like things (as stated in modena itself). The results are:
.button:focused,
.toggle-button:focused,
.radio-button:focused > .radio,
.check-box:focused > .box,
.menu-button:focused,
.choice-box:focused,
.color-picker.split-button:focused > .color-picker-label,
.combo-box-base:focused,
.slider:focused .thumb {
-fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-body-color;
-fx-background-insets: 0 0 -1 0, 0, 1, 2;
-fx-background-radius: 3px, 3px, 2px, 1px;
}
.scroll-pane:focused,
.split-pane:focused,
.list-view:focused,
.tree-view:focused,
.table-view:focused,
.tree-table-view:focused,
.html-editor:focused {
-fx-background-color: -fx-box-border, -fx-control-inner-background;
-fx-background-insets: 0, 1;
-fx-padding: 1;
}
.radio-button > .radio, .radio-button:focused > .radio {
-fx-background-radius: 1.0em; /* large value to make sure this remains circular */
-fx-padding: 0.333333em; /* 4 -- padding from outside edge to the inner black dot */
}
.split-menu-button:focused {
-fx-background-color: -fx-shadow-highlight-color, -fx-outer-border;
-fx-background-insets: 0 0 -1 0, 0;
-fx-background-radius: 3, 3;
}
.split-menu-button:focused > .label {
-fx-text-fill: -fx-text-base-color;
-fx-background-color: -fx-inner-border, -fx-body-color;
-fx-background-insets: 1 0 1 1, 2 1 2 2;
-fx-background-radius: 2 0 0 2, 1 0 0 1;
-fx-padding: 0.333333em 0.667em 0.333333em 0.667em; /* 4 8 4 8 */
}
.split-menu-button:focused > .arrow-button {
-fx-background-color: -fx-inner-border, -fx-body-color;
-fx-background-insets: 1, 2;
-fx-background-radius: 0 2 2 0, 0 1 1 0;
-fx-padding: 0.5em 0.667em 0.5em 0.667em; /* 6 8 6 8 */
}
.scroll-bar:focused {
-fx-background-color: derive(-fx-box-border,30%), linear-gradient(to bottom, derive(-fx-base,-3%), derive(-fx-base,5%) 50%, derive(-fx-base,-3%));
-fx-background-insets: 0, 1 0 1 0;
}
.scroll-bar:vertical:focused {
-fx-background-color: derive(-fx-box-border,30%), linear-gradient(to right, derive(-fx-base,-3%), derive(-fx-base,5%) 50%, derive(-fx-base,-3%));
-fx-background-insets: 0, 0 1 0 1;
}
.text-input:focused {
-fx-highlight-fill: -fx-accent;
-fx-highlight-text-fill: white;
-fx-background-color: linear-gradient(to bottom, derive(-fx-text-box-border, -10%), -fx-text-box-border),
linear-gradient(from 0px 0px to 0px 5px, derive(-fx-control-inner-background, -9%), -fx-control-inner-background);
-fx-background-insets: 0, 1;
-fx-background-radius: 3, 2;
-fx-prompt-text-fill: transparent;
}
.text-area:focused .content {
-fx-background-color:
linear-gradient(from 0px 0px to 0px 4px, derive(-fx-control-inner-background, -8%), -fx-control-inner-background);
-fx-background-radius: 2;
}
.titled-pane:focused > .title > .arrow-button > .arrow {
-fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
-fx-background-insets: 1 0 -1 0, 0;
}
.color-picker.split-button:focused > .arrow-button {
-fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color;
-fx-background-insets: 1 1 1 0, 1, 2;
-fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0;
}
Basically what it does it change the rendering of the background color to draw the same look and feel whether the UI node has focus or not.
I am styling my MenuBar in JavaFX and I have been trying to change the font-Color
of the text in the MenuItem but no success.
this is my CSS code.
How could I do it?
.menu-bar {
-fx-background-color: darkslategray;
-fx-opacity: 0.5;
}
.menu-bar .menu-button:hover, .menu-bar .menu-button:focused, .menu-bar .menu-button:showing {
-fx-background: -fx-accent;
-fx-background-color: darkslategray;
-fx-opacity: 0.5;
-fx-text-fill: -fx-selection-bar-text;
}
.menu-item {
-fx-background-color: darkslategray;
-fx-padding: 0em 0em 0em 0em;
-fx-text-fill: greenyellow;
}
.context-menu {
-fx-skin: "com.sun.javafx.scene.control.skin.ContextMenuSkin";
-fx-background-color:darkslategray ;
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 0 6 6 6, 0 5 5 5, 0 4 4 4;
-fx-padding: 0.333333em 0.083333em 0.666667em 0.083333em; /* 4 1 8 1 */
-fx-opacity: 0.9;
}
To style the text of the menu-item in css, you have to select the label of the menu-item using .menu-item .label{....} like,
.menu-item .label{
-fx-text-fill: greenyellow;
}
I hope this solved your problem.