Skip to content

Prefix only certain classes #330

@garygreen

Description

@garygreen

Following on from the recent addition to the prefix option where you can specify a prefix for all classes - it would be nice to be able to list what classes should be prefixed:

prefix: {
   'container': 'tw-'
},

Reason for this suggestion is because the main reason why you use the prefix option is to avoid collisions with whatever framework e.g. Bootstrap that you are using. It seems wasteful to prefix every single classname when there is probably only a 5% collision of names with your current framework.

This will help reduce size of your output CSS and simplify the classnames you need to type.

Another idea, maybe some kind of "mutator" function that will be called when classes are being added to your CSS?

tailwind.addTransformer(function(css) {
    if (css.selector == '.container') {
        css.selector = 'tw-container';
    }

    return css;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions