Header levels styling #59
              
                Unanswered
              
          
                  
                    
                      rawestmoreland
                    
                  
                
                  asked this question in
                General
              
            Replies: 1 comment
-
| 
        
 There's no native way of doing that. If you're using Tailwind you can use the Typography Plugin to style your output - that's how we do it. If not (or for some reason you can't use the plugin) you can replace the  function headerLevelClass(level: number) {
  switch (data?.level) {
    case 1: return "text-xl"
    case 2: return "text-lg"
    default: return "text-md"
  }
}
const Header: RenderFn<{
  text: string;
  level: number;
}> = ({
  data, className = ""
}) => {
  const props: {
    [s: string]: string;
  } = {};
  props.className = `${headerLevelClass(data?.level)} ${className}`
  const Tag = `h${data?.level || 1}` as keyof JSX.IntrinsicElements;
  return <Tag {...props}>{data?.text && HTMLReactParser(data.text)}</Tag>;
}
export default () => <Blocks data={dataFromEditor} renderers={{
  headers: Header
}} /> | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to change the styling on the different header level?
Beta Was this translation helpful? Give feedback.
All reactions