A simple React component for building living style guides with React. Check out the example.
- Markup samples based on React elements passed in as children.
- Custom markup strings if you don't want auto-generated ones.
- Built-in syntax highlighting with
highlight.js(or include your own). - Highly configurable (maybe too configurable).
- Allows custom class names and text on every element.
- Titles, descriptions, and expand/collapse controls are optional.
<StyleGuideItem
title="Cool Button"
description="This is a very cool button!"
>
<CoolButton>
Button!
</CoolButton>
<CoolButton type="primary">
Primary Button!
</CoolButton>
</StyleGuideItem>Optionally, include the CSS in react-style-guide.css for a nice set of default styles.
npm install
npm run exampleThen you can browse to http://localhost:8080/
To build the example files once:
npm run build-exampleThen you can open ./examples/index.html
Type: String Optional
A text title for the section.
Type: String Optional
An expanded description.
Type: Boolean Default: false
Set to true to use HTML for the section description.
Type: String
Example markup as a string. Use when you don't want auto-generated JSX markup for a section.
Type: Function
A custom syntax highlighting function. Takes the code example markup as a string, must return the example as HTML with syntax highlighting markup.
Type: Boolean Default: true
Set to false to disable expandable markup samples (making markup visible all the time).
Type: Boolean Default: false
Set to true to make markup samples expanded by default.
Type: Boolean Default: true
Set to true to prevent section titles from being wrapped in anchor tags (allowing users to easily link to sections).
Type: String Default: h2
HTML tag name for style guide headings.
Type: String Default: Guide
HTML class for the top level element of the component.
Type: String Default: Guide-heading
HTML class for the heading element.
Type: String Default: Guide-description
HTML class for the description element.
Type: String Default: Guide-example
HTML class for the example element.
Type: String Default: Guide-markup
HTML class for the markup sample element.
Type: String Default: Guide-anchor
HTML class for the anchor wrapping the heading element.
Type: String Default: Guide-expanderSection
HTML class for the element containing the section expander button.
Type: String Default: Guide-expander
HTML class for the section expander button.
Type: String Default: Expand
Text content of the section expander button when section is not expanded.
Type: String Default: Collapse
Text content of the section expander button when section is expanded.