Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Discussion on passing custom props and accessing custom list items in @portabletext/react.

8 replies
Last updated: Feb 10, 2022
Upgraded to the new
@portabletext/react
. Is a reason I can't seem to pass in
className
:
Like this:

const ptComponents = {
  list: {
    bullet: ({ children, className }) => {
      return <ul className={className}>{children}</ul>;
    },
  },

<PortableText className={className} ... components={ptComponents} />
Alternately, I'm not sure how to access custom
listItems
. Where do I designate which
listItem
is used for a list? Do I have to bake that into the Sanity schema? If so, how?
Feb 8, 2022, 7:44 PM
Hi Tatiana! Which frontend framework are you using?
Feb 8, 2022, 9:58 PM
user U
NextJS!
Feb 9, 2022, 12:08 AM
user U
NextJS!
Feb 9, 2022, 12:08 AM
I was just reviewing the somewhat new to me @portabletext/react methods myself, and one of the team may be able to chime in with a quicker solution off the top of their head. But looking through documentation, I did notice that the plugin guide link on the main site may not be working at the moment. (this should be addressed very shortly) Here is a direct link to the module documentation that might be a good resource for you: https://github.com/portabletext/react-portabletext
Feb 9, 2022, 12:23 AM
I was just reviewing the somewhat new to me @portabletext/react methods myself, and one of the team may be able to chime in with a quicker solution off the top of their head. But looking through documentation, I did notice that the plugin guide link on the main site may not be working at the moment. Here is a direct link to the module documentation that might be a good resource for you: https://github.com/portabletext/react-portabletext
Feb 9, 2022, 12:23 AM
Thanks,
user U
!
I should have mentioned that I did scour that guide (including the demo). In it, couldn't find a reference to adding custom props like `className`—a peak into
node_modules
didn't seem like there currently is flexibility for that, but I could be wrong!
The demo shows an application of the custom bullet style (which is a helpful example), but I'm not able to trace back where that's styled on the front end.
Feb 9, 2022, 2:09 AM
Thanks,
user U
!
I should have mentioned that I did scour that guide (including the demo). In it, couldn't find a reference to adding custom props like `className`—a peak into
node_modules
didn't seem like there currently is flexibility for that, but I could be wrong!
The demo shows an application of the custom bullet style (which is a helpful example), but I'm not able to trace back where that's styled on the front end.
Feb 9, 2022, 2:09 AM
Hi Tatiana. I am trying to follow up - were you able to work this out?
Feb 10, 2022, 10:30 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?