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

Rendering of inline field HTML for styling by it's name #2527

Open
AntonAL opened this issue Feb 23, 2025 · 1 comment
Open

Rendering of inline field HTML for styling by it's name #2527

AntonAL opened this issue Feb 23, 2025 · 1 comment
Labels
feature-request New feature or request.

Comments

@AntonAL
Copy link

AntonAL commented Feb 23, 2025

I'm using fields to track date in format (date:: 2025.02.23)

I need to apply CSS styles only to these date fields.

I see following HTML

<span class="dataview inline-field" contenteditable="false">
  <span class="dataview inline-field-standalone-value">2025.02.23</span>
</span>

It's impossible to target CSS rules to "date" fields, because there is no attributes rendered

Describe the solution you'd like

Add new attribute "data-name" to wrapper span:

<span class="dataview inline-field" contenteditable="false" data-name="date">
  <span class="dataview inline-field-standalone-value">2025.02.23</span>
</span>
@AntonAL AntonAL added the feature-request New feature or request. label Feb 23, 2025
@holroy
Copy link
Collaborator

holroy commented Feb 23, 2025

I will implement this soon, as I've thought about it for some time. Until that happens I've successfully used [key:: value], and then just hide the key part, and style the value part to my liking.

body .inline-field-key[data-dv-key="bt"] {
  display: none;

  & + .inline-field-value {
    background-color: var(--background-primary);
    color: #ddddc5;

    &::after {
      content: "𝐭";
    }
  }
}

In this example I've changed the colors related to the bt's value, and added a unit of 𝐭. This in addition to hiding the actual key of bt.

holroy added a commit to holroy/obsidian-dataview that referenced this issue Feb 25, 2025
Added the inline key attributes to the standalone variant, as asked for in blacksmithgu#2527
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants