Discussion on passing custom props and accessing custom list items in @portabletext/react.
8 replies
Last updated: Feb 10, 2022
T
Upgraded to the new
Like this:
Alternately, I'm not sure how to access custom
@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} />
listItems. Where do I designate which
listItemis used for a list? Do I have to bake that into the Sanity schema? If so, how?
Feb 8, 2022, 7:44 PM
J
Hi Tatiana! Which frontend framework are you using?
Feb 8, 2022, 9:58 PM
T
user U
NextJS!Feb 9, 2022, 12:08 AM
T
user U
NextJS!Feb 9, 2022, 12:08 AM
J
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
J
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
T
Thanks,
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
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.
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_modulesdidn'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
T
Thanks,
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
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.
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_modulesdidn'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
J
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.