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

Custom CSS for markers #33

Closed
nathan-gs opened this issue May 21, 2024 · 8 comments
Closed

Custom CSS for markers #33

nathan-gs opened this issue May 21, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@nathan-gs
Copy link
Owner

          For a stock map card I managed to fix alignment by
.marker:not(:has(.entity-picture)) {
      text-align: center;}

in an external js-file.

Originally posted by @ildar170975 in #17 (comment)

@nathan-gs nathan-gs added the enhancement New feature or request label May 21, 2024
@nathan-gs nathan-gs self-assigned this May 21, 2024
nathan-gs added a commit that referenced this issue May 21, 2024
@nathan-gs
Copy link
Owner Author

Implemented in v0.9.0

@nathan-gs
Copy link
Owner Author

@ildar170975 this will make you happy (fixes the alignment problems)

@ildar170975
Copy link
Contributor

Thanks a lot!!!
These days I am very far from a civilian PC, will check it later )))

@ildar170975
Copy link
Contributor

ildar170975 commented May 29, 2024

@nathan-gs
Just tested the new css option.
It works fine - but only for attributes which are NOT overridden on lower levels.
Consider this code:

type: custom:map-card
entities:
  - entity: person.samsung_p6800
    css: 'border-radius: 0;'

изображение
The border-radius property is customized on a map-card-entity-marker level.
But on a lower .marker level this property is hard-coded as 50%.
So, the css property is GREAT for some properties - and cannot work for some other properties.

Look at this:
изображение
For example, by using css option we cannot apply a border: 1px solid red - but can define a variable --ha-marker-color and achieve the same goal. But border-radius is defined as "50%" w/o any CSS variable - so we cannot customize this property.

Probably not a big deal, just for clarification...

Update: proposed a PR to add a CSS variable for border-radius.

@shaiger
Copy link

shaiger commented Jan 19, 2025

I was hoping to change the border width/background color of the marker, this does not seem to be possible with the current implementation.

@ildar170975
Copy link
Contributor

@shaiger post a short code of your failed attempt.

@shaiger
Copy link

shaiger commented Jan 21, 2025

css: 'background-color: blue;'
css: 'border-width: thick;'
etc

(I apologize in advance if my poor knowhow in CSS is generating noise)

@ildar170975
Copy link
Contributor

ildar170975 commented Jan 29, 2025

@shaiger
The current situation is described here:
"It works fine - but only for attributes which are NOT overridden on lower levels."

Check this code - here some CSS variable is defined:

type: custom:map-card
entities:
  - entity: device_tracker.ipad_air_2_companion
    css: '--ha-marker-border-radius: 0;'

Image

On a lower level in a .marker element this variable is used:

Image

So, the css option provides a way to define CSS variables which are used inside a marker. If you wish a full control over ANY element - you should use card-mod as a flexible & powerful tool.

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

No branches or pull requests

3 participants