Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size classes don't work on Label #19

Open
Moubassher opened this issue Nov 2, 2022 · 1 comment
Open

size classes don't work on Label #19

Moubassher opened this issue Nov 2, 2022 · 1 comment

Comments

@Moubassher
Copy link

First, Thank you for the fantastic implementation!
I just started using it and I saw the label's supported classes don't work. Here's the code:

Label lbl = new Label("some text");
lbl.getStyleClass().setAll("lbl", "h1", "lbl-primary");

but works on the Text class.
Thanks again

@EricRamirezS
Copy link

This might be a bit late, but hopefully, it can help someone in the future.
There are two ways to apply the size style class to a Label, although they may not be as intuitive as one might expect.

Expectation:

Label label = new Label();
label.getStylesheets().addAll("lbl", "lbl-primary", "h1");

Option 1:

This approach is used in the FXML examples in this repository: Wrap the Label in any Pane with the size class style.

Pane pane = new Pane();
pane.getStyleClass().add("h1");
Label label = new Label();
label.getStylesheets().addAll("lbl", "lbl-primary");
pane.getChildren().add(label);
<Pane styleClass="h1">
    <Label styleClass="lbl, lbl-default" text="Text"/>
</Pane>

Option 2:

Add a custom graphic to the Label and set the size style class to the graphic.

Label label = new Label();
label.getStylesheets().addAll("lbl", "lbl-primary");
Text text = new Text("Text");
text.getStyleClass().add("h1");
label.setGraphic(text);
<Label styleClass="lbl, lbl-default" >
    <graphic>
        <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Text" />
    </graphic>
</Label>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants