Skip to content

Embedding Tailwind base styles  #84

@DaniFrancisco

Description

@DaniFrancisco

Hi,

I've been trialing Tailwind for styling with cms-react but I'm confused with the way of including Tailwind styles.

As suggested by the docs, I've been including the base styles at the top of my component, like this:

import "../../styles/tailwind.css";

export const Component = </div>;

export const meta = {
  label: "My component",
};

export * from "./fields";

my tailwind.css being

@tailwind base;
@tailwind components;
@tailwind utilities;

But, if we do that to every single component using Tailwind in a Hubspot webpage, won't we eventually end up with duplicated styling/ unnecessarily large stylesheets? Defeating Tailwind's purpose in the first place.

Based on https://github.com/HubSpot/cms-react/tree/main/examples/styling, it seems that the best practice would be to inject base styles as part of a partial and then include islands/ modules as needed. I guess that would work but then the modules wouldn't be self-sufficient. I guess my end goal here would be to leverage Hubspot's Website pages drag & drop functionality, delegating some of that stuff to non technical staff while keeping my components granular and isolated. Am I making any sense?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions