Inkscape.org
Beyond the Basics XML Class Style for global color
  1. #1
    Inkscape Panda Inkscape Panda @Inkscapepanda

    Hi,

    Is it possible to define a Style in the XML editor in Inkscape and set a global fill color to be then referenced in different objects and paths as the inherited color?

  2. #2
    Inkscape Panda Inkscape Panda @Inkscapepanda

    Solved it. The weird trick is that I needed to create a text node nested withing an element node. To better explain it, type this inside the <defs> group in XML:

    1. Insert the Element Node:

    <style id="1">

    2. Insert the text Node inside the <style>

    ".ClassName { fill:red }"

    3. Create a rectangle for example, go into the XML Editor, delete the style and add a new attribute called: class with the value: ClassName

    Do not add the .(dot) when you reference your class.

  3. #3
    Tyler Durden Tyler Durden @TylerDurden

    There are tools to make it easier.

  4. #4
    Inkscape Panda Inkscape Panda @Inkscapepanda
    *

    Thanks, I stumbled on that tool just a moment ago. Although I have to say that the Selectors and CSS crash Inkscape when I try to use the checkboxes for each attribute style. It also crashes if you delete on the screen an object/path that the style was applied to, and then if you try to click on the remove icon bin in the CSS panel.

  5. #5
    Tyler Durden Tyler Durden @TylerDurden
    😇

    Recent info on CSS in Xav's tutorials: https://www.peppertop.com/blog/?p=1563  #112 - #115

  6. #6
    Tyler Durden Tyler Durden @TylerDurden
    *

    FYI some issues (with video!): https://gitlab.com/inkscape/inbox/-/issues/7685

     

    The + sign to add objects to a class seems to be missing from the Windows version of the CSS dialog. It works by clicking in the open space to the left of the class dropdown triangle.

    It is present in the Linux PPA (but tinyCss2 needs to be installed for the extension to work).

     

Inkscape Inkscape.org Inkscape Forum Beyond the Basics XML Class Style for global color