Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I render block children with custom containers? #742

Open
toddpadwick opened this issue Apr 8, 2023 · 1 comment
Open

How do I render block children with custom containers? #742

toddpadwick opened this issue Apr 8, 2023 · 1 comment
Labels
question Further information is requested

Comments

@toddpadwick
Copy link

I have a sanity Block content field that contains:

  • General text styling
  • Gallery component
  • banner component
  • video component

I would like to wrap chunks of block text in a different container tag to the other components so that I can apply styling to it that doesn't effect the components. such as max widths, or wrapping in a box or similar.
How can I specify a container tag for specific children of the block serialiser?

@toddpadwick toddpadwick added the question Further information is requested label Apr 8, 2023
@procrates
Copy link

Are you using portable text in the studio? If so create custom blocks and add a serializer in the frontend to render the blocks how you like.

Or create styles for the tags you like and create the serializer for that too. You can render a custom component for each style of block you add.

https://www.sanity.io/docs/portable-text-editor-configuration#dde2a7a4c661
https://www.sanity.io/docs/portable-text-editor-configuration#8997d6860827

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants