Skip to content

Css

css(from_string=None, *, from_dict=None, from_file=None)

Utility class to handle CSS injection for interactive plots.

This class provides multiple ways to load CSS: directly from a string, from a dictionary, or from a CSS file. It is intended to be combined with interactive plots.

Parameters:

Name Type Description Default
from_string Optional[str]

CSS rules in a string.

None
from_dict Optional[Mapping[str, Mapping[str, object]]]

Dictionary containing selectors as keys and dictionaries of property-value pairs as values.

None
from_file Optional[Pathish]

Path to a CSS file.

None
from ninejs import interactive, css, save

(
    interactive(p)
    + css(".tooltip { font-size: 2rem; }")
    + css(from_dict={".tooltip": {"font-size": "2rem"}})
    + css(from_file="style.css")
    + save("output.html")
)