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

Support CSS custom properties (variables) #540

Closed
MurakamiShinyu opened this issue Aug 22, 2019 · 5 comments · Fixed by #967
Closed

Support CSS custom properties (variables) #540

MurakamiShinyu opened this issue Aug 22, 2019 · 5 comments · Fixed by #967
Assignees
Labels
feature request P1 Priority 1: Required for MVP (Minimum Viable Product) spec conformance

Comments

@MurakamiShinyu
Copy link
Member

CSS Custom Properties for Cascading Variables Module Level 1
https://drafts.csswg.org/css-variables/

@spring-raining
Copy link
Member

If this feature can be realized, it will be a powerful way to customize Vivliostyle themes. I'm looking forward to the addition of this feature:)

@depth42
Copy link

depth42 commented Jun 8, 2022

I am also voting for this feature. CSS variables are a great way to reduce redundancy in CSS sheets.

@MurakamiShinyu
Copy link
Member Author

Now Vivliostyle.js (v2.17.0) supports CSS Custom Properties for Cascading Variables Module Level 1.

CSS variables can be used within any style rules, also can be used in @page {…} context. See the following simple example:

:root {
  --page-width: 148mm;
  --page-height: 210mm;
  --page-margin: 20mm;
  --page-header: "My Report";
  --page-footer: counter(page) " / " counter(pages);
}
@page {
  size: var(--page-width) var(--page-height);
  margin: var(--page-margin);
  @top-center {
    content: var(--page-header); 
  }
  @bottom-center {
    content: var(--page-footer); 
  }
}

@depth42
Copy link

depth42 commented Aug 10, 2022

Great! Are fallback values also supported, like in: var(--my-color, blue)

@MurakamiShinyu
Copy link
Member Author

Are fallback values also supported, like in: var(--my-color, blue)

Yes, the whole https://www.w3.org/TR/css-variables-1/ spec is supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request P1 Priority 1: Required for MVP (Minimum Viable Product) spec conformance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants