Skip to content

Enhance PrismicRichText #187

@benembery

Description

@benembery

Is your feature request related to a problem? Please describe.

No, more a request for an enhancement.

Describe the solution you'd like

I'd like to be able to apply css classes directly to a PrismicRichText component via a prop.

Most of the time I would use it apply a class to a single RichText element for example a title used in a slice. However, when there are multiple fragments to serialize it makes sense to wrap the elements with a div and apply the class there. In the instance of the multiple lines, I understand there is an argument that the component could ignore the class and leave it to the developer to create the wrapping div, or for consistency have the PrismicRichText always apply the class.

Describe alternatives you've considered

  • Wrapping the rich text field in an additional outer HTML tag to apply the class there.
  • Creating a component that applies a custom serializer that applies the class.
  • Using asText for single elements and applying the markup manually, but this in-flexible for complex use cases where event a single fragment rich text field might be using labels in the writing room.

This limitation made more acute by frameworks like tailwindcss where the preference is to apply the class to the element.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions