- Notifications
You must be signed in to change notification settings - Fork0
A StyleSheetMap instance is a Map-like object that allows adding, updating, and deleting CSS rules through key-value pairs. It provides a convenient way to manage and manipulate CSS stylesheets, simplifying the handling of dynamic styles.
License
baotlake/style-sheet-map
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A StyleSheetMap instance is a Map-like object that allows adding, updating, and deleting CSS rules through key-value pairs. It provides a convenient way to manage and manipulate CSS stylesheets, simplifying the handling of dynamic styles.
# npmnpm i style-sheet-map# yarnyarn add style-sheet-map# pnpmpnpm add style-sheet-map
importStyleSheetMapfrom"style-sheet-map";// Create a new StyleSheetMap instanceconststyleMap=newStyleSheetMap({rules:[["header","header { color: blue; }"],["paragraph","p { font-size: 16px; }"],],onCreated:(sheet)=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,sheet];},});// Dynamically adding new CSS rulesstyleMap.set("button","button { background-color: green; }");// Update existing CSS rulesstyleMap.set("header","header { color: red; }");// Deleting a CSS rulestyleMap.delete("paragraph");// Disable the entire stylesheetstyleMap.disable=true;
The concept and code for StyleSheetMap were initially developed as part of theAnything Copilot project. This project extracts and refines that functionality into a standalone, general-purpose module.
Discover more about its origins:Anything Copilot
This project is licensed under the MIT License.
About
A StyleSheetMap instance is a Map-like object that allows adding, updating, and deleting CSS rules through key-value pairs. It provides a convenient way to manage and manipulate CSS stylesheets, simplifying the handling of dynamic styles.