A custom Chakra UI component that adds ready-made styles for rendering remote HTML content.

Overview

Chakra UI Prose

Prose is a Chakra UI component that adds a ready-made typography styles when rendering remote HTML.

Installation

yarn add @nikolovlazar/chakra-ui-prose

# or

npm i @nikolovlazar/chakra-ui-prose

Usage

To use the Prose component in your app, first you need to use the withProse theme extension:

import { withProse } from '@nikolovlazar/chakra-ui-prose';

const theme = extendTheme({}, withProse());

export default theme;

I know you've already did it, but I want to remind you to pass your theme in your ChakraProvider.

Then, to render the remote HTML content, you need to import the Prose component and wrap your content with it:

import { Prose } from '@nikolovlazar/chakra-ui-prose';

const MyPage = (content) => {
  return <Prose>{content}</Prose>;
};

export default MyPage;

Overriding Style

The withProse theme extension has an optional argument that overrides its default style. To change the style of a certain element, supply a component style object in the theme extension, provide the baseStyle property and override the element, like so:

const theme = extendTheme(
  {},
  withProse({
    baseStyle: {
      h2: {
        fontWeight: 'light',
      },
    },
  })
);

Refer to the default theme when overriding certain elements.

I've also created a CodeSandbox which you can use to try out the Prose component, and override its default style.

Making it official

The Prose package is not part of the official Chakra UI package for a reason. We decided to roll it out as a separate package is to avoid bloating the core library while we figure out how much people actually need it.

If you want this package to be part of the core library, let us know in this discussion thread: chakra-ui/chakra-ui-docs#469.

Comments
  • 118 kB bundle size?

    118 kB bundle size?

    After adding the withProse to the extendTheme my Next.js bundle size shot up a lot, about 118 kB.

    before:
    chunks/pages/_app-57c7e4e7ff00db3f.js  52.3 kB
    after:
    chunks/pages/_app-af31a7e4f630c391.js  170 kB
    

    Considering that the source in this repo is ~ 4 kB I don't know what is happening here. Is this expected or is something wrong?

    If this is expected, is it possible to only include the withProse in specific routes (nested ChakraProvider)?

    opened by skirsten 3
  • Skip selected part of HTML

    Skip selected part of HTML

    I would like to be able to skip certain parts of the HTML. E.g. something wrapped in a <div class='skip-prose-styling'></div> would not be styled with prose styles, but rather with chakra theme (that excludes prose stylings) Is it possible. If yes how can I work this out?

    opened by krzysztofMlczk 1
  • dangerouslySetInnerHTML doesn't work

    dangerouslySetInnerHTML doesn't work

    Hi, I'd like to use chakra-ui-prose to render contents coming from Strapi CMS to Next.js app as string with HTML. Unfortunately dangerouslySetInnerHTML doesn't work and I can't render it. I tried sorting this out myself, but I get various misuse of React Hooks errors when I'm trying to build the library locally (React versions are the same).

    Here's what I tried

    opened by mrcnk 1
  • build: disabled incremental compilation

    build: disabled incremental compilation

    Closes #7

    Currently the TypeScript compilation is configured as incremental. That generated a tsconfig.tsbuildinfo file which produced a super heavy package (100kB+). I could've added it to .npmignore, but I decided to turn off the incremental compilation completely. The whole source is less than 250 LoC anyway.

    opened by nikolovlazar 1
  • Version Packages

    Version Packages

    This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

    Releases

    @nikolovlazar/[email protected]

    Patch Changes

    opened by github-actions[bot] 0
  • Version Packages

    Version Packages

    This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

    Releases

    @nikolovlazar/[email protected]

    Minor Changes

    Patch Changes

    opened by github-actions[bot] 0
  • Version Packages

    Version Packages

    This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

    Releases

    @nikolovlazar/[email protected]

    Minor Changes

    opened by github-actions[bot] 0
  • Version Packages

    Version Packages

    This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

    Releases

    @nikolovlazar/[email protected]

    Patch Changes

    opened by github-actions[bot] 0
  • Update guide on how to use dangerouslySetInnerHTML

    Update guide on how to use dangerouslySetInnerHTML

    Update the guide on how to use dangerouslySetInnerHTML and add an example on content sanitation.

    Example without sanitation:

    <Prose>
       <div dangerouslySetInnerHTML={{ _html: content }} />
    </Prose>
    
    documentation 
    opened by nikolovlazar 0
  • Version Packages

    Version Packages

    This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

    Releases

    @nikolovlazar/[email protected]

    Patch Changes

    opened by github-actions[bot] 0
  • Version Packages

    Version Packages

    This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

    Releases

    @nikolovlazar/[email protected]

    Patch Changes

    opened by github-actions[bot] 0
Releases(@nikolovlazar/[email protected])
Owner
Lazar Nikolov
Developer, designer, course creator. Works @codechem. Core & DevRel at @chakra-ui. Instructor @eggheadio. Streaming on twitch.tv/nikolovlazar. OSS Advocate 🥑
Lazar Nikolov
Chakra UI Animations is a dependancy which offers you pre-built animations for your Chakra UI components.

Chakra UI Animations Chakra UI Animations is a dependancy which offers you pre-built animations for your Chakra UI components. Installation yarn add @

Code Chemistry Inc. 9 Nov 19, 2022
A plugin for Master Styles to group up styles and add selectors.

master-styles-group A plugin for Master Styles to group up styles and add selectors. THIS PROJECT IS IN BETA This project may contain bugs and have no

SerKo 5 Sep 27, 2022
Kuldeep 2 Jun 21, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Ready to manipulate partitions file? Create a custom partition, apply custom security system, hide the partition and share your hidden data on the www

Paranoia ?? Ready to manipulate partitions file? Create a custom partition, apply custom security system, hide the partition and share your hidden dat

Alice Snow 3 Dec 29, 2022
A table component for your Mantine data-rich applications, supporting asynchronous data loading, column sorting, custom cell data rendering, row context menus, dark theme, and more.

Mantine DataTable A "dark-theme aware" table component for your Mantine UI data-rich applications, featuring asynchronous data loading support, pagina

Ionut-Cristian Florescu 331 Jan 4, 2023
🐦 A simple and minimal dashboard for your homelab made with Chakra UI and NextJS!

Dashbird (WIP) ?? A simple and minimal dashboard for your homelab made with Chakra UI and NextJS! Features ?? Simple configuration ?? Easily selfhosta

mellowmarshe 3 Oct 23, 2022
A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view.

Strapi Preview Button A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view. Get Started Features I

Matt Milburn 53 Dec 30, 2022
open-source implementation of the Turborepo custom remote cache server.

This project is an open-source implementation of the Turborepo custom remote cache server. If Vercel's official cache server isn't a viable option, th

Maksim Sinik 362 Dec 30, 2022
A custom element for rendering stylable (light DOM) Markdown

Motivation There are many web components these days to render Markdown to HTML. Here are a few: <zero-md> <marked-element> …and I’m sure many others H

Lea Verou 252 Dec 20, 2022
A Kernel Package that adds a tab to Discord settings where you can add and arrange custom code snippets.

Code Snippets A Kernel package (specifically for Discord) that adds a tab in settings where you can add and manage code snippets. Requires: https://gi

SwishyPlugs 6 Dec 14, 2022
A clean-looking, secure, MySQL/MariaDB remote connection terminal made in NodeJS

NodeJS MySQL/MariaDB Terminal NodeJS MySQL/MariaDB Terminal is a remote terminal for MySQL/MariaDB databases, which works in the same way as the offic

TeknoSenpai 5 Jun 24, 2022
MUI Core is a collection of React UI libraries for shipping new features faster. Start with Material UI, our fully-loaded component library, or bring your own design system to our production-ready components.

MUI Core MUI Core contains foundational React UI component libraries for shipping new features faster. Material UI is a comprehensive library of compo

MUI 83.6k Dec 30, 2022
👜 Next-gen e-commerce built using Remix, Chakra UI, GraphQL and web3

?? Future Store About Here at New Store, we have the best in women's, men's, bags, shoes, accessories and more. Unmissable discounts and installments.

Matheus Trindade 16 Dec 26, 2022
An unofficial(yet) implementation of Chakra Ui for SvelteJS

Welcome to chakra-ui-svelte ?? An implementation of Chakra Ui in Svelte Homepage Demo Install pnpm install chakra-ui-svelte import { Box } from "chakr

Jonathan Irhodia 53 Dec 31, 2022
The Remix Stack with Clerk authentication, Supabase database, Chakra UI, testing, linting, and more.

Remix Bossa Nova Stack Learn more about Remix Stacks. What's in the stack User management with Clerk Database with Supabase Styling with Chakra UI Dep

Clerk 32 Jan 2, 2023
An opinionated Next.js + Chakra + TypeScript starter

Nextjs + Chakra + Typescript Starter ✨ An opinionated Next.js + Chakra + TypeScript starter packed with: ⚡️ Next.js 12 ⚛️ React 18 ✨ TypeScript ?? Cha

jaclyn 3 Sep 17, 2022